aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/tests/stdbit/stdc_count_zeros_test.c
blob: a82de6696a64b084bc91c88b2e74f3ce30529727 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#define FUNCSTEM stdc_count_zeros
#define MKREFFUNC(name, type)						\
	static unsigned							\
	name(type value) 						\
	{ 								\
		unsigned count = 0;					\
									\
		value = ~value;						\
		while (value != 0) {					\
			count += value & 1;				\
			value >>= 1;					\
		}							\
									\
		return (count);						\
	}

#include "stdbit-test-framework.c"