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

Comparing cvsroot/libecb/ecb.pod (file contents):
Revision 1.14 by root, Thu May 26 23:23:08 2011 UTC vs.
Revision 1.15 by root, Thu May 26 23:26:29 2011 UTC

58 58
59=over 4 59=over 4
60 60
61=item ecb_attribute ((attrs...)) 61=item ecb_attribute ((attrs...))
62 62
63A simple wrapper that expands to C<__attribute__((attrs))> on GCC, and 63A simple wrapper that expands to C<__attribute__((attrs))> on GCC, and to
64to nothing on other compilers, so the effect is that only GCC sees these. 64nothing on other compilers, so the effect is that only GCC sees these.
65
66Example: use the C<deprecated> attribute on a function.
67
68 ecb_attribute((__deprecated__)) void
69 do_not_use_me_anymore (void);
65 70
66=item ecb_unused 71=item ecb_unused
67 72
68Marks a function or a variable as "unused", which simply suppresses a 73Marks a function or a variable as "unused", which simply suppresses a
69warning by GCC when it detects it as unused. This is useful when you e.g. 74warning by GCC when it detects it as unused. This is useful when you e.g.
70declare a variable but do not always use it: 75declare a variable but do not always use it:
71 76
72 { 77 {
73 int var ecb_unused; 78 int var ecb_unused;
74 79
75 #ifdef SOMECONDITION 80 #ifdef SOMECONDITION
76 var = ...; 81 var = ...;
77 return var; 82 return var;
78 #else 83 #else
79 return 0; 84 return 0;
80 #endif 85 #endif
81 } 86 }
82 87
83=item ecb_noinline 88=item ecb_noinline
84 89
85Prevent a function from being inlined - it might be optimised away, but 90Prevent a function from being inlined - it might be optimised away, but
86not inlined into other functions. This is useful if you know your function 91not inlined into other functions. This is useful if you know your function
139branch optimisations. 144branch optimisations.
140 145
141Usually, you want to use the more intuitive C<ecb_likely> and 146Usually, you want to use the more intuitive C<ecb_likely> and
142C<ecb_unlikely> functions instead. 147C<ecb_unlikely> functions instead.
143 148
144=item bool ecb_likely (bool) 149=item bool ecb_likely (cond)
145 150
146=item bool ecb_unlikely (bool) 151=item bool ecb_unlikely (cond)
147 152
148These two functions expect a expression that is true or false and return 153These two functions expect a expression that is true or false and return
149C<1> or C<0>, respectively, so when used in the condition of an C<if> or 154C<1> or C<0>, respectively, so when used in the condition of an C<if> or
150other conditional statement, it will not change the program: 155other conditional statement, it will not change the program:
151 156
275equivalently the number of bits set to 0 before the least significant 280equivalently the number of bits set to 0 before the least significant
276bit set), starting from 0. If C<x> is 0 the result is undefined. A 281bit set), starting from 0. If C<x> is 0 the result is undefined. A
277common use case is to compute the integer binary logarithm, i.e., 282common use case is to compute the integer binary logarithm, i.e.,
278floor(log2(n)). For example: 283floor(log2(n)). For example:
279 284
280 ecb_ctz32(3) = 0 285 ecb_ctz32 (3) = 0
281 ecb_ctz32(6) = 1 286 ecb_ctz32 (6) = 1
282 287
283=item int ecb_popcount32 (uint32_t x) 288=item int ecb_popcount32 (uint32_t x)
284 289
285Returns the number of bits set to 1 in C<x>. For example: 290Returns the number of bits set to 1 in C<x>. For example:
286 291
287 ecb_popcount32(7) = 3 292 ecb_popcount32 (7) = 3
288 ecb_popcount32(255) = 8 293 ecb_popcount32 (255) = 8
289 294
290=item uint32_t ecb_bswap16 (uint32_t x) 295=item uint32_t ecb_bswap16 (uint32_t x)
291 296
292=item uint32_t ecb_bswap32 (uint32_t x) 297=item uint32_t ecb_bswap32 (uint32_t x)
293 298

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines