Mercurial > dovecot > core-2.2
annotate src/lib/bits.c @ 22664:fea53c2725c0
director: Fix director_max_parallel_moves/kicks type
Should be uint, not time.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 09 Nov 2017 12:24:16 +0200 |
parents | 7f042673da58 |
children | cb108f786fb4 |
rev | line source |
---|---|
21390
2e2563132d5f
Updated copyright notices to include the year 2017.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
19552
diff
changeset
|
1 /* Copyright (c) 2001-2017 Dovecot authors, see the included COPYING file */ |
17447 | 2 |
3 #include "lib.h" | |
4 | |
5 size_t nearest_power(size_t num) | |
6 { | |
7 size_t n = 1; | |
8 | |
9 i_assert(num <= ((size_t)1 << (CHAR_BIT*sizeof(size_t) - 1))); | |
10 | |
11 while (n < num) n <<= 1; | |
12 return n; | |
13 } | |
14 | |
22393
7f042673da58
lib/bits.c: Finish fix for compiling with gcc 3.0 .. 3.3
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
21994
diff
changeset
|
15 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) |
21994
e8d7996b1fa7
lib: bits - GCC (and clang) provide bit-twiddle intrinsics, use them
Phil Carmody <phil@dovecot.fi>
parents:
21390
diff
changeset
|
16 /* Lucky you, it's all inline intrinsics */ |
e8d7996b1fa7
lib: bits - GCC (and clang) provide bit-twiddle intrinsics, use them
Phil Carmody <phil@dovecot.fi>
parents:
21390
diff
changeset
|
17 #else |
17447 | 18 unsigned int bits_required8(uint8_t num) |
19 { | |
20 int ret = 0; | |
21 if (num > 0xf) { ret += 4; num >>= 4; } | |
22 if (num > 0x3) { ret += 2; num >>= 2; } | |
23 num &= ~(num>>1); /* 3->2, else unchanged */ | |
24 return ret + num; | |
25 } | |
21994
e8d7996b1fa7
lib: bits - GCC (and clang) provide bit-twiddle intrinsics, use them
Phil Carmody <phil@dovecot.fi>
parents:
21390
diff
changeset
|
26 #endif |