]> git.eshelyaron.com Git - emacs.git/commitdiff
Update from Gnulib by running admin/merge-gnulib
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 18 May 2024 16:33:03 +0000 (09:33 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sat, 18 May 2024 19:12:36 +0000 (21:12 +0200)
(cherry picked from commit 08550d058f028e0819ba6a72e9a53c0bc789257e)

14 files changed:
lib/byteswap.c [new file with mode: 0644]
lib/byteswap.in.h
lib/count-leading-zeros.h
lib/count-one-bits.h
lib/count-trailing-zeros.h
lib/gnulib.mk.in
lib/stdlib.in.h
lib/strftime.c
lib/sys_select.in.h
lib/unistd.in.h
m4/byteswap.m4
m4/gnulib-comp.m4
m4/stdalign.m4
m4/stdlib_h.m4

diff --git a/lib/byteswap.c b/lib/byteswap.c
new file mode 100644 (file)
index 0000000..6e3dad7
--- /dev/null
@@ -0,0 +1,21 @@
+/* Inline functions for <byteswap.h>.
+
+   Copyright 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_BYTESWAP_INLINE _GL_EXTERN_INLINE
+#include <byteswap.h>
index 8e49efad05adfb39e38cce1523af817526735d53..4be335d9158b2c46dd173bc7152f0e00ff062849 100644 (file)
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #ifndef _GL_BYTESWAP_H
-#define _GL_BYTESWAP_H
+#define _GL_BYTESWAP_H 1
+
+/* This file uses _GL_INLINE.  */
+#if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+#endif
+
+#include <stdint.h>
+
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_BYTESWAP_INLINE
+# define _GL_BYTESWAP_INLINE _GL_INLINE
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP16 true
+#elif defined __has_builtin
+# if __has_builtin (__builtin_bswap16)
+#  define _GL_BYTESWAP_HAS_BUILTIN_BSWAP16 true
+# endif
+#endif
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP32 true
+# define _GL_BYTESWAP_HAS_BUILTIN_BSWAP64 true
+#elif defined __has_builtin
+# if __has_builtin (__builtin_bswap32)
+#  define _GL_BYTESWAP_HAS_BUILTIN_BSWAP32 true
+# endif
+# if __has_builtin (__builtin_bswap64)
+#  define _GL_BYTESWAP_HAS_BUILTIN_BSWAP64 true
+# endif
+#endif
 
 /* Given an unsigned 16-bit argument X, return the value corresponding to
    X with reversed byte order.  */
-#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
-                     (((x) & 0xFF00) >> 8))
+_GL_BYTESWAP_INLINE uint_least16_t
+bswap_16 (uint_least16_t x)
+{
+#ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP16
+  return __builtin_bswap16 (x);
+#else
+  uint_fast16_t mask = 0xff;
+  return (  (x & mask << 8 * 1) >> 8 * 1
+          | (x & mask << 8 * 0) << 8 * 1);
+#endif
+}
 
 /* Given an unsigned 32-bit argument X, return the value corresponding to
    X with reversed byte order.  */
-#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
-                     (((x) & 0x0000FF00) << 8) | \
-                     (((x) & 0x00FF0000) >> 8) | \
-                     (((x) & 0xFF000000) >> 24))
+_GL_BYTESWAP_INLINE uint_least32_t
+bswap_32 (uint_least32_t x)
+{
+#ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP32
+  return __builtin_bswap32 (x);
+#else
+  uint_fast32_t mask = 0xff;
+  return (  (x & mask << 8 * 3) >> 8 * 3
+          | (x & mask << 8 * 2) >> 8 * 1
+          | (x & mask << 8 * 1) << 8 * 1
+          | (x & mask << 8 * 0) << 8 * 3);
+#endif
+}
 
+#ifdef UINT_LEAST64_MAX
 /* Given an unsigned 64-bit argument X, return the value corresponding to
    X with reversed byte order.  */
