]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/bitops.h
2 * BIRD Library -- Generic Bit Operations
4 * (c) 1998 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
9 #ifndef _BIRD_BITOPTS_H_
10 #define _BIRD_BITOPTS_H_
13 * Bit mask operations:
15 * u32_mkmask Make bit mask consisting of <n> consecutive ones
16 * from the left and the rest filled with zeroes.
17 * E.g., u32_mkmask(5) = 0xf8000000.
18 * u32_masklen Inverse operation to u32_mkmask, -1 if not a bitmask.
21 u32
u32_mkmask(unsigned n
);
22 int u32_masklen(u32 x
);
26 static inline u32
u32_hash(u32 v
) { return v
* 2902958171u; }