Index: sys/kern/kern_cpuset.c =================================================================== --- sys/kern/kern_cpuset.c (revision 220456) +++ sys/kern/kern_cpuset.c (working copy) @@ -745,6 +745,23 @@ return (0); } +int +cpuset_ffs(cpuset_t *set) +{ + size_t i; + int cbit; + + cbit = 0; + for (i = 0; i < _NCPUWORDS; i++) { + if (set->__bits[i] != 0) { + cbit = ffsl(set->__bits[i]); + cbit += i * _NCPUBITS; + break; + } + } + return (cbit); +} + /* * This is called once the final set of system cpus is known. Modifies * the root set and all children and mark the root read-only. Index: sys/sys/pcpu.h =================================================================== --- sys/sys/pcpu.h (revision 220456) +++ sys/sys/pcpu.h (working copy) @@ -134,6 +134,9 @@ } \ } while(0) +#define PCPU_CPU_GET(m, t) CPU_COPY(PCPU_PTR(m), t) +#define PCPU_CPU_SET(f, m) CPU_COPY(f, PCPU_PTR(m)) + #endif /* _KERNEL */ /* Index: sys/sys/cpuset.h =================================================================== --- sys/sys/cpuset.h (revision 220456) +++ sys/sys/cpuset.h (working copy) @@ -124,6 +124,30 @@ (d)->__bits[__i] &= ~(s)->__bits[__i]; \ } while (0) +#ifdef _KERNEL + +#define CPU_CLR_ATOMIC(n, p) \ + atomic_clear_long(&(p)->__bits[(n)/_NCPUBITS], __cpuset_mask(n)) + +#define CPU_SET_ATOMIC(n, p) \ + atomic_set_long(&(p)->__bits[(n)/_NCPUBITS], __cpuset_mask(n)) + +#define CPU_OR_ATOMIC(d, s) do { \ + __size_t __i; \ + for (__i = 0; __i < _NCPUWORDS; __i++) \ + atomic_set_long(&(d)->__bits[__i], \ + (s)->__bits[__i]); \ +} while (0) + +#define CPU_NAND_ATOMIC(d, s) do { \ + __size_t __i; \ + for (__i = 0; __i < _NCPUWORDS; __i++) \ + atomic_clear_long(&(d)->__bits[__i], \ + (s)->__bits[__i]); \ +} while (0) + +#endif + /* * Valid cpulevel_t values. */ @@ -184,6 +208,7 @@ int cpuset_setthread(lwpid_t id, cpuset_t *); int cpuset_create_root(struct prison *, struct cpuset **); int cpuset_setproc_update_set(struct proc *, struct cpuset *); +int cpuset_ffs(cpuset_t *); #else __BEGIN_DECLS