opnsense-src/lib/libc/tests/stdbit/stdc_bit_width_test.c
Robert Clausecker c9ec3fc0d5 libc/tests: add stdbit test framework and unit tests
This adds unit tests for all 70 functions in <stdbit.h>.

I'm sorry for the test framework, but it makes it so I don't
have to write 70 unit tests by hand.

Reviewed by:	adrian, des
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D53660

(cherry picked from commit 2fb8cbc6ef1b3cc6cd60e5db07f8305623f9b044)
2026-01-01 21:57:32 +01:00

22 lines
438 B
C

/*
* Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#define FUNCSTEM stdc_bit_width
#define MKREFFUNC(name, type) \
static unsigned \
name(type value) \
{ \
unsigned width = 0; \
\
while (value != 0) { \
value >>= 1; \
width++; \
} \
\
return (width); \
}
#include "stdbit-test-framework.c"