1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
/* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only */
/* Copyright (c) 2020-2022 Brett Sheffield <bacs@librecast.net> */
#include <stdarg.h>
#include <stdio.h>
#include "misc.h"
/* Public Domain, credit to Sean Anderson from
* https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 */
uint32_t next_pow2(uint32_t v)
{
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
return ++v;
}
int _vscprintf (const char * format, va_list argp)
{
int r;
va_list argc;
va_copy(argc, argp);
r = vsnprintf(NULL, 0, format, argc);
va_end(argc);
return r;
}
|