Mercurial > dovecot > core-2.2
view src/lib/bits.c @ 22656:1789bf2a1e01
director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0
The reset command would just hang in that case. doveadm would never have
sent this, so this is just an extra sanity check.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sun, 05 Nov 2017 23:51:56 +0200 |
parents | 7f042673da58 |
children | cb108f786fb4 |
line wrap: on
line source
/* Copyright (c) 2001-2017 Dovecot authors, see the included COPYING file */ #include "lib.h" size_t nearest_power(size_t num) { size_t n = 1; i_assert(num <= ((size_t)1 << (CHAR_BIT*sizeof(size_t) - 1))); while (n < num) n <<= 1; return n; } #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) /* Lucky you, it's all inline intrinsics */ #else unsigned int bits_required8(uint8_t num) { int ret = 0; if (num > 0xf) { ret += 4; num >>= 4; } if (num > 0x3) { ret += 2; num >>= 2; } num &= ~(num>>1); /* 3->2, else unchanged */ return ret + num; } #endif