Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/lib/libc/tests/stdbit/stdc_count_ones_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_count_ones
8
#define MKREFFUNC(name, type) \
9
static unsigned \
10
name(type value) \
11
{ \
12
unsigned count = 0; \
13
\
14
while (value != 0) { \
15
count += value & 1; \
16
value >>= 1; \
17
} \
18
\
19
return (count); \
20
}
21
22
#include "stdbit-test-framework.c"
23
24