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

Comparing libecb/ecb.pod (file contents):
Revision 1.18 by root, Fri May 27 00:01:28 2011 UTC vs.
Revision 1.19 by sf-exg, Fri May 27 00:04:05 2011 UTC

105 { 105 {
106 puts (errline); 106 puts (errline);
107 abort (); 107 abort ();
108 } 108 }
109 109
110In this case, the compiler would probbaly be smart enough to decude it on 110In this case, the compiler would probably be smart enough to deduce it on
111it's own, so this is mainly useful for declarations. 111its own, so this is mainly useful for declarations.
112 112
113=item ecb_const 113=item ecb_const
114 114
115Declares that the function only depends on the values of it's arguments, 115Declares that the function only depends on the values of its arguments,
116much like a mathematical function. It specifically does not read or write 116much like a mathematical function. It specifically does not read or write
117any memory any arguments might point to, global variables, or call any 117any memory any arguments might point to, global variables, or call any
118non-const functions. It also must not have any side effects. 118non-const functions. It also must not have any side effects.
119 119
120Such a function can be optimised much more aggressively by the compiler - 120Such a function can be optimised much more aggressively by the compiler -
121for example, multiple calls with the same arguments can be optimised into 121for example, multiple calls with the same arguments can be optimised into
122a single call, which wouldn't be possible if the compiler would have to 122a single call, which wouldn't be possible if the compiler would have to
123expect any side effects. 123expect any side effects.
124 124
125It is best suited for functions in the sense of mathematical functions, 125It is best suited for functions in the sense of mathematical functions,
126such as a function return the square root of its input argument. 126such as a function returning the square root of its input argument.
127 127
128Not suited would be a function that calculates the hash of some memory 128Not suited would be a function that calculates the hash of some memory
129area you pass in, prints some messages or looks at a global variable to 129area you pass in, prints some messages or looks at a global variable to
130decide on rounding. 130decide on rounding.
131 131
154possible. 154possible.
155 155
156The compiler reacts by trying to place hot functions near to each other in 156The compiler reacts by trying to place hot functions near to each other in
157memory. 157memory.
158 158
159Whether a function is hot or not often depend son the whole program, 159Whether a function is hot or not often depends on the whole program,
160and less on the function itself. C<ecb_cold> is likely more useful in 160and less on the function itself. C<ecb_cold> is likely more useful in
161practise. 161practise.
162 162
163=item ecb_cold 163=item ecb_cold
164 164
169 169
170In addition to placing cold functions together (or at least away from hot 170In addition to placing cold functions together (or at least away from hot
171functions), this knowledge can be used in other ways, for example, the 171functions), this knowledge can be used in other ways, for example, the
172function will be optimised for size, as opposed to speed, and codepaths 172function will be optimised for size, as opposed to speed, and codepaths
173leading to calls to those functions can automatically be marked as if 173leading to calls to those functions can automatically be marked as if
174C<ecb_unlikel> had been used to reach them. 174C<ecb_unlikely> had been used to reach them.
175 175
176Good examples for such functions would be error reporting functions, or 176Good examples for such functions would be error reporting functions, or
177functions only called in exceptional or rare cases. 177functions only called in exceptional or rare cases.
178 178
179=item ecb_artificial 179=item ecb_artificial

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines