1 #ifndef MY_COMPILER_INCLUDED
2 #define MY_COMPILER_INCLUDED
27 #include <my_global.h>
36 # define MY_GNUC_PREREQ(maj, min) \
37 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
41 # if MY_GNUC_PREREQ(4,5)
42 # define MY_ASSERT_UNREACHABLE() __builtin_unreachable()
46 #elif defined _MSC_VER
47 # define MY_ALIGNOF(type) __alignof(type)
48 # define MY_ALIGNED(n) __declspec(align(n))
51 #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
52 # if __SUNPRO_C >= 0x590
58 # if __xlC__ >= 0x0600
63 #elif defined(__HP_aCC) || defined(__HP_cc)
64 # if (__HP_aCC >= 60000) || (__HP_cc >= 60000)
71 # define MY_ALIGNOF(type) __alignof__(type)
73 # define MY_ALIGNED(n) __attribute__((__aligned__((n))))
80 #ifndef MY_GNUC_PREREQ
81 # define MY_GNUC_PREREQ(maj, min) (0)
86 template<
typename type>
struct my_alignof_helper {
char m1;
type m2; };
88 # define MY_ALIGNOF(type) offsetof(my_alignof_helper<type>, m2)
90 # define MY_ALIGNOF(type) offsetof(struct { char m1; type m2; }, m2)
94 #ifndef MY_ASSERT_UNREACHABLE
95 # define MY_ASSERT_UNREACHABLE() do { assert(0); } while (0)
107 # if defined(MY_ALIGNED)
109 template<
size_t alignment>
struct my_alignment_imp;
110 template<>
struct MY_ALIGNED(1) my_alignment_imp<1> {};
111 template<>
struct MY_ALIGNED(2) my_alignment_imp<2> {};
112 template<>
struct MY_ALIGNED(4) my_alignment_imp<4> {};
113 template<>
struct MY_ALIGNED(8) my_alignment_imp<8> {};
114 template<>
struct MY_ALIGNED(16) my_alignment_imp<16> {};
117 template<
size_t alignment>
118 struct my_alignment_imp {
double m1; };
131 template <
size_t size,
size_t alignment>
132 struct my_aligned_storage
137 my_alignment_imp<alignment> align;
148 #define MY_ALIGNED(size)
151 #include <my_attribute.h>