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)
This commit is contained in:
parent
dd1669b914
commit
469bc5c414
@ -28,6 +28,7 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/cpuset.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/assym.h>
|
#include <sys/assym.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
|
@ -36,26 +36,15 @@
|
|||||||
* Macros addressing word and bit within it, tuned to make compiler
|
* Macros addressing word and bit within it, tuned to make compiler
|
||||||
* optimize cases when SETSIZE fits into single machine word.
|
* 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) \
|
#define __bitset_words(_s) (__howmany(_s, _BITSET_BITS))
|
||||||
(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_DEFINE(t, _s) \
|
#define BITSET_DEFINE(t, _s) \
|
||||||
struct t { \
|
struct t { \
|
||||||
long __bits[__bitset_words((_s))]; \
|
long __bits[__bitset_words((_s))]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BITSET_T_INITIALIZER(x) \
|
|
||||||
{ .__bits = { x } }
|
|
||||||
|
|
||||||
#define BITSET_FSET(n) \
|
|
||||||
[ 0 ... ((n) - 1) ] = (-1L)
|
|
||||||
|
|
||||||
#endif /* !_SYS__BITSET_H_ */
|
#endif /* !_SYS__BITSET_H_ */
|
||||||
|
@ -44,13 +44,7 @@
|
|||||||
#define CPU_SETSIZE CPU_MAXSIZE
|
#define CPU_SETSIZE CPU_MAXSIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _NCPUBITS _BITSET_BITS
|
|
||||||
#define _NCPUWORDS __bitset_words(CPU_SETSIZE)
|
|
||||||
|
|
||||||
BITSET_DEFINE(_cpuset, CPU_SETSIZE);
|
BITSET_DEFINE(_cpuset, CPU_SETSIZE);
|
||||||
typedef struct _cpuset cpuset_t;
|
typedef struct _cpuset cpuset_t;
|
||||||
|
|
||||||
#define CPUSET_FSET BITSET_FSET(_NCPUWORDS)
|
|
||||||
#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER
|
|
||||||
|
|
||||||
#endif /* !_SYS__CPUSET_H_ */
|
#endif /* !_SYS__CPUSET_H_ */
|
||||||
|
@ -32,6 +32,13 @@
|
|||||||
#ifndef _SYS_BITSET_H_
|
#ifndef _SYS_BITSET_H_
|
||||||
#define _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) \
|
#define BIT_CLR(_s, n, p) \
|
||||||
((p)->__bits[__bitset_word(_s, n)] &= ~__bitset_mask((_s), (n)))
|
((p)->__bits[__bitset_word(_s, n)] &= ~__bitset_mask((_s), (n)))
|
||||||
|
|
||||||
@ -185,5 +192,11 @@
|
|||||||
__count += __bitcountl((p)->__bits[__i]); \
|
__count += __bitcountl((p)->__bits[__i]); \
|
||||||
__count; \
|
__count; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#define BITSET_T_INITIALIZER(x) \
|
||||||
|
{ .__bits = { x } }
|
||||||
|
|
||||||
|
#define BITSET_FSET(n) \
|
||||||
|
[ 0 ... ((n) - 1) ] = (-1L)
|
||||||
|
|
||||||
#endif /* !_SYS_BITSET_H_ */
|
#endif /* !_SYS_BITSET_H_ */
|
||||||
|
@ -35,6 +35,10 @@
|
|||||||
#include <sys/_cpuset.h>
|
#include <sys/_cpuset.h>
|
||||||
|
|
||||||
#include <sys/bitset.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)
|
#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_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t)
|
||||||
#define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p)
|
#define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p)
|
||||||
#define CPU_COUNT(p) BIT_COUNT(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.
|
* Valid cpulevel_t values.
|
||||||
|
Loading…
Reference in New Issue
Block a user