Messages in this thread | | | Date | Mon, 20 Mar 2006 09:22:08 +0100 | From | "Peter T. Breuer" <> | Subject | Re: OOPS: 2.6.16-rc6 cpufreq_conservative |
| |
In article <20060320061212.GG21493@w.ods.org> you wrote: > On Sun, Mar 19, 2006 at 11:33:17AM -0800, Linus Torvalds wrote: >> Of course, I shouldn't say "works", since it is still totally untested. It >> _looks_ good, and that statement expression usage is just _so_ ugly it's >> cute.
> #define for_each_cpu_mask(cpu, mask) \ > for ((cpu) = 0; (cpu) < NR_CPUS; (cpu)++) { \ > unsigned long __bits = (mask).bits[0] >> (cpu); \ > if (!__bits) \ > break; \ > if (!__bits & 1) \ > continue; \ > else
While that's slightly wrong (needs a closing } supplied by the user), it does inspire me to point out that one can put the skips in the ordinary statement part of the for and use the if else idea to make sure that the for needs just one statement following (i.e. no dangling } supplied by the user)
#define for_each_cpu_mask(cpu, mask) \ for ((cpu) = 0; (cpu) < NR_CPUS; (cpu)++) \ if (!((mask).bits[0] >> (cpu)) { \ break; \ } else if (!((mask).bits[0] >> (cpu)) & 1) { \ continue; \ } else
I expect common subexpression optimization in the compiler to remove the repetition here. If not, somebody else can think about it!
Peter - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |