xref: /freebsd/lib/libc/tests/stdbit/stdc_count_zeros_test.c (revision 2fb8cbc6ef1b3cc6cd60e5db07f8305623f9b044)
1 /*
2  * Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  */
6 
7 #define FUNCSTEM stdc_count_zeros
8 #define MKREFFUNC(name, type)						\
9 	static unsigned							\
10 	name(type value) 						\
11 	{ 								\
12 		unsigned count = 0;					\
13 									\
14 		value = ~value;						\
15 		while (value != 0) {					\
16 			count += value & 1;				\
17 			value >>= 1;					\
18 		}							\
19 									\
20 		return (count);						\
21 	}
22 
23 #include "stdbit-test-framework.c"
24