]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Map highbit64() to fls64()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 30 Sep 2014 22:07:07 +0000 (18:07 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 17 Oct 2014 22:11:50 +0000 (15:11 -0700)
The fls64() function has been available since Linux 2.6.16 and
it should be used to implemented highbit64().  This allows us
to provide an optimized implementation and simplify the code.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
config/spl-build.m4
include/linux/bitops_compat.h
include/sys/sysmacros.h
module/spl/spl-generic.c
module/spl/spl-kmem.c

index 08609b80af1c6b2b0d71632065822aa04a8b7f77..fbe88083683ec22d77297897af66f068815884d5 100644 (file)
@@ -30,7 +30,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_CTL_NAME
        SPL_AC_VMALLOC_INFO
        SPL_AC_PDE_DATA
-       SPL_AC_FLS64
        SPL_AC_SET_NORMALIZED_TIMESPEC_EXPORT
        SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE
        SPL_AC_TIMESPEC_SUB
@@ -993,24 +992,6 @@ AC_DEFUN([SPL_AC_CTL_NAME], [
        ])
 ])
 
-dnl #
-dnl # 2.6.16 API change.
-dnl # Check if 'fls64()' is available
-dnl #
-AC_DEFUN([SPL_AC_FLS64],
-       [AC_MSG_CHECKING([whether fls64() is available])
-       SPL_LINUX_TRY_COMPILE([
-               #include <linux/bitops.h>
-       ],[
-               return fls64(0);
-       ],[
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_FLS64, 1, [fls64() is available])
-       ],[
-               AC_MSG_RESULT(no)
-       ])
-])
-
 dnl #
 dnl # 2.6.26 API change, set_normalized_timespec() is exported.
 dnl #
index 9c55844adba7e11513dc7542b88727ff4060c612..0a3ac16f49d4a8d7864510a28460809a63547f75 100644 (file)
 
 #include <linux/bitops.h>
 
-#ifndef HAVE_FLS64
-
-static inline int fls64(__u64 x)
-{
-       __u32 h = x >> 32;
-       if (h)
-               return fls(h) + 32;
-       return fls(x);
-}
-
-#endif /* HAVE_FLS64 */
-
 #endif /* _SPL_BITOPS_COMPAT_H */
 
index 33e92b6d840ec725a85bbdd854a1fe663973eb8e..c56d7e12a6203051abf79213ac88e49d14f55cac 100644 (file)
@@ -152,13 +152,12 @@ extern char spl_version[32];
 extern unsigned long spl_hostid;
 
 /* Missing misc functions */
-extern int highbit(unsigned long i);
-extern int highbit64(uint64_t i);
 extern uint32_t zone_get_hostid(void *zone);
 extern void spl_setup(void);
 extern void spl_cleanup(void);
 
-#define makedevice(maj,min) makedev(maj,min)
+#define        highbit64(x)            fls64(x)
+#define        makedevice(maj,min)     makedev(maj,min)
 
 /* common macros */
 #ifndef MIN
index 3e8f874de744ac95133eb7234ce569c3c4a9d809..1059fb3ccb0e382495ddfe1debcbe780280cb814 100644 (file)
@@ -64,68 +64,6 @@ DECLARE_WAIT_QUEUE_HEAD(spl_kallsyms_lookup_name_waitq);
 kallsyms_lookup_name_t spl_kallsyms_lookup_name_fn = SYMBOL_POISON;
 #endif
 
-int
-highbit(unsigned long i)
-{
-        register int h = 1;
-        SENTRY;
-
-        if (i == 0)
-                SRETURN(0);
-#if BITS_PER_LONG == 64
-        if (i & 0xffffffff00000000ul) {
-                h += 32; i >>= 32;
-        }
-#endif
-        if (i & 0xffff0000) {
-                h += 16; i >>= 16;
-        }
-        if (i & 0xff00) {
-                h += 8; i >>= 8;
-        }
-        if (i & 0xf0) {
-                h += 4; i >>= 4;
-        }
-        if (i & 0xc) {
-                h += 2; i >>= 2;
-        }
-        if (i & 0x2) {
-                h += 1;
-        }
-        SRETURN(h);
-}
-EXPORT_SYMBOL(highbit);
-
-int
-highbit64(uint64_t i)
-{
-        register int h = 1;
-        SENTRY;
-
-        if (i == 0)
-                SRETURN(0);
-        if (i & 0xffffffff00000000ull) {
-                h += 32; i >>= 32;
-        }
-        if (i & 0xffff0000) {
-                h += 16; i >>= 16;
-        }
-        if (i & 0xff00) {
-                h += 8; i >>= 8;
-        }
-        if (i & 0xf0) {
-                h += 4; i >>= 4;
-        }
-        if (i & 0xc) {
-                h += 2; i >>= 2;
-        }
-        if (i & 0x2) {
-                h += 1;
-        }
-        SRETURN(h);
-}
-EXPORT_SYMBOL(highbit64);
-
 #if BITS_PER_LONG == 32
 /*
  * Support 64/64 => 64 division on a 32-bit platform.  While the kernel
index 55b2656960c8670e0b0baf7c8b7356e62f462a33..8b52dfedecf4f9791681889fc4c810e91b6ef78e 100644 (file)
@@ -977,7 +977,7 @@ spl_sko_from_obj(spl_kmem_cache_t *skc, void *obj)
 static inline uint32_t
 spl_offslab_size(spl_kmem_cache_t *skc)
 {
-       return 1UL << (highbit(spl_obj_size(skc)) + 1);
+       return 1UL << (fls64(spl_obj_size(skc)) + 1);
 }
 
 /*