summaryrefslogtreecommitdiffstats
path: root/sys/ofed
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2015-10-21 09:37:34 +0000
committerhselasky <hselasky@FreeBSD.org>2015-10-21 09:37:34 +0000
commit06414daf3ab570715436bec75eeddfde37248b3f (patch)
tree2ead5fe1a3e862748a5331381204cc197197bc95 /sys/ofed
parent093c8bb5836c48e48310a7e9464f8ffcc5adb854 (diff)
downloadFreeBSD-src-06414daf3ab570715436bec75eeddfde37248b3f.zip
FreeBSD-src-06414daf3ab570715436bec75eeddfde37248b3f.tar.gz
Remove all comments deriving from Linux.
Minor rework of ilog2() function. Suggested by: emaste @ Sponsored by: Mellanox Technologies
Diffstat (limited to 'sys/ofed')
-rw-r--r--sys/ofed/include/linux/log2.h54
1 files changed, 6 insertions, 48 deletions
diff --git a/sys/ofed/include/linux/log2.h b/sys/ofed/include/linux/log2.h
index 2801d5c..a44c560 100644
--- a/sys/ofed/include/linux/log2.h
+++ b/sys/ofed/include/linux/log2.h
@@ -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))
OpenPOWER on IntegriCloud