summaryrefslogtreecommitdiff
path: root/lib/stdc_leading_zeros.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2024-05-12 14:22:58 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2024-05-18 10:23:51 -0700
commit88b0bb4db9aaecff8b01e81726b911fa5d02b2fb (patch)
tree8ac3e75bba0a9082a94e7c3a03cd8b590f07a97d /lib/stdc_leading_zeros.c
parent08550d058f028e0819ba6a72e9a53c0bc789257e (diff)
downloademacs-88b0bb4db9aaecff8b01e81726b911fa5d02b2fb.tar.gz
emacs-88b0bb4db9aaecff8b01e81726b911fa5d02b2fb.tar.bz2
emacs-88b0bb4db9aaecff8b01e81726b911fa5d02b2fb.zip
Prefer stdbit.h to count-one-bits.h etc
C23's <stdbit.h> in the long run should be better supported than Gnulib's count-one-bits.h and similar headers, so switch to the C23 primitives, with a Gnulib fallback for platforms lacking C23. * admin/merge-gnulib (GNULIB_MODULES): Remove count-leading-zeros, count-one-bits, count-trailing-zeros. Add stdc_bit_width, stdc_count_ones, stdc_trailing_zeros. * lib/count-leading-zeros.c, lib/count-leading-zeros.h: * lib/count-one-bits.c, lib/count-one-bits.h: * lib/count-trailing-zeros.c, lib/count-trailing-zeros.h: Remove. * lib/stdbit.c, lib/stdbit.in.h, lib/stdc_bit_width.c: * lib/stdc_count_ones.c, lib/stdc_leading_zeros.c: * lib/stdc_trailing_zeros.c, m4/stdbit_h.m4: New files, copied from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * src/data.c: Do not include count-one-bits.h, count-trailing-zeros.h. Instead, rely on lisp.h including stdbit.h. (Flogcount, Fbool_vector_count_population) (Fbool_vector_count_consecutive): Use stdbit.h macros instead of count-one-bits.h and count-trailing-zeros.h macros. (shift_right_ull, count_one_bits_word, pre_value) (count_trailing_zero_bits): Remove; no longer needed. * src/lisp.h: Include stdbit.h instead of count-leading-zeros.h. (elogb): Use stdbit.h macro instead of count-leading-zeros.h macro.
Diffstat (limited to 'lib/stdc_leading_zeros.c')
-rw-r--r--lib/stdc_leading_zeros.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/stdc_leading_zeros.c b/lib/stdc_leading_zeros.c
new file mode 100644
index 00000000000..45695e51aa8
--- /dev/null
+++ b/lib/stdc_leading_zeros.c
@@ -0,0 +1,20 @@
+/* stdc_leading_zeros_* functions.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#define _GL_STDC_LEADING_ZEROS_INLINE _GL_EXTERN_INLINE
+#include <stdbit.h>