Changeset d354d57 in mainline


Ignore:
Timestamp:
2010-05-22T22:24:15Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d92bf462
Parents:
b8230b9
Message:

use fnzb32 or fnzb64 according to the platform

File:
1 edited

Legend:

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

    rb8230b9 rd354d57  
    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
    3841
    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).
    4047 *
    41  * If number is zero, it returns 0
     48 * @return 0 (if the number is zero) or [log_2(arg)].
     49 *
    4250 */
    43 static inline int fnzb32(uint32_t arg)
     51static inline uint8_t fnzb32(uint32_t arg)
    4452{
    45         int n = 0;
    46 
     53        uint8_t n = 0;
     54       
    4755        if (arg >> 16) {
    4856                arg >>= 16;
     
    7179}
    7280
    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 */
     86static inline uint8_t fnzb64(uint64_t arg)
    7487{
    75         int n = 0;
    76 
     88        uint8_t n = 0;
     89       
    7790        if (arg >> 32) {
    7891                arg >>= 32;
     
    8396}
    8497
    85 #define fnzb(x) fnzb32(x)
    86 
    8798#endif
    8899
Note: See TracChangeset for help on using the changeset viewer.