예제 #1
0
파일: test-util.c 프로젝트: David-B55/ovs
static void
check_log_2_floor(uint32_t x, int n)
{
    if (log_2_floor(x) != n) {
        fprintf(stderr, "log_2_floor(%"PRIu32") is %d but should be %d\n",
                x, log_2_floor(x), n);
        abort();
    }
}
/* Given a 32 bit word 'n', calculates ceil(log_2('n')).  It is an error to
 * call this function with 'n' == 0. */
int
log_2_ceil(uint32_t n)
{
    return log_2_floor(n) + !IS_POW2(n);
}