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. MFC after: 2 weeks
This commit is contained in:
parent
4c918926cd
commit
070b490323
@ -176,4 +176,14 @@
|
|||||||
__bit; \
|
__bit; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
#define BIT_COUNT(_s, p) __extension__ ({ \
|
||||||
|
__size_t __i; \
|
||||||
|
int __count; \
|
||||||
|
\
|
||||||
|
__count = 0; \
|
||||||
|
for (__i = 0; __i < __bitset_words((_s)); __i++) \
|
||||||
|
__count += __builtin_popcount((p)->__bits[__i]); \
|
||||||
|
__count; \
|
||||||
|
})
|
||||||
|
|
||||||
#endif /* !_SYS_BITSET_H_ */
|
#endif /* !_SYS_BITSET_H_ */
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s)
|
#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_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)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Valid cpulevel_t values.
|
* Valid cpulevel_t values.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user