Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/bitops.h

    rd354d57 r137691a  
    2727 */
    2828
    29 /** @addtogroup generic
     29/** @addtogroup generic 
    3030 * @{
    3131 */
     
    3636#define KERN_BITOPS_H_
    3737
    38 #ifdef __32_BITS__
    39         #define fnzb(arg)  fnzb32(arg)
    40 #endif
    4138
    42 #ifdef __64_BITS__
    43         #define fnzb(arg)  fnzb64(arg)
    44 #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 */
     43static inline int fnzb32(uint32_t arg)
     44{
     45        int n = 0;
    4546
    46 /** Return position of first non-zero bit from left (32b variant).
    47  *
    48  * @return 0 (if the number is zero) or [log_2(arg)].
    49  *
    50  */
    51 static inline uint8_t fnzb32(uint32_t arg)
    52 {
    53         uint8_t n = 0;
    54        
    5547        if (arg >> 16) {
    5648                arg >>= 16;
     
    7971}
    8072
    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)
     73static inline int fnzb64(uint64_t arg)
    8774{
    88         uint8_t n = 0;
    89        
     75        int n = 0;
     76
    9077        if (arg >> 32) {
    9178                arg >>= 32;
     
    9683}
    9784
     85#define fnzb(x) fnzb32(x)
     86
    9887#endif
    9988
Note: See TracChangeset for help on using the changeset viewer.