diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ia64/include/runq.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/sys/ia64/include/runq.h b/sys/ia64/include/runq.h index 9f844b6..2a8eb7f 100644 --- a/sys/ia64/include/runq.h +++ b/sys/ia64/include/runq.h @@ -36,23 +36,30 @@ #define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs64(word) - 1) +#define RQB_FFS(word) (__ffsl(word) - 1) /* * Type of run queue status word. */ typedef u_int64_t rqb_word_t; -static __inline u_long -ffs64(u_long mask) +static __inline u_int64_t +__popcnt(u_int64_t bits) { - u_long bit; + u_int64_t result; - if (mask == 0) + __asm __volatile("popcnt %0=%1" : "=r" (result) : "r" (bits)); + return result; +} + + +static __inline int +__ffsl(u_long mask) +{ + + if (__predict_false(mask == 0ul)) return (0); - for (bit = 1; (mask & 1UL) == 0; bit++) - mask >>= 1UL; - return (bit); + return (popcnt(mask ^ (mask - 1))); } #endif |