1 #pragma once
2 
3 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
4 // Clang and GCC
5 #define M_ALIGN(x) __attribute__((aligned(x)))
6 #define M_RESTRICT __restrict__
7 #define M_PACK(statement) statement __attribute__((packed))
8 #define M_MUST_USE_RESULT __attribute__((warn_unused_result))
9 #define M_PREDICT_FALSE(x) (__builtin_expect(x, 0))
10 #define M_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
11 #elif defined(_MSC_VER)
12 // MSVC
13 #define M_ALIGN(x) __declspec(align(x))
14 #define M_RESTRICT __restrict
15 #define M_PACK(statement)  __pragma( pack(push, 1) ) statement __pragma( pack(pop) )
16 // MSVC supports _Check_return_ but it's a prefix, not a suffix. We could do
17 // something like M_PACK but for now don't bother.
18 #define M_MUST_USE_RESULT
19 #define M_PREDICT_FALSE(x) (x)
20 #define M_PREDICT_TRUE(x) (x)
21 #else
22 #error We do not support your compiler. Please email mixxx-devel@lists.sourceforge.net and tell us about your use case.
23 #endif
24 
25 #if defined(__clang__) && defined(__has_warning)
26 #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
27 #define M_FALLTHROUGH_INTENDED [[clang::fallthrough]]
28 #endif
29 #elif defined(__GNUC__) && __GNUC__ >= 7
30 // Taken from https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough_003d
31 // We could also use a comment, but that would require ccache users to set the
32 // keep_comments_cpp option. If we switch to C++17, we can use [[fallthough]].
33 #define M_FALLTHROUGH_INTENDED __attribute__ ((fallthrough));
34 #endif
35 
36 #ifndef M_FALLTHROUGH_INTENDED
37 #define M_FALLTHROUGH_INTENDED \
38   do {                         \
39   } while (0)
40 #endif
41