http://blog.csdn.net/denny_233/article/details/6234687 2011 refer:http://en./wiki/Restrict From Wikipedia, the free encyclopedia
Jump to: navigation
,
search
This article is about the C programming language keyword. For other uses, see Restriction (disambiguation)
.
In the C programming language
, as of the C99 standard
, [edit ] OptimizationIf the compiler knows that there is only one pointer to a memory block, it can produce better code. The following hypothetical example makes it clearer: void updatePtrs( size_t * ptrA, size_t * ptrB, size_t * val) In the above code, the pointers load R1 ← * val ; Load the value of val pointer However if the void updatePtrs( size_t * restrict ptrA, size_t * restrict ptrB, size_t * restrict val) ; then the compiler is allowed to assume
that Now the compiler can generate better code as follows: load R1 ← * val Note that the above assembly code is better and the [edit ] References
[edit ] External links
Retrieved from "http://en./wiki/Restrict
"
|
|
来自: 心不留意外尘 > 《ccpp for hardware》