[libc-commits] [libc] [libc][stdbit] implement stdc_trailing_ones (C23) (PR #80459)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Fri Feb 2 14:29:32 PST 2024
================
@@ -55,6 +85,20 @@ inline unsigned stdc_leading_ones(unsigned long long x) {
unsigned: stdc_leading_ones_ui, \
unsigned long: stdc_leading_ones_ul, \
unsigned long long: stdc_leading_ones_ull)(x)
+#define stdc_trailing_zeros(x) \
+ _Generic((x), \
----------------
nickdesaulniers wrote:
> Hey! Thanks for doing this.
Heh, thanks for standardizing these. I was going to show you/ask for review at some point, I appreciate that you found this, took a look, and had feedback. Do you have cycles at the moment to be cc'ed on more of these as I implement them? If not, no worries.
This is the first I've heard of `_BitInt`, is that something new-ish?
> 6.2.5 Types
> A bit-precise signed integer type is designated as _BitInt(N) where N is an integer constant expression
that specifies the number of bits that are used to represent the type, including the sign bit. Each
value of N designates a distinct type.42)
Yeah, woah gcc-14 and clang-14 both support this type...https://godbolt.org/z/or83fMcro
Ok, I will add support for these. Will file an TODO and revisit; the initial implementations don't need to be perfect to land.
https://github.com/llvm/llvm-project/pull/80459
More information about the libc-commits
mailing list