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

Comparing libecb/ecb.h (file contents):
Revision 1.12 by root, Thu May 26 18:17:45 2011 UTC vs.
Revision 1.13 by root, Thu May 26 18:21:04 2011 UTC

86#define ecb_const ecb_attribute ((const)) 86#define ecb_const ecb_attribute ((const))
87#define ecb_pure ecb_attribute ((pure)) 87#define ecb_pure ecb_attribute ((pure))
88#define ecb_hot ecb_attribute ((hot)) /* 4.3 */ 88#define ecb_hot ecb_attribute ((hot)) /* 4.3 */
89#define ecb_cold ecb_attribute ((cold)) /* 4.3 */ 89#define ecb_cold ecb_attribute ((cold)) /* 4.3 */
90 90
91#if ECB_GCC_VERSION(4,5)
92# define ecb_unreachable() __builtin_unreachable ()
93#else
94/* this seems to work fine, but gcc always emits a warning for it :/ */
95ECB_HEADER_INLINE void ecb_unreachable () ecb_attribute ((noreturn));
96ECB_HEADER_INLINE void ecb_unreachable () { }
97#endif
98
99/* put into ifs if you are very sure that the expression */ 91/* put into ifs if you are very sure that the expression */
100/* is mostly true or mosty false. note that these return */ 92/* is mostly true or mosty false. note that these return */
101/* booleans, not the expression. */ 93/* booleans, not the expression. */
102#define ecb_unlikely(expr) ecb_expect (!!(expr), 0) 94#define ecb_unlikely(expr) ecb_expect (!!(expr), 0)
103#define ecb_likely(expr) ecb_expect (!!(expr), 1) 95#define ecb_likely(expr) ecb_expect (!!(expr), 1)
136 128
137 return x >> 24; 129 return x >> 24;
138} 130}
139#endif 131#endif
140 132
133#if ECB_GCC_VERSION(4,3)
134ECB_GCC_VERSION uint32_t ecb_bswap32 (uint32_t x) { return __builtin_bswap32 (x); }
135#else
136ECB_GCC_VERSION uint32_t
137ecb_bswap32 (uint32_t x)
138{
139 return (x >> 24)
140 | ((x >> 8) & 0x0000ff00)
141 | ((x << 8) & 0x00ff0000)
142 | (x << 24);
143}
144#endif
145
146#if ECB_GCC_VERSION(4,5)
147# define ecb_unreachable() __builtin_unreachable ()
148#else
149/* this seems to work fine, but gcc always emits a warning for it :/ */
150ECB_HEADER_INLINE void ecb_unreachable () ecb_attribute ((noreturn));
151ECB_HEADER_INLINE void ecb_unreachable () { }
152#endif
153
141ECB_HEADER_INLINE unsigned char 154ECB_HEADER_INLINE unsigned char
142ecb_byteorder_helper () ecb_const 155ecb_byteorder_helper () ecb_const
143{ 156{
144 const uint32_t u = 0x11223344; 157 const uint32_t u = 0x11223344;
145 return *(unsigned char *)&u; 158 return *(unsigned char *)&u;
169ecb_rotl32 (uint32_t x, unsigned int count) 182ecb_rotl32 (uint32_t x, unsigned int count)
170{ 183{
171 return (x >> (32 - count)) | (x << count); 184 return (x >> (32 - count)) | (x << count);
172} 185}
173 186
174#if ECB_GCC_VERSION(4,3)
175ECB_GCC_VERSION uint32_t ecb_bswap32 (uint32_t x) { return __builtin_bswap32 (x); }
176#else
177ECB_GCC_VERSION uint32_t
178ecb_bswap32 (uint32_t x)
179{
180 return (x >> 24)
181 | ((x >> 8) & 0x0000ff00)
182 | ((x << 8) & 0x00ff0000)
183 | (x << 24);
184}
185#endif 187#endif
186 188
187#endif
188

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines