diff options
| author | Doug Moore <dougm@FreeBSD.org> | 2024-06-24 07:00:31 +0000 |
|---|---|---|
| committer | Doug Moore <dougm@FreeBSD.org> | 2024-06-24 07:00:31 +0000 |
| commit | c8b0c33b03ac072413b27bed2bdae2ae27426f3a (patch) | |
| tree | a5c5e6a0cda077a252cb1a13d3609ae6df93ad4a /sys/compat/linuxkpi/common/include/linux | |
| parent | a94ed493b50752cee09245fc312c63b00331f217 (diff) | |
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux')
| -rw-r--r-- | sys/compat/linuxkpi/common/include/linux/log2.h | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/log2.h b/sys/compat/linuxkpi/common/include/linux/log2.h index 2d54c75c7c23..660e9adb6fa9 100644 --- a/sys/compat/linuxkpi/common/include/linux/log2.h +++ b/sys/compat/linuxkpi/common/include/linux/log2.h @@ -33,24 +33,9 @@ #include <sys/libkern.h> -static inline unsigned long -roundup_pow_of_two(unsigned long x) -{ - return (1UL << flsl(x - 1)); -} - -static inline int -is_power_of_2(unsigned long n) -{ - return (n == roundup_pow_of_two(n)); -} - -static inline unsigned long -rounddown_pow_of_two(unsigned long x) -{ - return (1UL << (flsl(x) - 1)); -} - -#define order_base_2(x) ilog2(roundup_pow_of_two(x)) +#define is_power_of_2(n) ({ \ + __typeof(n) _n = (n); \ + _n != 0 && (_n & (_n - 1)) == 0; \ +}) #endif /* _LINUXKPI_LINUX_LOG2_H_ */ |
