aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdbit.c
diff options
context:
space:
mode:
authorPaul Eggert2024-05-12 14:22:58 -0700
committerPaul Eggert2024-05-18 10:23:51 -0700
commit88b0bb4db9aaecff8b01e81726b911fa5d02b2fb (patch)
tree8ac3e75bba0a9082a94e7c3a03cd8b590f07a97d /lib/stdbit.c
parent08550d058f028e0819ba6a72e9a53c0bc789257e (diff)
downloademacs-88b0bb4db9aaecff8b01e81726b911fa5d02b2fb.tar.gz
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/stdbit.c')
-rw-r--r--lib/stdbit.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/stdbit.c b/lib/stdbit.c
new file mode 100644
index 00000000000..4801e74d281
--- /dev/null
+++ b/lib/stdbit.c
@@ -0,0 +1,23 @@
1/* Support C23 bit and byte utilities on non-C23 platforms.
2
3 Copyright 2024 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20#include <config.h>
21
22#define _GL_STDBIT_INLINE _GL_EXTERN_INLINE
23#include <stdbit.h>