Changeset 660 for GPL/branches/uniaud32-next/include/linux/log2.h
- Timestamp:
- Jan 25, 2021, 11:33:33 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-next/include/linux/log2.h
r647 r660 14 14 { 15 15 return (n != 0 && ((n & (n - 1)) == 0)); 16 } 17 18 /** 19 * __roundup_pow_of_two() - round up to nearest power of two 20 * @n: value to round up 21 */ 22 static inline /*__attribute__((const))*/ 23 unsigned long __roundup_pow_of_two(unsigned long n) 24 { 25 return 1UL << fls_long(n - 1); 26 } 27 28 /** 29 * __rounddown_pow_of_two() - round down to nearest power of two 30 * @n: value to round down 31 */ 32 static inline /*__attribute__((const))*/ 33 unsigned long __rounddown_pow_of_two(unsigned long n) 34 { 35 return 1UL << (fls_long(n) - 1); 16 36 } 17 37 … … 62 82 } 63 83 84 /** 85 * roundup_pow_of_two - round the given value up to nearest power of two 86 * @n: parameter 87 * 88 * round the given value up to the nearest power of two 89 * - the result is undefined when n == 0 90 * - this can be used to initialise global variables from constant data 91 */ 92 #define roundup_pow_of_two(n) \ 93 ( \ 94 __roundup_pow_of_two(n) \ 95 ) 96 97 /** 98 * rounddown_pow_of_two - round the given value down to nearest power of two 99 * @n: parameter 100 * 101 * round the given value down to the nearest power of two 102 * - the result is undefined when n == 0 103 * - this can be used to initialise global variables from constant data 104 */ 105 #define rounddown_pow_of_two(n) \ 106 ( \ 107 __rounddown_pow_of_two(n) \ 108 ) 109 64 110 #endif /* _LINUX_LOG2_H */
Note:
See TracChangeset
for help on using the changeset viewer.