From owner-svn-src-all@freebsd.org Thu May 5 15:43:28 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 2268EB2E041; Thu, 5 May 2016 15:43:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F046D1C8C; Thu, 5 May 2016 15:43:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u45FhRDr070426; Thu, 5 May 2016 15:43:27 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u45FhQOw070420; Thu, 5 May 2016 15:43:26 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201605051543.u45FhQOw070420@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 5 May 2016 15:43:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299122 - in head/sys: arm/arm sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 15:43:28 -0000 Author: jhb Date: Thu May 5 15:43:26 2016 New Revision: 299122 URL: https://svnweb.freebsd.org/changeset/base/299122 Log: Fix and to not require . - Hardcode '8' instead of NBBY in _BITSET_BITS. - Define a private version of 'howmany' for use in __bitset_words(). - While here, move a few more things out of _bitset.h and _cpuset.h to bitset.h and cpuset.h, respectively. The only things left in _bitset.h and _cpuset.h are the bits needed to define a bitset structure. Reviewed by: bde, kib (ish) Modified: head/sys/arm/arm/genassym.c head/sys/sys/_bitset.h head/sys/sys/_cpuset.h head/sys/sys/bitset.h head/sys/sys/cpuset.h Modified: head/sys/arm/arm/genassym.c ============================================================================== --- head/sys/arm/arm/genassym.c Thu May 5 15:32:47 2016 (r299121) +++ head/sys/arm/arm/genassym.c Thu May 5 15:43:26 2016 (r299122) @@ -28,6 +28,7 @@ #include __FBSDID("$FreeBSD$"); #include +#include #include #include #include Modified: head/sys/sys/_bitset.h ============================================================================== --- head/sys/sys/_bitset.h Thu May 5 15:32:47 2016 (r299121) +++ head/sys/sys/_bitset.h Thu May 5 15:43:26 2016 (r299122) @@ -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_ */ Modified: head/sys/sys/_cpuset.h ============================================================================== --- head/sys/sys/_cpuset.h Thu May 5 15:32:47 2016 (r299121) +++ head/sys/sys/_cpuset.h Thu May 5 15:43:26 2016 (r299122) @@ -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_ */ Modified: head/sys/sys/bitset.h ============================================================================== --- head/sys/sys/bitset.h Thu May 5 15:32:47 2016 (r299121) +++ head/sys/sys/bitset.h Thu May 5 15:43:26 2016 (r299122) @@ -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_ */ Modified: head/sys/sys/cpuset.h ============================================================================== --- head/sys/sys/cpuset.h Thu May 5 15:32:47 2016 (r299121) +++ head/sys/sys/cpuset.h Thu May 5 15:43:26 2016 (r299122) @@ -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.