aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/tests/stdbit/stdc_bit_floor_test.c
blob: a2c5b5f7d8ce17ea1771b2876bf7b94b8be7f20d (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
24
25
/*
 * Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#define FUNCSTEM stdc_bit_floor
#define MKREFFUNC(name, type)						\
	static type 							\
	name(type value) 						\
	{ 								\
		type floor = 1;						\
									\
		if (value == 0)						\
			return (0);					\
									\
		while (value != 1) {					\
			floor <<= 1;					\
			value >>= 1;					\
		}							\
									\
		return (floor);						\
	}

#include "stdbit-test-framework.c"