Date: Mon, 14 Jun 2010 10:02:59 -0400 From: John Baldwin <jhb@freebsd.org> To: mdf@freebsd.org Cc: src-committers@freebsd.org, Pawel Jakub Dawidek <pjd@freebsd.org>, svn-src-all@freebsd.org, Bruce Evans <brde@optusnet.com.au>, svn-src-head@freebsd.org, Lawrence Stewart <lstewart@freebsd.org> Subject: Re: svn commit: r209119 - head/sys/sys Message-ID: <201006141002.59464.jhb@freebsd.org> In-Reply-To: <AANLkTikR9LhvtjfzLpgVr7oV9uzp2n4dVWY-030UA4Hp@mail.gmail.com> References: <201006130239.o5D2du3m086332@svn.freebsd.org> <20100614230205.A37830@delplex.bde.org> <AANLkTikR9LhvtjfzLpgVr7oV9uzp2n4dVWY-030UA4Hp@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 14 June 2010 9:50:10 am mdf@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006141002.59464.jhb>