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

Comparing libecb/ecb.pod (file contents):
Revision 1.10 by root, Thu May 26 21:03:15 2011 UTC vs.
Revision 1.11 by sf-exg, Thu May 26 21:18:52 2011 UTC

111 /* these two do the same thing */ 111 /* these two do the same thing */
112 if (some_condition) ...; 112 if (some_condition) ...;
113 if (ecb_likely (some_condition)) ...; 113 if (ecb_likely (some_condition)) ...;
114 114
115However, by using C<ecb_likely>, you tell the compiler that the condition 115However, by using C<ecb_likely>, you tell the compiler that the condition
116is likely to be true (and for C<ecb_unlikel>, that it is unlikely to be 116is likely to be true (and for C<ecb_unlikely>, that it is unlikely to be
117true). 117true).
118 118
119For example, when you check for a null pointer and expect this to be a 119For example, when you check for a null pointer and expect this to be a
120rare, exceptional, case, then use C<ecb_unlikely>: 120rare, exceptional, case, then use C<ecb_unlikely>:
121 121
222 222
223=item bool ecb_big_endian () 223=item bool ecb_big_endian ()
224 224
225=item bool ecb_little_endian () 225=item bool ecb_little_endian ()
226 226
227These two functions return true if the byte order is big endian
228(most-significant byte first) or little endian (least-significant byte
229first) respectively.
230
227=item int ecb_ctz32 (uint32_t x) 231=item int ecb_ctz32 (uint32_t x)
228 232
233Returns the index of the least significant bit set in C<x> (or
234equivalently the number of bits set to 0 before the least significant
235bit set), starting from 0. If C<x> is 0 the result is undefined. A
236common use case is to compute the integer binary logarithm, i.e.,
237floor(log2(n)). For example:
238
239 ecb_ctz32(3) = 1
240 ecb_ctz32(6) = 2
241
229=item int ecb_popcount32 (uint32_t x) 242=item int ecb_popcount32 (uint32_t x)
230 243
244Returns the number of bits set to 1 in C<x>. For example:
245
246 ecb_popcount32(7) = 3
247 ecb_popcount32(255) = 8
248
231=item uint32_t ecb_bswap16 (uint32_t x) 249=item uint32_t ecb_bswap16 (uint32_t x)
232 250
233=item uint32_t ecb_bswap32 (uint32_t x) 251=item uint32_t ecb_bswap32 (uint32_t x)
234 252
235=item uint32_t ecb_rotr32 (uint32_t x, unsigned int count) 253=item uint32_t ecb_rotr32 (uint32_t x, unsigned int count)
236 254
237=item uint32_t ecb_rotl32 (uint32_t x, unsigned int count) 255=item uint32_t ecb_rotl32 (uint32_t x, unsigned int count)
238 256
257These two functions return the value of C<x> after shifting all the bits
258by C<count> positions to the right or left respectively.
259
239=back 260=back
240 261
241=head2 ARITHMETIC 262=head2 ARITHMETIC
242 263
243=over 4 264=over 4
244 265
245=item x = ecb_mod (m, n) [MACRO] 266=item x = ecb_mod (m, n) [MACRO]
246 267
268Returns the positive remainder of the modulo operation between C<m>
269and C<n>.
270
247=back 271=back
248 272
249=head2 UTILITY 273=head2 UTILITY
250 274
251=over 4 275=over 4

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines