]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Remove all comments deriving from Linux.
authorhselasky <hselasky@FreeBSD.org>
Wed, 21 Oct 2015 09:37:34 +0000 (09:37 +0000)
committerhselasky <hselasky@FreeBSD.org>
Wed, 21 Oct 2015 09:37:34 +0000 (09:37 +0000)
Minor rework of ilog2() function.

Suggested by: emaste @
Sponsored by: Mellanox Technologies

sys/ofed/include/linux/log2.h

index 2801d5c649f82076f6bb607427f6acbb9727c0eb..a44c560f043ba1f4506dcceb9837bb32099bb1e0 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2010 Isilon Systems, Inc.
  * Copyright (c) 2010 iX Systems, Inc.
  * Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2015 Mellanox Technologies, Ltd.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -53,50 +53,10 @@ rounddown_pow_of_two(unsigned long x)
         return (1UL << (flsl(x) - 1));
 }
 
-
-/*
- * deal with unrepresentable constant logarithms
- */
-extern __attribute__((const, noreturn))
-int ____ilog2_NaN(void);
-
-/*
- * non-constant log of base 2 calculators
- * - the arch may override these in asm/bitops.h if they can be implemented
- *   more efficiently than using fls() and fls64()
- * - the arch is not required to handle n==0 if implementing the fallback
- */
-#ifndef CONFIG_ARCH_HAS_ILOG2_U32
-static inline __attribute__((const))
-int __ilog2_u32(u32 n)
-{
-       return flsl(n) - 1;
-}
-#endif
-
-#ifndef CONFIG_ARCH_HAS_ILOG2_U64
-static inline __attribute__((const))
-int __ilog2_u64(u64 n)
-{
-       return flsl(n) - 1;
-}
-#endif
-
-
-/**
- * ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
- * @n - parameter
- *
- * constant-capable log of base 2 calculation
- * - this can be used to initialise global variables from constant data, hence
- *   the massive ternary operator construction
- *
- * selects the appropriately-sized optimised version depending on sizeof(n)
- */
-#define ilog2(n)                               \
+#define        ilog2(n)                                \
 (                                              \
        __builtin_constant_p(n) ? (             \
-               (n) < 1 ? ____ilog2_NaN() :     \
+               (n) < 1 ? -1 :                  \
                (n) & (1ULL << 63) ? 63 :       \
                (n) & (1ULL << 62) ? 62 :       \
                (n) & (1ULL << 61) ? 61 :       \
@@ -161,12 +121,10 @@ int __ilog2_u64(u64 n)
                (n) & (1ULL <<  2) ?  2 :       \
                (n) & (1ULL <<  1) ?  1 :       \
                (n) & (1ULL <<  0) ?  0 :       \
-               ____ilog2_NaN()                 \
-                                  ) :          \
+               -1) :                           \
        (sizeof(n) <= 4) ?                      \
-       __ilog2_u32(n) :                        \
-       __ilog2_u64(n)                          \
- )
+       fls((u32)(n)) - 1 : flsll((u64)(n)) - 1 \
+)
 
 #define        order_base_2(x) ilog2(roundup_pow_of_two(x))