mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
This new header complies with ISO/IEC 9899:2024 (C23). Contrary to glibc, we do not provide inline definitions in <stdbit.h> as we expect our system compiler to soon recognise these as builtins anyway. Relnotes: yes MFC after: 1 month Reviewed by: adrian Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D53657
39 lines
626 B
C
39 lines
626 B
C
/*
|
|
* Copyright (c) 2025 Robert Clausecker <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <limits.h>
|
|
#include <stdbit.h>
|
|
|
|
unsigned int
|
|
stdc_count_zeros_uc(unsigned char x)
|
|
{
|
|
return (__builtin_popcount(x ^ UCHAR_MAX));
|
|
}
|
|
|
|
unsigned int
|
|
stdc_count_zeros_us(unsigned short x)
|
|
{
|
|
return (__builtin_popcount(x ^ USHRT_MAX));
|
|
}
|
|
|
|
unsigned int
|
|
stdc_count_zeros_ui(unsigned int x)
|
|
{
|
|
return (__builtin_popcount(~x));
|
|
}
|
|
|
|
unsigned int
|
|
stdc_count_zeros_ul(unsigned long x)
|
|
{
|
|
return (__builtin_popcountl(~x));
|
|
}
|
|
|
|
unsigned int
|
|
stdc_count_zeros_ull(unsigned long long x)
|
|
{
|
|
return (__builtin_popcountll(~x));
|
|
}
|