Usage of unlikely in RCU code
From: Manish Katiyar <hidden>
Date: 2011-08-01 23:45:05
From: Manish Katiyar <hidden>
Date: 2011-08-01 23:45:05
C absolutely guarantees that the second will NEVER be evaluated before the first. Otherwise, things like this: if ( ptr && ptr->field ) could fail if ptr was NULL.
In your example yes. But is there a problem if the two conditions are
independent ? for eg..
foo() {
....
a = 0;
b = my_complex_function_call();
if (b && a) {
/* Do some non-trivial stuff */
} else {
printf("I'm an intelligent compiler\n");
}
.....
}
Does C guarantee that even in this case it won't be reordered and not
optimized ?
--
Thanks -
Manish