Lines Matching defs:num
9 /* Returns x, such that x is the smallest power of 2 >= num. */
10 size_t nearest_power(size_t num) ATTR_CONST;
12 /* Returns TRUE if 2^x=num, i.e. if num has only a single bit set to 1. */
14 bits_is_power_of_two(uint64_t num)
16 return num > 0 && (num & (num - 1)) == 0;
21 bits_required32(uint32_t num)
23 return num == 0 ? 0 : 32 - __builtin_clz(num);
26 bits_required8(uint8_t num) { return bits_required32(num); }
29 bits_required16(uint16_t num) { return bits_required32(num); }
32 bits_required64(uint64_t num)
34 return num == 0 ? 0 : 64 - __builtin_clzll(num);
37 unsigned int bits_required8(uint8_t num) ATTR_CONST;
40 unsigned int bits_required16(uint16_t num)
42 return (num <= 0xff) ? bits_required8(num)
43 : 8 + bits_required8(num >> 8);
46 unsigned int bits_required32(uint32_t num)
48 return (num <= 0xffff) ? bits_required16(num)
49 : 16 + bits_required16(num >> 16);
52 unsigned int bits_required64(uint64_t num)
54 return (num <= 0xffffffff) ? bits_required32(num)
55 : 32 + bits_required32(num >> 32);
60 bits_rotl64(uint64_t num, unsigned int count)
62 const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
64 return (num << count) | (num >> (-count & mask));
68 bits_rotl32(uint32_t num, unsigned int count)
70 const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
72 return (num << count) | (num >> (-count & mask));
76 bits_rotr64(uint64_t num, unsigned int count)
78 const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
80 return (num >> count) | (num << (-count & mask));
84 bits_rotr32(uint32_t num, unsigned int count)
86 const unsigned int mask = CHAR_BIT*sizeof(num) - 1;
88 return (num >> count) | (num << (-count & mask));