ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libecb/ecb.h
(Generate patch)

Comparing libecb/ecb.h (file contents):
Revision 1.23 by root, Thu May 26 19:40:09 2011 UTC vs.
Revision 1.29 by root, Mon May 30 16:22:55 2011 UTC

53typedef _Bool ecb_bool; 53typedef _Bool ecb_bool;
54# else 54# else
55# define ECB_INLINE inline /* yeah! */ 55# define ECB_INLINE inline /* yeah! */
56typedef int ecb_bool; 56typedef int ecb_bool;
57# endif 57# endif
58#else
59# define ECB_INLINE inline
60typedef bool ecb_bool;
58#endif 61#endif
59 62
60#define ECB_CONCAT_(a, b) a ## b 63#define ECB_CONCAT_(a, b) a ## b
61#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) 64#define ECB_CONCAT(a, b) ECB_CONCAT_(a, b)
62#define ECB_STRINGIFY_(a) # a 65#define ECB_STRINGIFY_(a) # a
81# define ecb_decltype(x) __decltype(x) 84# define ecb_decltype(x) __decltype(x)
82#elif ECB_GCC_VERSION(3,0) 85#elif ECB_GCC_VERSION(3,0)
83# define ecb_decltype(x) typeof(x) 86# define ecb_decltype(x) typeof(x)
84#endif 87#endif
85 88
89#define ecb_artificial ecb_attribute ((__artificial__)) /* 4.3 */
86#define ecb_noinline ecb_attribute ((noinline)) 90#define ecb_noinline ecb_attribute ((__noinline__))
87#define ecb_noreturn ecb_attribute ((noreturn)) 91#define ecb_noreturn ecb_attribute ((__noreturn__))
88#define ecb_unused ecb_attribute ((unused)) 92#define ecb_unused ecb_attribute ((__unused__))
89#define ecb_const ecb_attribute ((const)) 93#define ecb_const ecb_attribute ((__const__))
90#define ecb_pure ecb_attribute ((pure)) 94#define ecb_pure ecb_attribute ((__pure__))
91#define ecb_hot ecb_attribute ((hot)) /* 4.3 */ 95#define ecb_hot ecb_attribute ((__hot__)) /* 4.3 */
92#define ecb_cold ecb_attribute ((cold)) /* 4.3 */ 96#define ecb_cold ecb_attribute ((__cold__)) /* 4.3 */
93 97
94/* put into if's if you are very sure that the expression */ 98/* put into if's if you are very sure that the expression */
95/* is mostly true or mosty false. note that these return */ 99/* is mostly true or mosty false. note that these return */
96/* booleans, not the expression. */ 100/* booleans, not the expression. */
97#define ecb_unlikely(expr) ecb_expect (!!(expr), 0) 101#define ecb_unlikely(expr) ecb_expect (!!(expr), 0)
100/* try to tell the compiler that some condition is definitely true */ 104/* try to tell the compiler that some condition is definitely true */
101#define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0) 105#define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0)
102 106
103/* count trailing zero bits and count # of one bits */ 107/* count trailing zero bits and count # of one bits */
104#if ECB_GCC_VERSION(3,4) 108#if ECB_GCC_VERSION(3,4)
105#define ecb_ctz32 (x) __builtin_ctz (x) 109#define ecb_ctz32(x) __builtin_ctz (x)
106#define ecb_popcount32 (x) __builtin_popcount (x) 110#define ecb_popcount32(x) __builtin_popcount (x)
107#else 111#else
108ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const; 112ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const;
109ECB_HEADER_INLINE 113ECB_HEADER_INLINE
110ecb_ctz32 (uint32_t x) 114ecb_ctz32 (uint32_t x)
111{ 115{
178ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) ecb_const; 182ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) ecb_const;
179ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; }; 183ECB_HEADER_INLINE ecb_bool ecb_big_endian (void) { return ecb_byteorder_helper () == 0x11; };
180ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) ecb_const; 184ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) ecb_const;
181ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; }; 185ECB_HEADER_INLINE ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () == 0x44; };
182 186
183#define ecb_mod(m, n) ((m) < 0 ? ((n) - (-(m) % (n))) : ((m) % (n))) 187#define ecb_mod(m,n) ((m) < 0 ? ((n) - (-(m) % (n))) : ((m) % (n)))
184 188
185#if ecb_cplusplus_does_not_suck 189#if ecb_cplusplus_does_not_suck
186// does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm) 190// does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm)
187template<typename T, int N> 191template<typename T, int N>
188static inline int ecb_array_length (const T (&arr)[N]) 192static inline int ecb_array_length (const T (&arr)[N])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines