--- libecb/ecb.h 2011/05/26 18:26:59 1.14 +++ libecb/ecb.h 2011/05/26 18:43:48 1.19 @@ -1,5 +1,5 @@ /* - * libecb + * libecb - http://software.schmorp.de/pkg/libecb * * Copyright (©) 2009-2011 Marc Alexander Lehmann * Copyright (©) 2011 Emanuele Giaquinta @@ -34,7 +34,8 @@ /* many compilers define _GNUC_ to some versions but then only implement * what their idiot authors think are the "more important" extensions, - * causing enourmous grief for some better fake benchmark numbers or so. + * causing enourmous grief in return for some better fake benchmark numbers. + * or so. * we try to detect these and simply assume they are not gcc - if they have * an issue with that they should have done it right in the first place. */ @@ -97,15 +98,14 @@ #define ecb_likely(expr) ecb_expect (!!(expr), 1) /* try to tell the compiler that some condition is definitely true */ -#define ecb_assume(cond) do { if (!(cond)) unreachable (); } while (0) +#define ecb_assume(cond) do { if (!(cond)) ecb_unreachable (); } while (0) /* count trailing zero bits and count # of one bits */ -ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const; -ECB_HEADER_INLINE int ecb_popcount32 (uint32_t x) ecb_const; #if ECB_GCC_VERSION(3,4) -ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) { return __builtin_ctz (x); } -ECB_HEADER_INLINE int ecb_popcount32 (uint32_t x) { return __builtin_popcount (x); } +#define ecb_ctz32 (x) __builtin_ctz (x) +#define ecb_popcount32 (x) __builtin_popcount (x) #else +ECB_HEADER_INLINE int ecb_ctz32 (uint32_t x) ecb_const; ECB_HEADER_INLINE ecb_ctz32 (uint32_t x) { @@ -122,6 +122,7 @@ return r; } +ECB_HEADER_INLINE int ecb_popcount32 (uint32_t x) ecb_const; ECB_HEADER_INLINE ecb_popcount32 (uint32_t x) { @@ -134,10 +135,10 @@ } #endif -ECB_HEADER_INLINE uint32_t ecb_bswap32 (uint32_t x) ecb_const; #if ECB_GCC_VERSION(4,3) -ECB_HEADER_INLINE uint32_t ecb_bswap32 (uint32_t x) { return __builtin_bswap32 (x); } +# define ecb_bswap32(x) __builtin_bswap32 (x) #else +ECB_HEADER_INLINE uint32_t ecb_bswap32 (uint32_t x) ecb_const; ECB_HEADER_INLINE uint32_t ecb_bswap32 (uint32_t x) { @@ -148,16 +149,15 @@ } #endif -ECB_HEADER_INLINE void ecb_unreachable (void) ecb_attribute ((noreturn)); #if ECB_GCC_VERSION(4,5) -ECB_HEADER_INLINE void ecb_unreachable (void) { __builtin_unreachable (); } +# define ecb_unreachable() __builtin_unreachable () #else /* this seems to work fine, but gcc always emits a warning for it :/ */ +ECB_HEADER_INLINE void ecb_unreachable (void) ecb_noreturn; ECB_HEADER_INLINE void ecb_unreachable (void) { } #endif ECB_HEADER_INLINE unsigned char ecb_byteorder_helper () ecb_const; - ECB_HEADER_INLINE unsigned char ecb_byteorder_helper () {