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