-#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
-                     (((x) & 0x000000000000FF00ULL) << 40) | \
-                     (((x) & 0x0000000000FF0000ULL) << 24) | \
-                     (((x) & 0x00000000FF000000ULL) << 8) | \
-                     (((x) & 0x000000FF00000000ULL) >> 8) | \
-                     (((x) & 0x0000FF0000000000ULL) >> 24) | \
-                     (((x) & 0x00FF000000000000ULL) >> 40) | \
-                     (((x) & 0xFF00000000000000ULL) >> 56))
+_GL_BYTESWAP_INLINE uint_least64_t
+bswap_64 (uint_least64_t x)
+{
+# ifdef _GL_BYTESWAP_HAS_BUILTIN_BSWAP64
+  return __builtin_bswap64 (x);
+# else
+  uint_fast64_t mask = 0xff;
+  return (  (x & mask << 8 * 7) >> 8 * 7
+          | (x & mask << 8 * 6) >> 8 * 5
+          | (x & mask << 8 * 5) >> 8 * 3
+          | (x & mask << 8 * 4) >> 8 * 1
+          | (x & mask << 8 * 3) << 8 * 1
+          | (x & mask << 8 * 2) << 8 * 3
+          | (x & mask << 8 * 1) << 8 * 5
+          | (x & mask << 8 * 0) << 8 * 7);
+# endif
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+_GL_INLINE_HEADER_END
 
 #endif /* _GL_BYTESWAP_H */
index 545749d6d2753cb51d81e928924b900eaccea5bb..a4b68c210645361d0e478768e04816334d374b5a 100644 (file)
@@ -45,8 +45,10 @@ extern "C" {
 # define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE)                \
   return x ? BUILTIN (x) : CHAR_BIT * sizeof x;
 #elif _MSC_VER
+extern unsigned char _BitScanReverse (unsigned long *, unsigned long);
 # pragma intrinsic (_BitScanReverse)
 # if defined _M_X64
+extern unsigned char _BitScanReverse64 (unsigned long *, unsigned long long);
 #  pragma intrinsic (_BitScanReverse64)
 # endif
 # define COUNT_LEADING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE)                \
index 8d67f8718a4e29767ef71383e1d34aff85fa7aca..24bf8cc2327795c61159f9e701ee0119124b7012 100644 (file)
@@ -85,9 +85,12 @@ count_one_bits_32 (unsigned int x)
 #   include <intrin.h>
 #  else
     /* Don't pollute the namespace with too many MSVC intrinsics.  */
+extern void __cpuid (int[4], int);
 #   pragma intrinsic (__cpuid)
+extern unsigned int __popcnt (unsigned int);
 #   pragma intrinsic (__popcnt)
 #   if defined _M_X64
+extern unsigned long long __popcnt64 (unsigned long long);
 #    pragma intrinsic (__popcnt64)
 #   endif
 #  endif
index ed1e013114704cbcbdeb492e98aff00190880743..82de8731ec120523312b12aa4fa6f4664eaca05b 100644 (file)
@@ -45,8 +45,10 @@ extern "C" {
 # define COUNT_TRAILING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE)               \
   return x ? BUILTIN (x) : CHAR_BIT * sizeof x;
 #elif _MSC_VER
+extern unsigned char _BitScanForward (unsigned long *, unsigned long);
 # pragma intrinsic (_BitScanForward)
 # if defined _M_X64
+extern unsigned char _BitScanForward64 (unsigned long *, unsigned long long);
 #  pragma intrinsic (_BitScanForward64)
 # endif
 # define COUNT_TRAILING_ZEROS(BUILTIN, MSC_BUILTIN, TYPE)               \
index a5c009cfb85d2544ea87be147ab9dac4eeb2146d..d03e193b63c10b166cbacdbca2c8cfebc4ed857d 100644 (file)
@@ -361,6 +361,7 @@ GL_GENERATE_MINI_GMP_H_CONDITION = @GL_GENERATE_MINI_GMP_H_CONDITION@
 GL_GENERATE_STDCKDINT_H_CONDITION = @GL_GENERATE_STDCKDINT_H_CONDITION@
 GL_GENERATE_STDDEF_H_CONDITION = @GL_GENERATE_STDDEF_H_CONDITION@
 GL_GENERATE_STDINT_H_CONDITION = @GL_GENERATE_STDINT_H_CONDITION@
+GL_GNULIB_ABORT_DEBUG = @GL_GNULIB_ABORT_DEBUG@
 GL_GNULIB_ACCESS = @GL_GNULIB_ACCESS@
 GL_GNULIB_ALIGNED_ALLOC = @GL_GNULIB_ALIGNED_ALLOC@
 GL_GNULIB_ALPHASORT = @GL_GNULIB_ALPHASORT@
@@ -1107,6 +1108,7 @@ QCOPY_ACL_LIB = @QCOPY_ACL_LIB@
 RALLOC_OBJ = @RALLOC_OBJ@
 RANLIB = @RANLIB@
 READELF = @READELF@
+REPLACE_ABORT = @REPLACE_ABORT@
 REPLACE_ACCESS = @REPLACE_ACCESS@
 REPLACE_ALIGNED_ALLOC = @REPLACE_ALIGNED_ALLOC@
 REPLACE_CALLOC_FOR_CALLOC_GNU = @REPLACE_CALLOC_FOR_CALLOC_GNU@
@@ -1639,6 +1641,7 @@ ifneq (,$(GL_GENERATE_BYTESWAP_H_CONDITION))
 byteswap.h: byteswap.in.h $(top_builddir)/config.status
        $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/byteswap.in.h
        $(AM_V_at)mv $@-t $@
+libgnu_a_SOURCES += byteswap.c
 else
 byteswap.h: $(top_builddir)/config.status
        rm -f $@
@@ -3322,6 +3325,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
              -e 's/@''GNULIB__EXIT''@/$(GL_GNULIB__EXIT)/g' \
+             -e 's/@''GNULIB_ABORT_DEBUG''@/$(GL_GNULIB_ABORT_DEBUG)/g' \
              -e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GL_GNULIB_ALIGNED_ALLOC)/g' \
              -e 's/@''GNULIB_ATOLL''@/$(GL_GNULIB_ATOLL)/g' \
              -e 's/@''GNULIB_CALLOC_GNU''@/$(GL_GNULIB_CALLOC_GNU)/g' \
@@ -3424,6 +3428,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
              < $@-t1 > $@-t2
        $(AM_V_at)sed \
              -e 's|@''REPLACE__EXIT''@|$(REPLACE__EXIT)|g' \
+             -e 's|@''REPLACE_ABORT''@|$(REPLACE_ABORT)|g' \
              -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
              -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \
              -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
index e74e7c18d19e0550ef6ca23e40f52e6b615caf85..1888d3ee314e7b79c86348c5431d09998e8efe06 100644 (file)
@@ -216,6 +216,23 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
 #endif
 
 
+#if @GNULIB_ABORT_DEBUG@
+# if @REPLACE_ABORT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef abort
+#   define abort rpl_abort
+#  endif
+_GL_FUNCDECL_RPL (abort, _Noreturn void, (void));
+_GL_CXXALIAS_RPL (abort, void, (void));
+# else
+_GL_CXXALIAS_SYS (abort, void, (void));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (abort);
+# endif
+#endif
+
+
 #if @GNULIB_FREE_POSIX@
 # if @REPLACE_FREE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
index 9b205e48023b49b7d8f80eef4978763b4e0b025b..834f3a79f46d68bce57dfb74b6c9bd9a48c2ad21 100644 (file)
@@ -143,11 +143,11 @@ extern char *tzname[];
 
 enum pad_style
 {
-  ZERO_PAD,      /* (default) Pad with 0 unless format says otherwise.  */
-  ALWAYS_ZERO_PAD,     /* '0' Always pad with 0.  */
-  SIGN_PAD,            /* '+' Always output a sign.  */
-  SPACE_PAD,           /* '_' Pad with space.  */
-  NO_PAD               /* '-' Do not pad.  */
+  ZERO_PAD,         /* (default) Pad with 0 unless format says otherwise.  */
+  ALWAYS_ZERO_PAD,  /* '0'       Always pad with 0.  */
+  SIGN_PAD,         /* '+'       Always output a sign.  */
+  SPACE_PAD,        /* '_'       Pad with space.  */
+  NO_PAD            /* '-'       Do not pad.  */
 };
 
 #define TM_YEAR_BASE 1900
index de29c77949af528c7d00a0e4e8ac641da0c8821e..ddf25d1de4c48e48351f88b8cc0ccd9d6b54f046 100644 (file)
@@ -328,7 +328,9 @@ _GL_CXXALIAS_SYS (select, int,
                   (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
                    timeval *restrict));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (select);
+# endif
 #elif @HAVE_WINSOCK2_H@
 # undef select
 # define select select_used_without_requesting_gnulib_module_select
index fa99d7472f41af292d0f5758503dc8408826604e..7dbed38969b4a08e45a09a8d99c59d1b86a326ea 100644 (file)
@@ -1934,11 +1934,7 @@ _GL_CXXALIASWARN (read);
 #   undef read
 #   define read _read
 #  endif
-#  ifdef __MINGW32__
-_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
-#  else
-_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
-#  endif
+_GL_CXXALIAS_MDA_CAST (read, ssize_t, (int fd, void *buf, unsigned int count));
 # else
 _GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
 # endif
@@ -2402,11 +2398,7 @@ _GL_CXXALIASWARN (write);
 #   undef write
 #   define write _write
 #  endif
-#  ifdef __MINGW32__
-_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
-#  else
-_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
-#  endif
+_GL_CXXALIAS_MDA_CAST (write, ssize_t, (int fd, const void *buf, unsigned int count));
 # else
 _GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
 # endif
index 0c76fe9312d08f129fa031ae3f5d9ed5e81fc6dc..3f5ef45cfe6896b1f14c4705e80d3efe47ddca83 100644 (file)
@@ -1,5 +1,5 @@
 # byteswap.m4
-# serial 5
+# serial 6
 dnl Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,9 +10,28 @@ dnl Written by Oskar Liljeblad.
 AC_DEFUN([gl_BYTESWAP],
 [
   dnl Prerequisites of lib/byteswap.in.h.
-  AC_CHECK_HEADERS([byteswap.h], [
+  AC_CHECK_HEADERS_ONCE([byteswap.h])
+  if test $ac_cv_header_byteswap_h = yes; then
+    AC_CACHE_CHECK([for working bswap_16, bswap_32, bswap_64],
+      [gl_cv_header_working_byteswap_h],
+      [gl_cv_header_working_byteswap_h=no
+       AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <byteswap.h>
+            ]],
+            [[int value_16 = bswap_16 (0.0);
+              int value_32 = bswap_32 (0.0);
+              int value_64 = bswap_64 (0.0);
+              return !(value_16 + value_32 + value_64);
+            ]])
+         ],
+         [gl_cv_header_working_byteswap_h=yes],
+         [gl_cv_header_working_byteswap_h=no])
+      ])
+  fi
+  if test $gl_cv_header_working_byteswap_h = yes; then
     GL_GENERATE_BYTESWAP_H=false
-  ], [
+  else
     GL_GENERATE_BYTESWAP_H=true
-  ])
+  fi
 ])
