diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2015-10-21 09:37:34 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2015-10-21 09:37:34 +0000 |
commit | 03ae38081c1405667d5979a1cd20fd5204d589b7 (patch) | |
tree | 2ead5fe1a3e862748a5331381204cc197197bc95 /sys/ofed | |
parent | 6f2fc610dda2d7ef54312cb67d6c7410b8bbe684 (diff) | |
download | src-03ae38081c1405667d5979a1cd20fd5204d589b7.tar.gz src-03ae38081c1405667d5979a1cd20fd5204d589b7.zip |
Remove all comments deriving from Linux.
Minor rework of ilog2() function.
Suggested by: emaste @
Sponsored by: Mellanox Technologies
Notes
Notes:
svn path=/head/; revision=289683
Diffstat (limited to 'sys/ofed')
-rw-r--r-- | sys/ofed/include/linux/log2.h | 54 |
1 files changed, 6 insertions, 48 deletions
diff --git a/sys/ofed/include/linux/log2.h b/sys/ofed/include/linux/log2.h index 2801d5c649f8..a44c560f043b 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)) |