summaryrefslogtreecommitdiff
path: root/lib/libc/tests/stdbit/stdc_bit_width_test.c
blob: bfcb2b3bd779e521be7ca6e65c9bf48e312bec98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * 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"