diff options
author | mav <mav@FreeBSD.org> | 2015-10-02 20:13:56 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-10-02 20:13:56 +0000 |
commit | 8d38b6620685ca901cf6e6b43c9204604a45f03a (patch) | |
tree | c81bec83b52783bbdb184393c99629a3b0d9dd61 | |
parent | 507088a8fab790bee8f93abfb5379a7fb2b670af (diff) | |
download | FreeBSD-src-8d38b6620685ca901cf6e6b43c9204604a45f03a.zip FreeBSD-src-8d38b6620685ca901cf6e6b43c9204604a45f03a.tar.gz |
MFC r284591 (by avg): illums compat: use flsl/flsll for highbit/highbit64
Do that only when when fast inline versions are available.
At the moment that can be the case only in the kernel and not for all
platforms.
The original code uses the binary search and that's kept as a fallback.
This is a micro optimization.
-rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h index 0d98b26..0d5a35a 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h +++ b/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h @@ -32,6 +32,9 @@ #include <sys/param.h> #include <sys/isa_defs.h> +#if defined(__FreeBSD__) && defined(_KERNEL) +#include <sys/libkern.h> +#endif #ifdef __cplusplus extern "C" { @@ -382,6 +385,9 @@ extern unsigned char bcd_to_byte[256]; static __inline int highbit(ulong_t i) { +#if defined(__FreeBSD__) && defined(_KERNEL) && defined(HAVE_INLINE_FLSL) + return (flsl(i)); +#else register int h = 1; if (i == 0) @@ -407,6 +413,7 @@ highbit(ulong_t i) h += 1; } return (h); +#endif } /* @@ -416,6 +423,9 @@ highbit(ulong_t i) static __inline int highbit64(uint64_t i) { +#if defined(__FreeBSD__) && defined(_KERNEL) && defined(HAVE_INLINE_FLSLL) + return (flsll(i)); +#else int h = 1; if (i == 0) @@ -439,6 +449,7 @@ highbit64(uint64_t i) h += 1; } return (h); +#endif } #ifdef __cplusplus |