svn commit: r299122 - in head/sys: arm/arm sys
John Baldwin
jhb at FreeBSD.org
Thu May 5 15:43:28 UTC 2016
Author: jhb
Date: Thu May 5 15:43:26 2016
New Revision: 299122
URL: https://svnweb.freebsd.org/changeset/base/299122
Log:
Fix <sys/_bitset.h> and <sys/_cpuset.h> to not require <sys/param.h>.
- 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 <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/cpuset.h>
#include <sys/systm.h>
#include <sys/assym.h>
#include <sys/proc.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)
@@ -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 <sys/_cpuset.h>
#include <sys/bitset.h>
+#include <sys/queue.h>
+
+#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.
More information about the svn-src-all
mailing list