… | |
… | |
236 | } |
236 | } |
237 | |
237 | |
238 | In this case, the compiler would probably be smart enough to deduce it on |
238 | In this case, the compiler would probably be smart enough to deduce it on |
239 | its own, so this is mainly useful for declarations. |
239 | its own, so this is mainly useful for declarations. |
240 | |
240 | |
|
|
241 | =item ecb_restrict |
|
|
242 | |
|
|
243 | Expands to the C<restrict> keyword or equivalent on compilers that support |
|
|
244 | them, and to nothing on others. Must be specified on a pointer type or |
|
|
245 | an array index to indicate that the memory doesn't alias with any other |
|
|
246 | restricted pointer in the same scope. |
|
|
247 | |
|
|
248 | Example: multiply a vector, and allow the compiler to parallelise the |
|
|
249 | loop, because it knows it doesn't overwrite input values. |
|
|
250 | |
|
|
251 | void |
|
|
252 | multiply (float *ecb_restrict src, |
|
|
253 | float *ecb_restrict dst, |
|
|
254 | int len, float factor) |
|
|
255 | { |
|
|
256 | int i; |
|
|
257 | |
|
|
258 | for (i = 0; i < len; ++i) |
|
|
259 | dst [i] = src [i] * factor; |
|
|
260 | } |
|
|
261 | |
241 | =item ecb_const |
262 | =item ecb_const |
242 | |
263 | |
243 | Declares that the function only depends on the values of its arguments, |
264 | Declares that the function only depends on the values of its arguments, |
244 | much like a mathematical function. It specifically does not read or write |
265 | much like a mathematical function. It specifically does not read or write |
245 | any memory any arguments might point to, global variables, or call any |
266 | any memory any arguments might point to, global variables, or call any |