… | |
… | |
38 | * or so. |
38 | * or so. |
39 | * we try to detect these and simply assume they are not gcc - if they have |
39 | * we try to detect these and simply assume they are not gcc - if they have |
40 | * an issue with that they should have done it right in the first place. |
40 | * an issue with that they should have done it right in the first place. |
41 | */ |
41 | */ |
42 | #ifndef ECB_GCC_VERSION |
42 | #ifndef ECB_GCC_VERSION |
43 | # if defined(__INTEL_COMPILER) || defined(__SUNPRO_C) || defined(__llvm__) |
43 | #if defined(__INTEL_COMPILER) || defined(__SUNPRO_C) || defined(__llvm__) |
44 | # define ECB_GCC_VERSION(major,minor) 0 |
44 | #define ECB_GCC_VERSION(major,minor) 0 |
45 | # else |
45 | #else |
46 | # define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) |
46 | #define ECB_GCC_VERSION(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) |
47 | # endif |
47 | #endif |
48 | #endif |
48 | #endif |
49 | |
49 | |
50 | #ifndef __cplusplus |
50 | #ifndef __cplusplus |
51 | # if __STDC_VERSION__ >= 199901L |
51 | #if __STDC_VERSION__ >= 199901L |
52 | # define ECB_INLINE static inline |
52 | #define ECB_INLINE static inline |
53 | typedef _Bool ecb_bool; |
53 | typedef _Bool ecb_bool; |
54 | # else |
54 | #else |
55 | # define ECB_INLINE static inline /* yeah! */ |
55 | #define ECB_INLINE static inline /* we assume the extension is ubiquituous, please tell us when we are wrong, or upgrade to the GCC */ |
56 | typedef int ecb_bool; |
56 | typedef int ecb_bool; |
57 | # endif |
57 | #endif |
58 | #else |
58 | #else |
59 | # define ECB_INLINE static inline |
59 | #define ECB_INLINE static inline |
60 | typedef bool ecb_bool; |
60 | typedef bool ecb_bool; |
61 | #endif |
61 | #endif |
62 | |
62 | |
63 | #define ECB_CONCAT_(a, b) a ## b |
63 | #define ECB_CONCAT_(a, b) a ## b |
64 | #define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) |
64 | #define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) |
65 | #define ECB_STRINGIFY_(a) # a |
65 | #define ECB_STRINGIFY_(a) # a |
66 | #define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) |
66 | #define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) |
67 | |
67 | |
68 | #define ECB_HEADER_INLINE ECB_INLINE |
68 | #define ECB_HEADER_INLINE ECB_INLINE |
69 | |
69 | |
70 | #if ECB_GCC_VERSION(3,1) |
70 | #if ECB_GCC_VERSION(3,1) |
71 | # define ecb_attribute(attrlist) __attribute__(attrlist) |
71 | #define ecb_attribute(attrlist) __attribute__(attrlist) |
72 | # define ecb_is_constant(expr) __builtin_constant_p (expr) |
72 | #define ecb_is_constant(expr) __builtin_constant_p (expr) |
73 | # define ecb_expect(expr,value) __builtin_expect ((expr),(value)) |
73 | #define ecb_expect(expr,value) __builtin_expect ((expr),(value)) |
74 | # define ecb_prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) |
74 | #define ecb_prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality) |
75 | #else |
75 | #else |
76 | # define ecb_attribute(attrlist) |
76 | #define ecb_attribute(attrlist) |
77 | # define ecb_is_constant(expr) 0 |
77 | #define ecb_is_constant(expr) 0 |
78 | # define ecb_expect(expr,value) (expr) |
78 | #define ecb_expect(expr,value) (expr) |
79 | # define ecb_prefetch(addr,rw,locality) |
79 | #define ecb_prefetch(addr,rw,locality) |
80 | #endif |
80 | #endif |
81 | |
81 | |
82 | /* no emulation for ecb_decltype */ |
82 | /* no emulation for ecb_decltype */ |
83 | #if ECB_GCC_VERSION(4,5) |
83 | #if ECB_GCC_VERSION(4,5) |
84 | # define ecb_decltype(x) __decltype(x) |
84 | #define ecb_decltype(x) __decltype(x) |
85 | #elif ECB_GCC_VERSION(3,0) |
85 | #elif ECB_GCC_VERSION(3,0) |
86 | # define ecb_decltype(x) typeof(x) |
86 | #define ecb_decltype(x) typeof(x) |
87 | #endif |
87 | #endif |
88 | |
88 | |
89 | #define ecb_noinline ecb_attribute ((__noinline__)) |
89 | #define ecb_noinline ecb_attribute ((__noinline__)) |
90 | #define ecb_noreturn ecb_attribute ((__noreturn__)) |
90 | #define ecb_noreturn ecb_attribute ((__noreturn__)) |
91 | #define ecb_unused ecb_attribute ((__unused__)) |
91 | #define ecb_unused ecb_attribute ((__unused__)) |