diff options
| author | Paul Eggert | 2024-05-12 14:22:58 -0700 |
|---|---|---|
| committer | Paul Eggert | 2024-05-18 10:23:51 -0700 |
| commit | 88b0bb4db9aaecff8b01e81726b911fa5d02b2fb (patch) | |
| tree | 8ac3e75bba0a9082a94e7c3a03cd8b590f07a97d /src/lisp.h | |
| parent | 08550d058f028e0819ba6a72e9a53c0bc789257e (diff) | |
| download | emacs-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 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lisp.h b/src/lisp.h index 8ee37f5298a..d61a4d5c982 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -23,6 +23,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 23 | #include <alloca.h> | 23 | #include <alloca.h> |
| 24 | #include <setjmp.h> | 24 | #include <setjmp.h> |
| 25 | #include <stdarg.h> | 25 | #include <stdarg.h> |
| 26 | #include <stdbit.h> | ||
| 26 | #include <stdckdint.h> | 27 | #include <stdckdint.h> |
| 27 | #include <stddef.h> | 28 | #include <stddef.h> |
| 28 | #include <string.h> | 29 | #include <string.h> |
| @@ -37,7 +38,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 37 | 38 | ||
| 38 | #include <attribute.h> | 39 | #include <attribute.h> |
| 39 | #include <byteswap.h> | 40 | #include <byteswap.h> |
| 40 | #include <count-leading-zeros.h> | ||
| 41 | #include <intprops.h> | 41 | #include <intprops.h> |
| 42 | #include <verify.h> | 42 | #include <verify.h> |
| 43 | 43 | ||
| @@ -4148,11 +4148,12 @@ integer_to_uintmax (Lisp_Object num, uintmax_t *n) | |||
| 4148 | } | 4148 | } |
| 4149 | } | 4149 | } |
| 4150 | 4150 | ||
| 4151 | /* Return floor (log2 (N)) as an int, where 0 < N <= ULLONG_MAX. */ | 4151 | /* Return floor (log2 (N)) as an int. If N is zero, return -1. */ |
| 4152 | INLINE int | 4152 | INLINE int |
| 4153 | elogb (unsigned long long int n) | 4153 | elogb (unsigned long long int n) |
| 4154 | { | 4154 | { |
| 4155 | return ULLONG_WIDTH - 1 - count_leading_zeros_ll (n); | 4155 | int width = stdc_bit_width (n); |
| 4156 | return width - 1; | ||
| 4156 | } | 4157 | } |
| 4157 | 4158 | ||
| 4158 | /* A modification count. These are wide enough, and incremented | 4159 | /* A modification count. These are wide enough, and incremented |