… | |
… | |
101 | /* try to tell the compiler that some condition is definitely true */ |
101 | /* try to tell the compiler that some condition is definitely true */ |
102 | #define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0) |
102 | #define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0) |
103 | |
103 | |
104 | /* count trailing zero bits and count # of one bits */ |
104 | /* count trailing zero bits and count # of one bits */ |
105 | #if ECB_GCC_VERSION(3,4) |
105 | #if ECB_GCC_VERSION(3,4) |
106 | #define ecb_ctz32(x) __builtin_ctz (x) |
106 | #define ecb_ctz32(x) __builtin_ctz (x) |
107 | #define ecb_popcount32(x) __builtin_popcount (x) |
107 | #define ecb_popcount32(x) __builtin_popcount (x) |
108 | #else |
108 | #else |
109 | ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const; |
109 | ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const; |
110 | ECB_HEADER_INLINE |
110 | ECB_HEADER_INLINE |
111 | ecb_ctz32 (uint32_t x) |
111 | ecb_ctz32 (uint32_t x) |
… | |
… | |
179 | ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) ecb_const; |
179 | ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) ecb_const; |
180 | ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; }; |
180 | ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; }; |
181 | ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) ecb_const; |
181 | ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) ecb_const; |
182 | ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; }; |
182 | ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; }; |
183 | |
183 | |
184 | #define ecb_mod(m, n) ((m) < 0 ? ((n) - (-(m) % (n))) : ((m) % (n))) |
184 | #define ecb_mod(m,n) ((m) < 0 ? ((n) - (-(m) % (n))) : ((m) % (n))) |
185 | |
185 | |
186 | #if ecb_cplusplus_does_not_suck |
186 | #if ecb_cplusplus_does_not_suck |
187 | // does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) |
187 | // does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) |
188 | template<typename T, int N> |
188 | template<typename T, int N> |
189 | static inline int ecb_array_length (const T (&arr)[N]) |
189 | static inline int ecb_array_length (const T (&arr)[N]) |