Mercurial > dovecot > core-2.2
view src/lib/bits.h @ 19604:c996bc091c6b
master: Do not close stdout if going foreground
This lets one to use /dev/stdout for logging. Mainly
useful for testing purposes where we can generate
log output to stdout and use tee to write it to a
file for later examination.
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Mon, 18 Jan 2016 15:50:23 +0200 |
parents | 5d58bdcafc7d |
children | 2cf6728ef766 |
line wrap: on
line source
#ifndef BITS_H #define BITS_H #define UINT64_SUM_OVERFLOWS(a, b) \ (a > (uint64_t)-1 - b) #define BIT(n) (1u << (n)) size_t nearest_power(size_t num) ATTR_CONST; unsigned int bits_required8(uint8_t num) ATTR_CONST; static inline unsigned int bits_required16(uint16_t num) { return (num <= 0xff) ? bits_required8(num) : 8 + bits_required8(num >> 8); } static inline unsigned int bits_required32(uint32_t num) { return (num <= 0xffff) ? bits_required16(num) : 16 + bits_required16(num >> 16); } static inline unsigned int bits_required64(uint64_t num) { return (num <= 0xffffffff) ? bits_required32(num) : 32 + bits_required32(num >> 32); } #endif