blob: e9c6781e8e93d01df71b18e45b62dae503236301 [file] [log] [blame]
#ifndef _NTZ_H
#define _NTZ_H
/* Number of Tail Zeros: ntz(x)= (ffs(x) ? ffs(x)-1 : 16)
It works with all: cpp, gcc and gas expressions. */
#define ntz(x) \
( (1 & (((x) & 1) == 0)) \
+ (1 & (((x) & 3) == 0)) \
+ (1 & (((x) & 7) == 0)) \
+ (1 & (((x) & 017) == 0)) \
+ (1 & (((x) & 037) == 0)) \
+ (1 & (((x) & 077) == 0)) \
+ (1 & (((x) & 0177) == 0)) \
+ (1 & (((x) & 0377) == 0)) \
+ (1 & (((x) & 0777) == 0)) \
+ (1 & (((x) & 01777) == 0)) \
+ (1 & (((x) & 03777) == 0)) \
+ (1 & (((x) & 07777) == 0)) \
+ (1 & (((x) & 017777) == 0)) \
+ (1 & (((x) & 037777) == 0)) \
+ (1 & (((x) & 077777) == 0)) \
+ (1 & (((x) & 0177777) == 0)) )
#endif /* !_NTZ_H */