[libc-commits] [libc] [libc][stdbit] implement stdc_trailing_ones (C23) (PR #80459)

The Phantom Derpstorm via libc-commits libc-commits at lists.llvm.org
Fri Feb 2 09:50:13 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),                                                                \
----------------
ThePhD wrote:

Hey! Thanks for doing this. Please make sure that you include `_BitInt(CHAR_BIT)`/`_BitInt(CHAR_BIT * 2)`/`_BitInt(CHAR_BIT * 4)`/`_BitInt(CHAR_BIT * 8)` versions of this, as that's part of the spec. (You can also just use `8/16/32/64`; I know that LLVM as a thing tends to not care about `CHAR_BIT != 8` platforms.)

https://github.com/llvm/llvm-project/pull/80459


More information about the libc-commits mailing list