index 37f180a89556f6e91a25e6eda83a332ee5ea5745..61040987b5766653c4b9ed59c97f87fad23a58b3 100644 (file)
@@ -1259,6 +1259,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/boot-time-aux.h
   lib/boot-time.c
   lib/boot-time.h
+  lib/byteswap.c
   lib/byteswap.in.h
   lib/c++defs.h
   lib/c-ctype.c
index 2b4762f3200708eda590caed931b2008ea23adbe..1c29d1e4fb9076e7d45f06304a3eac70614dd34c 100644 (file)
@@ -81,7 +81,7 @@ AC_DEFUN([gl_ALIGNASOF],
 
    References:
    ISO C23 (latest free draft
-   <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3047.pdf>)
+   <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf>)
    sections 6.5.3.4, 6.7.5, 7.15.
    C++11 (latest free draft
    <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
index a4662f299556bbcace5aaaddc8fd8746a5014622..bb5a6460414f7551dae5b7f8a6fa481aa640bca0 100644 (file)
@@ -1,5 +1,5 @@
 # stdlib_h.m4
-# serial 77
+# serial 78
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -110,6 +110,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
 [
   m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ABORT_DEBUG])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU])
@@ -218,6 +219,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_UNLOCKPT=1;           AC_SUBST([HAVE_UNLOCKPT])
   HAVE_DECL_UNSETENV=1;      AC_SUBST([HAVE_DECL_UNSETENV])
   REPLACE__EXIT=0;           AC_SUBST([REPLACE__EXIT])
+  REPLACE_ABORT=0;           AC_SUBST([REPLACE_ABORT])
   REPLACE_ALIGNED_ALLOC=0;   AC_SUBST([REPLACE_ALIGNED_ALLOC])
   REPLACE_CALLOC_FOR_CALLOC_GNU=0;    AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
   REPLACE_CALLOC_FOR_CALLOC_POSIX=0;  AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])