diff options
author | jhb <jhb@FreeBSD.org> | 2015-04-14 20:05:26 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2015-04-14 20:05:26 +0000 |
commit | 887f061ed2aee5cdb4d1feca2f366981de423082 (patch) | |
tree | 972b20fdf5104b2f360f75937fb17893c3d1afc8 /sys/sys/cpuset.h | |
parent | f3aa91c0843bcc324941e3ce2dc188ea47ef3294 (diff) | |
download | FreeBSD-src-887f061ed2aee5cdb4d1feca2f366981de423082.zip FreeBSD-src-887f061ed2aee5cdb4d1feca2f366981de423082.tar.gz |
MFC 278474,278476,280279:
Expand the bitcount*() API and use it to implement CPU_COUNT for cpusets.
278474:
Use __builtin_popcnt() to implement a BIT_COUNT() operation for bitsets and
use this to implement CPU_COUNT() to count the number of CPUs in a cpuset.
278476:
Use __builtin_popcountl() instead of __builtin_popcount().
280279:
Expand the bitcount* API to support 64-bit integers, plain ints and longs
and create a "hidden" API that can be used in other system headers without
adding namespace pollution.
- If the POPCNT instruction is enabled at compile time, use
__builtin_popcount*() to implement __bitcount*(), otherwise fall back
to software implementations.
- Use the existing bitcount16() and bitcount32() from <sys/systm.h> to
implement the non-POPCNT __bitcount16() and __bitcount32() in
<sys/types.h>.
- For the non-POPCNT __bitcount64(), use a similar SWAR method on 64-bit
systems. For 32-bit systems, use two __bitcount32() operations on the
two halves.
- Use __bitcount32() to provide a __bitcount() that operates on plain ints.
- Use either __bitcount32() or __bitcount64() to provide a
__bitcountl() that operates on longs.
- Add public bitcount*() wrappers for __bitcount*() for use in the kernel
in <sys/libkern.h>.
- Use __bitcountl() instead of __builtin_popcountl() in BIT_COUNT().
Diffstat (limited to 'sys/sys/cpuset.h')
-rw-r--r-- | sys/sys/cpuset.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index f3ec3da..dfa2d31 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -60,6 +60,7 @@ #define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s) #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) /* * Valid cpulevel_t values. |