Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/lib/libc/tests/stdbit/stdc_leading_zeros_test.c
96309 views
1
/*
2
* Copyright (c) 2025 Robert Clausecker <[email protected]>
3
*
4
* SPDX-License-Identifier: BSD-2-Clause
5
*/
6
7
#define FUNCSTEM stdc_leading_zeros
8
#define MKREFFUNC(name, type) \
9
static unsigned \
10
name(type value) \
11
{ \
12
type bit = 1; \
13
unsigned count = 0; \
14
\
15
while ((type)(bit << 1) != 0) \
16
bit <<= 1; \
17
\
18
while (bit != 0 && (bit & value) == 0) { \
19
bit >>= 1; \
20
count++; \
21
} \
22
\
23
return (count); \
24
}
25
26
#include "stdbit-test-framework.c"
27
28