From owner-svn-src-all@freebsd.org Thu May 5 04:18:53 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5D0D3AA3CD4; Thu, 5 May 2016 04:18:53 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1CF711D46; Thu, 5 May 2016 04:18:53 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AF170B968; Thu, 5 May 2016 00:18:51 -0400 (EDT) From: John Baldwin To: Bruce Evans Cc: Pedro Giffuni , "Ngie Cooper (yaneurabeya)" , 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 Date: Wed, 04 May 2016 21:17:50 -0700 Message-ID: <2067797.hs1zGgLCXN@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <1928389.rOu33C1eaq@ralph.baldwin.cx> References: <201605021800.u42I0cjK084243@repo.freebsd.org> <20160504031930.A3395@besplex.bde.org> <1928389.rOu33C1eaq@ralph.baldwin.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 05 May 2016 00:18:51 -0400 (EDT) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2016 04:18:53 -0000 On Tuesday, May 03, 2016 11:19:44 AM John Baldwin wrote: > On Wednesday, May 04, 2016 03:58:40 AM Bruce Evans wrote: > > On Tue, 3 May 2016, John Baldwin wrote: > > > I would be happy to fix _bitset.h and _cpuset.h to not need sys/param.h. > > > However, they also use NBBY which is defined in sys/param.h. _sigset.h > > > gets around this because it uses an array of uint32_t and hardcodes a > > > shift count of 5 in _SIG_WORD() and a mask of 31 in _SIG_BIT(). If you > > > think it is fine to hardcode '8' instead of 'NBBY' I'll do that. Hmm, > > > sys/select.h hardcodes '8' for _NFDBITS, so I guess that is fine. > > > > NBBY can be cleaned up too. I rather like it, but it is bogus in C90 > > since it is spelled CHAR_BIT there, and it is now more bogus in POSIX > > since POSIX started specifying 8-bit bytes in 2001. Thus 8 is the > > correct spelling of it in the implementation where you don't want to > > expose a macro that makes it clearer what this magic 8 is. > > Ok. > > > BTW, I don't like select's and bitset's use of longs. Using unsigned > > for select is a historical mistake. Bitset apparently copied select > > except it unimproved to signed long. Bitstring uses unsigned char with > > no optimizations. Sigset uses uint32_t with no obvious optimizations, > > but compilers do a good job with with it due to its fixed size. I doubt > > that the manual optimization of using a wider size is important. > > I agree, but cpuset_t is already part of the ABI in existing releases. :( > Changing it to uint32_t would break the ABI for big-endian platforms. How about this: diff --git a/sys/arm/arm/genassym.c b/sys/arm/arm/genassym.c index f9cb23e..9c67018 100644 --- a/sys/arm/arm/genassym.c +++ b/sys/arm/arm/genassym.c @@ -28,6 +28,7 @@ #include __FBSDID("$FreeBSD$"); #include +#include #include #include #include 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)) -#define __bitset_mask(_s, n) \ - (1L << ((__bitset_words((_s)) == 1) ? \ - (__size_t)(n) : ((n) % _BITSET_BITS))) - -#define __bitset_word(_s, n) \ - ((__bitset_words((_s)) == 1) ? 0 : ((n) / _BITSET_BITS)) +#define __bitset_words(_s) (_howmany(_s, _BITSET_BITS)) #define BITSET_DEFINE(t, _s) \ struct t { \ long __bits[__bitset_words((_s))]; \ } -#define BITSET_T_INITIALIZER(x) \ - { .__bits = { x } } - -#define BITSET_FSET(n) \ - [ 0 ... ((n) - 1) ] = (-1L) - #endif /* !_SYS__BITSET_H_ */ diff --git a/sys/sys/_cpuset.h b/sys/sys/_cpuset.h index cd38484..1ddafac 100644 --- a/sys/sys/_cpuset.h +++ b/sys/sys/_cpuset.h @@ -44,13 +44,7 @@ #define CPU_SETSIZE CPU_MAXSIZE #endif -#define _NCPUBITS _BITSET_BITS -#define _NCPUWORDS __bitset_words(CPU_SETSIZE) - BITSET_DEFINE(_cpuset, CPU_SETSIZE); typedef struct _cpuset cpuset_t; -#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) -#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER - #endif /* !_SYS__CPUSET_H_ */ diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h index d130522..f1c7bf8 100644 --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -32,6 +32,13 @@ #ifndef _SYS_BITSET_H_ #define _SYS_BITSET_H_ +#define __bitset_mask(_s, n) \ + (1L << ((__bitset_words((_s)) == 1) ? \ + (__size_t)(n) : ((n) % _BITSET_BITS))) + +#define __bitset_word(_s, n) \ + ((__bitset_words((_s)) == 1) ? 0 : ((n) / _BITSET_BITS)) + #define BIT_CLR(_s, n, p) \ ((p)->__bits[__bitset_word(_s, n)] &= ~__bitset_mask((_s), (n))) @@ -185,5 +192,11 @@ __count += __bitcountl((p)->__bits[__i]); \ __count; \ }) - + +#define BITSET_T_INITIALIZER(x) \ + { .__bits = { x } } + +#define BITSET_FSET(n) \ + [ 0 ... ((n) - 1) ] = (-1L) + #endif /* !_SYS_BITSET_H_ */ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 4fa55a9..e017883 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -35,6 +35,10 @@ #include #include +#include + +#define _NCPUBITS _BITSET_BITS +#define _NCPUWORDS __bitset_words(CPU_SETSIZE) #define CPUSETBUFSIZ ((2 + sizeof(long) * 2) * _NCPUWORDS) @@ -61,6 +65,8 @@ #define CPU_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) #define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p) #define CPU_COUNT(p) BIT_COUNT(CPU_SETSIZE, p) +#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) +#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER /* * Valid cpulevel_t values. -- John Baldwin