Date: Thu, 5 May 2016 21:14:49 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Konstantin Belousov <kostikbel@gmail.com> Cc: John Baldwin <jhb@freebsd.org>, Bruce Evans <brde@optusnet.com.au>, Pedro Giffuni <pfg@freebsd.org>, "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r298933 - in head: share/man/man9 sys/amd64/include sys/dev/acpica sys/dev/drm2 sys/dev/drm2/i915 sys/kern sys/sys sys/x86/acpica sys/x86/x86 Message-ID: <20160505203633.Y2142@besplex.bde.org> In-Reply-To: <20160505084222.GD2422@kib.kiev.ua> References: <201605021800.u42I0cjK084243@repo.freebsd.org> <20160504031930.A3395@besplex.bde.org> <1928389.rOu33C1eaq@ralph.baldwin.cx> <2067797.hs1zGgLCXN@ralph.baldwin.cx> <20160505084222.GD2422@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 5 May 2016, Konstantin Belousov wrote: > On Wed, May 04, 2016 at 09:17:50PM -0700, John Baldwin wrote: >> ... >> How about this: >> ... >> diff --git a/sys/sys/_bitset.h b/sys/sys/_bitset.h >> index 26a8848..89dd7b6 100644 >> --- a/sys/sys/_bitset.h >> +++ b/sys/sys/_bitset.h >> @@ -36,26 +36,15 @@ >> * Macros addressing word and bit within it, tuned to make compiler >> * optimize cases when SETSIZE fits into single machine word. >> */ >> -#define _BITSET_BITS (sizeof(long) * NBBY) >> +#define _BITSET_BITS (sizeof(long) * 8) >> >> -#define __bitset_words(_s) (howmany(_s, _BITSET_BITS)) >> +#define _howmany(x, y) (((x) + ((y) - 1)) / (y)) > The _howmany symbol is still in the user namespace. Implementation-reserved > names are __.* and _[A-Z].* . The names _.* also are reserved at file scope. sys/select.h also uses _howmany(), and that is correct there since it is only used in inner scopes that the application cannot conflict with (except possibly via -Wshadow warnings). I haven't checked this in the patch yet, but it is probably the same. In select.h, the inner scopes are one inside a struct declaration and one inside a compound statement in a statement-like macro. I like to use minimal underscores since 2 underscores are uglier. select.h does this perfectly or almost perfectly. An example of this is the __fd_mask typedef. This is used in non-inner scopes so it needs 2 underscores. The above fixes the bogus underscore on _s. 1 underscore is also ugly, and this one shows lack of understanding of namespaces. Underscores are never needed for macro parameters since they create their their own namespace. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160505203633.Y2142>