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

Comparing libecb/ecb.h (file contents):
Revision 1.33 by root, Wed Jun 1 01:29:36 2011 UTC vs.
Revision 1.34 by root, Fri Jun 10 12:20:14 2011 UTC

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 inline 52# define ECB_INLINE static inline
53typedef _Bool ecb_bool; 53typedef _Bool ecb_bool;
54# else 54# else
55# define ECB_INLINE inline /* yeah! */ 55# define ECB_INLINE static inline /* yeah! */
56typedef int ecb_bool; 56typedef int ecb_bool;
57# endif 57# endif
58#else 58#else
59# define ECB_INLINE inline 59# define ECB_INLINE static inline
60typedef bool ecb_bool; 60typedef 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 static 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))
110#if ECB_GCC_VERSION(3,4) 110#if ECB_GCC_VERSION(3,4)
111#define ecb_ctz32(x) __builtin_ctz (x) 111#define ecb_ctz32(x) __builtin_ctz (x)
112#define ecb_popcount32(x) __builtin_popcount (x) 112#define ecb_popcount32(x) __builtin_popcount (x)
113#else 113#else
114ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const; 114ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const;
115ECB_HEADER_INLINE 115ECB_HEADER_INLINE int
116ecb_ctz32 (uint32_t x) 116ecb_ctz32 (uint32_t x)
117{ 117{
118 int r = 0; 118 int r = 0;
119 119
120 x &= -x; /* this isolates the lowest bit */ 120 x &= -x; /* this isolates the lowest bit */
127 127
128 return r; 128 return r;
129} 129}
130 130
131ECB_HEADER_INLINE int ecb_popcount32 (uint32_t x) ecb_const; 131ECB_HEADER_INLINE int ecb_popcount32 (uint32_t x) ecb_const;
132ECB_HEADER_INLINE 132ECB_HEADER_INLINE int
133ecb_popcount32 (uint32_t x) 133ecb_popcount32 (uint32_t x)
134{ 134{
135 x -= (x >> 1) & 0x55555555; 135 x -= (x >> 1) & 0x55555555;
136 x = ((x >> 2) & 0x33333333) + (x & 0x33333333); 136 x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
137 x = ((x >> 4) + x) & 0x0f0f0f0f; 137 x = ((x >> 4) + x) & 0x0f0f0f0f;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines