On Monday 14 June 2010 9:50:10 am m...@freebsd.org wrote: > > BTW, one reason I liked BSD code more than gnu code is that it didn't > > use so many macros. Macros should only exist when they are not just > > syntactic sugar, like DPCPU_SUM() and unlike CPU_FOREACH(). > > As a style question, I do understand (generally) why too many macros > make the code confusing. However, the *FOREACH macros all fit the > same pattern and having a macro to iterate protects one against > changes in the implementation -- there's a single location to change > if e.g. we want to make CPU_FOREACH use a bitwise operator to > determine the next non-zero bit, rather than testing each > individually.
In the case of CPU_FOREACH() there is a very good chance that the implementation details will change when we switch from cpumask_t to cpuset_t, which is part of the reason I added it. I am less of a fan of macros that just wrap TAILQ_FOREACH() (note that there isn't a PCPU_FOREACH() since you can already do this via SLIST_FOREACH() now for example) such as FOREACH_PROC_IN_SYSTEM(). CPU_FOREACH() has additional logic in that it hides the CPU_ABSENT() stuff, so to me it doesn't quite fall in that class. (Some code was using pcpu_find() instead of CPU_ABSENT() to determine absent CPUs as well FWIW.) -- John Baldwin _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"