Changes in kernel/generic/include/bitops.h [7a0359b:b3f8fb7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/bitops.h
r7a0359b rb3f8fb7 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 36 36 #define KERN_BITOPS_H_ 37 37 38 #include <trace.h>39 38 40 #ifdef __32_BITS__ 41 #define fnzb(arg) fnzb32(arg) 42 #endif 39 /** Return position of first non-zero bit from left (i.e. [log_2(arg)]). 40 * 41 * If number is zero, it returns 0 42 */ 43 static inline int fnzb32(uint32_t arg) 44 { 45 int n = 0; 43 46 44 #ifdef __64_BITS__45 #define fnzb(arg) fnzb64(arg)46 #endif47 48 /** Return position of first non-zero bit from left (32b variant).49 *50 * @return 0 (if the number is zero) or [log_2(arg)].51 *52 */53 NO_TRACE static inline uint8_t fnzb32(uint32_t arg)54 {55 uint8_t n = 0;56 57 47 if (arg >> 16) { 58 48 arg >>= 16; … … 75 65 } 76 66 77 if (arg >> 1) 67 if (arg >> 1) { 68 arg >>= 1; 78 69 n += 1; 70 } 79 71 80 72 return n; 81 73 } 82 74 83 /** Return position of first non-zero bit from left (64b variant). 84 * 85 * @return 0 (if the number is zero) or [log_2(arg)]. 86 * 87 */ 88 NO_TRACE static inline uint8_t fnzb64(uint64_t arg) 75 static inline int fnzb64(uint64_t arg) 89 76 { 90 uint8_t n = 0;91 77 int n = 0; 78 92 79 if (arg >> 32) { 93 80 arg >>= 32; … … 98 85 } 99 86 87 #define fnzb(x) fnzb32(x) 88 100 89 #endif 101 90
Note:
See TracChangeset
for help on using the changeset viewer.