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 /m4 | |
| 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 'm4')
| -rw-r--r-- | m4/gnulib-comp.m4 | 46 | ||||
| -rw-r--r-- | m4/stdbit_h.m4 | 37 |
2 files changed, 74 insertions, 9 deletions
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 61040987b57..4dd1e68d15c 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 | |||
| @@ -63,9 +63,6 @@ AC_DEFUN([gl_EARLY], | |||
| 63 | # Code from module cloexec: | 63 | # Code from module cloexec: |
| 64 | # Code from module close-stream: | 64 | # Code from module close-stream: |
| 65 | # Code from module copy-file-range: | 65 | # Code from module copy-file-range: |
| 66 | # Code from module count-leading-zeros: | ||
| 67 | # Code from module count-one-bits: | ||
| 68 | # Code from module count-trailing-zeros: | ||
| 69 | # Code from module crypto/md5: | 66 | # Code from module crypto/md5: |
| 70 | # Code from module crypto/md5-buffer: | 67 | # Code from module crypto/md5-buffer: |
| 71 | # Code from module crypto/sha1-buffer: | 68 | # Code from module crypto/sha1-buffer: |
| @@ -174,7 +171,12 @@ AC_DEFUN([gl_EARLY], | |||
| 174 | # Code from module ssize_t: | 171 | # Code from module ssize_t: |
| 175 | # Code from module stat-time: | 172 | # Code from module stat-time: |
| 176 | # Code from module std-gnu11: | 173 | # Code from module std-gnu11: |
| 174 | # Code from module stdbit-h: | ||
| 177 | # Code from module stdbool: | 175 | # Code from module stdbool: |
| 176 | # Code from module stdc_bit_width: | ||
| 177 | # Code from module stdc_count_ones: | ||
| 178 | # Code from module stdc_leading_zeros: | ||
| 179 | # Code from module stdc_trailing_zeros: | ||
| 178 | # Code from module stdckdint: | 180 | # Code from module stdckdint: |
| 179 | # Code from module stddef: | 181 | # Code from module stddef: |
| 180 | # Code from module stdint: | 182 | # Code from module stdint: |
| @@ -514,7 +516,18 @@ AC_DEFUN([gl_INIT], | |||
| 514 | gt_TYPE_SSIZE_T | 516 | gt_TYPE_SSIZE_T |
| 515 | gl_STAT_TIME | 517 | gl_STAT_TIME |
| 516 | gl_STAT_BIRTHTIME | 518 | gl_STAT_BIRTHTIME |
| 519 | gl_STDBIT_H | ||
| 520 | gl_CONDITIONAL_HEADER([stdbit.h]) | ||
| 521 | AC_PROG_MKDIR_P | ||
| 517 | gl_C_BOOL | 522 | gl_C_BOOL |
| 523 | AC_REQUIRE([gl_STDBIT_H]) | ||
| 524 | GL_STDC_BIT_WIDTH=1 | ||
| 525 | AC_REQUIRE([gl_STDBIT_H]) | ||
| 526 | GL_STDC_COUNT_ONES=1 | ||
| 527 | AC_REQUIRE([gl_STDBIT_H]) | ||
| 528 | GL_STDC_LEADING_ZEROS=1 | ||
| 529 | AC_REQUIRE([gl_STDBIT_H]) | ||
| 530 | GL_STDC_TRAILING_ZEROS=1 | ||
| 518 | AC_CHECK_HEADERS_ONCE([stdckdint.h]) | 531 | AC_CHECK_HEADERS_ONCE([stdckdint.h]) |
| 519 | if test $ac_cv_header_stdckdint_h = yes; then | 532 | if test $ac_cv_header_stdckdint_h = yes; then |
| 520 | GL_GENERATE_STDCKDINT_H=false | 533 | GL_GENERATE_STDCKDINT_H=false |
| @@ -673,6 +686,7 @@ AC_DEFUN([gl_INIT], | |||
| 673 | gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false | 686 | gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false |
| 674 | gl_gnulib_enabled_strtoll=false | 687 | gl_gnulib_enabled_strtoll=false |
| 675 | gl_gnulib_enabled_utimens=false | 688 | gl_gnulib_enabled_utimens=false |
| 689 | gl_gnulib_enabled_verify=false | ||
| 676 | gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false | 690 | gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false |
| 677 | func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () | 691 | func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () |
| 678 | { | 692 | { |
| @@ -953,6 +967,12 @@ AC_DEFUN([gl_INIT], | |||
| 953 | gl_gnulib_enabled_utimens=true | 967 | gl_gnulib_enabled_utimens=true |
| 954 | fi | 968 | fi |
| 955 | } | 969 | } |
| 970 | func_gl_gnulib_m4code_verify () | ||
| 971 | { | ||
| 972 | if $gl_gnulib_enabled_verify; then :; else | ||
| 973 | gl_gnulib_enabled_verify=true | ||
| 974 | fi | ||
| 975 | } | ||
| 956 | func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () | 976 | func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec () |
| 957 | { | 977 | { |
| 958 | if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then :; else | 978 | if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then :; else |
| @@ -1016,6 +1036,9 @@ AC_DEFUN([gl_INIT], | |||
| 1016 | if case $host_os in mingw* | windows*) false;; *) test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1;; esac; then | 1036 | if case $host_os in mingw* | windows*) false;; *) test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1;; esac; then |
| 1017 | func_gl_gnulib_m4code_open | 1037 | func_gl_gnulib_m4code_open |
| 1018 | fi | 1038 | fi |
| 1039 | if test $REPLACE_MKTIME = 1; then | ||
| 1040 | func_gl_gnulib_m4code_verify | ||
| 1041 | fi | ||
| 1019 | if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then | 1042 | if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then |
| 1020 | func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b | 1043 | func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b |
| 1021 | fi | 1044 | fi |
| @@ -1025,6 +1048,9 @@ AC_DEFUN([gl_INIT], | |||
| 1025 | if test $ac_use_included_regex = yes; then | 1048 | if test $ac_use_included_regex = yes; then |
| 1026 | func_gl_gnulib_m4code_fd38c7e463b54744b77b98aeafb4fa7c | 1049 | func_gl_gnulib_m4code_fd38c7e463b54744b77b98aeafb4fa7c |
| 1027 | fi | 1050 | fi |
| 1051 | if test $ac_use_included_regex = yes; then | ||
| 1052 | func_gl_gnulib_m4code_verify | ||
| 1053 | fi | ||
| 1028 | if test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then | 1054 | if test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then |
| 1029 | func_gl_gnulib_m4code_strtoll | 1055 | func_gl_gnulib_m4code_strtoll |
| 1030 | fi | 1056 | fi |
| @@ -1065,6 +1091,7 @@ AC_DEFUN([gl_INIT], | |||
| 1065 | AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) | 1091 | AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) |
| 1066 | AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) | 1092 | AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) |
| 1067 | AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens]) | 1093 | AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens]) |
| 1094 | AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify]) | ||
| 1068 | AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) | 1095 | AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec]) |
| 1069 | # End of code from modules | 1096 | # End of code from modules |
| 1070 | m4_ifval(gl_LIBSOURCES_LIST, [ | 1097 | m4_ifval(gl_LIBSOURCES_LIST, [ |
| @@ -1276,12 +1303,6 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 1276 | lib/close-stream.c | 1303 | lib/close-stream.c |
| 1277 | lib/close-stream.h | 1304 | lib/close-stream.h |
| 1278 | lib/copy-file-range.c | 1305 | lib/copy-file-range.c |
| 1279 | lib/count-leading-zeros.c | ||
| 1280 | lib/count-leading-zeros.h | ||
| 1281 | lib/count-one-bits.c | ||
| 1282 | lib/count-one-bits.h | ||
| 1283 | lib/count-trailing-zeros.c | ||
| 1284 | lib/count-trailing-zeros.h | ||
| 1285 | lib/diffseq.h | 1306 | lib/diffseq.h |
| 1286 | lib/dirent-private.h | 1307 | lib/dirent-private.h |
| 1287 | lib/dirent.in.h | 1308 | lib/dirent.in.h |
| @@ -1414,6 +1435,12 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 1414 | lib/signal.in.h | 1435 | lib/signal.in.h |
| 1415 | lib/stat-time.c | 1436 | lib/stat-time.c |
| 1416 | lib/stat-time.h | 1437 | lib/stat-time.h |
| 1438 | lib/stdbit.c | ||
| 1439 | lib/stdbit.in.h | ||
| 1440 | lib/stdc_bit_width.c | ||
| 1441 | lib/stdc_count_ones.c | ||
| 1442 | lib/stdc_leading_zeros.c | ||
| 1443 | lib/stdc_trailing_zeros.c | ||
| 1417 | lib/stdckdint.in.h | 1444 | lib/stdckdint.in.h |
| 1418 | lib/stddef.in.h | 1445 | lib/stddef.in.h |
| 1419 | lib/stdint.in.h | 1446 | lib/stdint.in.h |
| @@ -1567,6 +1594,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 1567 | m4/stat-time.m4 | 1594 | m4/stat-time.m4 |
| 1568 | m4/std-gnu11.m4 | 1595 | m4/std-gnu11.m4 |
| 1569 | m4/stdalign.m4 | 1596 | m4/stdalign.m4 |
| 1597 | m4/stdbit_h.m4 | ||
| 1570 | m4/stddef_h.m4 | 1598 | m4/stddef_h.m4 |
| 1571 | m4/stdint.m4 | 1599 | m4/stdint.m4 |
| 1572 | m4/stdio_h.m4 | 1600 | m4/stdio_h.m4 |
diff --git a/m4/stdbit_h.m4 b/m4/stdbit_h.m4 new file mode 100644 index 00000000000..6af813f39dc --- /dev/null +++ b/m4/stdbit_h.m4 | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | # stdbit_h.m4 | ||
| 2 | # serial 2 | ||
| 3 | dnl Copyright 2024 Free Software Foundation, Inc. | ||
| 4 | dnl This file is free software; the Free Software Foundation | ||
| 5 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 6 | dnl with or without modifications, as long as this notice is preserved. | ||
| 7 | |||
| 8 | dnl A placeholder for <stdbit.h>, for platforms that have issues. | ||
| 9 | |||
| 10 | AC_DEFUN_ONCE([gl_STDBIT_H], | ||
| 11 | [ | ||
| 12 | AC_REQUIRE([gl_BIGENDIAN]) | ||
| 13 | |||
| 14 | AC_CHECK_HEADERS_ONCE([stdbit.h]) | ||
| 15 | if test $ac_cv_header_stdbit_h = yes; then | ||
| 16 | GL_GENERATE_STDBIT_H=false | ||
| 17 | else | ||
| 18 | GL_GENERATE_STDBIT_H=true | ||
| 19 | fi | ||
| 20 | |||
| 21 | dnl We don't use gl_MODULE_INDICATOR_INIT_VARIABLE here, because stdbit.in.h | ||
| 22 | dnl does not use #include_next. | ||
| 23 | GL_STDC_LEADING_ZEROS=0; AC_SUBST([GL_STDC_LEADING_ZEROS]) | ||
| 24 | GL_STDC_LEADING_ONES=0; AC_SUBST([GL_STDC_LEADING_ONES]) | ||
| 25 | GL_STDC_TRAILING_ZEROS=0; AC_SUBST([GL_STDC_TRAILING_ZEROS]) | ||
| 26 | GL_STDC_TRAILING_ONES=0; AC_SUBST([GL_STDC_TRAILING_ONES]) | ||
| 27 | GL_STDC_FIRST_LEADING_ZERO=0; AC_SUBST([GL_STDC_FIRST_LEADING_ZERO]) | ||
| 28 | GL_STDC_FIRST_LEADING_ONE=0; AC_SUBST([GL_STDC_FIRST_LEADING_ONE]) | ||
| 29 | GL_STDC_FIRST_TRAILING_ZERO=0; AC_SUBST([GL_STDC_FIRST_TRAILING_ZERO]) | ||
| 30 | GL_STDC_FIRST_TRAILING_ONE=0; AC_SUBST([GL_STDC_FIRST_TRAILING_ONE]) | ||
| 31 | GL_STDC_COUNT_ZEROS=0; AC_SUBST([GL_STDC_COUNT_ZEROS]) | ||
| 32 | GL_STDC_COUNT_ONES=0; AC_SUBST([GL_STDC_COUNT_ONES]) | ||
| 33 | GL_STDC_HAS_SINGLE_BIT=0; AC_SUBST([GL_STDC_HAS_SINGLE_BIT]) | ||
| 34 | GL_STDC_BIT_WIDTH=0; AC_SUBST([GL_STDC_BIT_WIDTH]) | ||
| 35 | GL_STDC_BIT_FLOOR=0; AC_SUBST([GL_STDC_BIT_FLOOR]) | ||
| 36 | GL_STDC_BIT_CEIL=0; AC_SUBST([GL_STDC_BIT_CEIL]) | ||
| 37 | ]) | ||