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

Comparing libecb/ecb.pod (file contents):
Revision 1.7 by root, Thu May 26 20:49:40 2011 UTC vs.
Revision 1.8 by root, Thu May 26 20:51:14 2011 UTC

61 61
62=head2 OPTIMISATION HINTS 62=head2 OPTIMISATION HINTS
63 63
64=over 4 64=over 4
65 65
66=item bool ecb_is_constant(expr) 66=item bool ecb_is_constant(expr) [MACRO]
67 67
68Returns true iff the expression can be deduced to be a compile-time 68Returns true iff the expression can be deduced to be a compile-time
69constant, and false otherwise. 69constant, and false otherwise.
70 70
71For example, when you have a C<rndm16> function that returns a 16 bit 71For example, when you have a C<rndm16> function that returns a 16 bit
89 return is_constant (n) && !(n & (n - 1)) 89 return is_constant (n) && !(n & (n - 1))
90 ? rndm16 () & (num - 1) 90 ? rndm16 () & (num - 1)
91 : (n * (uint32_t)rndm16 ()) >> 16; 91 : (n * (uint32_t)rndm16 ()) >> 16;
92 } 92 }
93 93
94=item bool ecb_expect (expr, value) 94=item bool ecb_expect (expr, value) [MACRO]
95 95
96Evaluates C<expr> and returns it. In addition, it tells the compiler that 96Evaluates C<expr> and returns it. In addition, it tells the compiler that
97the C<expr> evaluates to C<value> a lot, which can be used for static 97the C<expr> evaluates to C<value> a lot, which can be used for static
98branch optimisations. 98branch optimisations.
99 99
100Usually, you want to use the more intuitive C<ecb_likely> and 100Usually, you want to use the more intuitive C<ecb_likely> and
101C<ecb_unlikely> functions instead. 101C<ecb_unlikely> functions instead.
102 102
103=item bool ecb_likely (bool) 103=item bool ecb_likely (bool) [MACRO]
104 104
105=item bool ecb_unlikely (bool) 105=item bool ecb_unlikely (bool) [MACRO]
106 106
107These two functions expect a expression that is true or false and return 107These two functions expect a expression that is true or false and return
108C<1> or C<0>, respectively, so when used in the condition of an C<if> or 108C<1> or C<0>, respectively, so when used in the condition of an C<if> or
109other conditional statement, it will not change the program: 109other conditional statement, it will not change the program:
110 110
140 { 140 {
141 if (ecb_unlikely (current + size > end)) 141 if (ecb_unlikely (current + size > end))
142 real_reserve_method (size); /* presumably noinline */ 142 real_reserve_method (size); /* presumably noinline */
143 } 143 }
144 144
145=item bool ecb_assume (cond) 145=item bool ecb_assume (cond) [MACRO]
146 146
147Try to tell the compiler that some condition is true, even if it's not 147Try to tell the compiler that some condition is true, even if it's not
148obvious. 148obvious.
149 149
150This can be used to teach the compiler about invariants or other 150This can be used to teach the compiler about invariants or other
176 176
177This function does nothing itself, except tell the compiler that it will 177This function does nothing itself, except tell the compiler that it will
178never be executed. Apart from supressing a warning in some cases, this 178never be executed. Apart from supressing a warning in some cases, this
179function can be used to implement C<ecb_assume> or similar functions. 179function can be used to implement C<ecb_assume> or similar functions.
180 180
181=item bool ecb_prefetch (addr, rw, locality) 181=item bool ecb_prefetch (addr, rw, locality) [MACRO]
182 182
183Tells the compiler to try to prefetch memory at the given C<addr>ess 183Tells the compiler to try to prefetch memory at the given C<addr>ess
184for either reading (c<rw> = 0) or writing (C<rw> = 1). A C<locality> of 184for either reading (c<rw> = 0) or writing (C<rw> = 1). A C<locality> of
185C<0> means that there will only be one access later, C<3> means that 185C<0> means that there will only be one access later, C<3> means that
186the data will likely be accessed very often, and values in between mean 186the data will likely be accessed very often, and values in between mean
226 226
227=item int ecb_ctz32 (uint32_t x) 227=item int ecb_ctz32 (uint32_t x)
228 228
229=item int ecb_popcount32 (uint32_t x) 229=item int ecb_popcount32 (uint32_t x)
230 230
231=item uint32_t ecb_bswap16 (uint32_t x)
232
231=item uint32_t ecb_bswap32 (uint32_t x) 233=item uint32_t ecb_bswap32 (uint32_t x)
232 234
233=item uint32_t ecb_bswap16 (uint32_t x)
234
235=item uint32_t ecb_rotr32 (uint32_t x, unsigned int count) 235=item uint32_t ecb_rotr32 (uint32_t x, unsigned int count)
236 236
237=item uint32_t ecb_rotl32 (uint32_t x, unsigned int count) 237=item uint32_t ecb_rotl32 (uint32_t x, unsigned int count)
238 238
239=back 239=back
248 248
249=head2 UTILITY 249=head2 UTILITY
250 250
251=over 4 251=over 4
252 252
253=item ecb_array_length (name) [MACRO] 253=item element_count = ecb_array_length (name) [MACRO]
254 254
255=back 255=back
256 256
257 257

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines