… | |
… | |
41 | # else |
41 | # else |
42 | # define ECB_INLINE inline /* yeah! */ |
42 | # define ECB_INLINE inline /* yeah! */ |
43 | typedef int ecb_bool; |
43 | typedef int ecb_bool; |
44 | # endif |
44 | # endif |
45 | #endif |
45 | #endif |
|
|
46 | |
|
|
47 | #define ECB_CONCAT_(a, b) a ## b |
|
|
48 | #define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) |
|
|
49 | #define ECB_STRINGIFY_(a) # a |
|
|
50 | #define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) |
46 | |
51 | |
47 | #define ECB_HEADER_INLINE static ECB_INLINE |
52 | #define ECB_HEADER_INLINE static ECB_INLINE |
48 | |
53 | |
49 | #if ECB_GCC_VERSION(3,1) |
54 | #if ECB_GCC_VERSION(3,1) |
50 | # define ecb_attribute(attrlist) __attribute__(attrlist) |
55 | # define ecb_attribute(attrlist) __attribute__(attrlist) |
… | |
… | |
134 | ECB_HEADER_INLINE ecb_bool ecb_little_endian () ecb_const { return ecb_byteorder_helper () == 0x44; }; |
139 | ECB_HEADER_INLINE ecb_bool ecb_little_endian () ecb_const { return ecb_byteorder_helper () == 0x44; }; |
135 | |
140 | |
136 | #if ecb_cplusplus_does_not_suck |
141 | #if ecb_cplusplus_does_not_suck |
137 | // does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) |
142 | // does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) |
138 | template<typename T, int N> |
143 | template<typename T, int N> |
139 | static inline int array_length (const T (&arr)[N]) |
144 | static inline int ecb_array_length (const T (&arr)[N]) |
140 | { |
145 | { |
141 | return N; |
146 | return N; |
142 | } |
147 | } |
143 | #else |
148 | #else |
144 | #define ecb_array_length(name) (sizeof (name) / sizeof (name [0])) |
149 | #define ecb_array_length(name) (sizeof (name) / sizeof (name [0])) |
145 | #endif |
150 | #endif |
146 | |
151 | |
147 | ECB_INLINE uint32_t |
152 | ECB_INLINE uint32_t |
148 | ecb_rotate32_right (uint32_t c, unsigned int count = 1) |
153 | ecb_rotr32 (uint32_t c, unsigned int count) |
149 | { |
154 | { |
150 | return (c << (32 - count)) | (c >> count); |
155 | return (c << (32 - count)) | (c >> count); |
151 | } |
156 | } |
152 | |
157 | |
153 | ECB_INLINE uint32_t |
158 | ECB_INLINE uint32_t |
154 | ecb_rotate32_left (uint32_t c, unsigned int count = 1) |
159 | ecb_rotl32 (uint32_t c, unsigned int count) |
155 | { |
160 | { |
156 | return (c >> (32 - count)) | (c << count); |
161 | return (c >> (32 - count)) | (c << count); |
157 | } |
162 | } |
158 | |
163 | |
159 | #endif |
164 | #endif |