#include "acl-internal.h"
+#if defined __CYGWIN__
+# include <sys/types.h>
+# include <grp.h>
+# include <string.h>
+#endif
+
#if USE_ACL && HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */
# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
acl_tag_t tag;
if (acl_get_tag_type (ace, &tag) < 0)
return -1;
- if (!(tag == ACL_USER_OBJ || tag == ACL_GROUP_OBJ || tag == ACL_OTHER))
- return 1;
+ switch (tag)
+ {
+ case ACL_USER_OBJ:
+ case ACL_GROUP_OBJ:
+ case ACL_OTHER:
+ break;
+# ifdef __CYGWIN__
+ /* On Cygwin, a trivial ACL inside the Cygwin file system consists of
+ e.g.
+ user::rwx
+ group::r-x
+ other::r-x
+ but a trivial ACL outside the Cygwin file system has more entries:
+ e.g.
+ user::rwx
+ group::r-x
+ group:SYSTEM:rwx
+ group:Administrators:rwx
+ mask::r-x
+ other::r-x
+ */
+ case ACL_GROUP:
+ {
+ int ignorable = 0;
+ void *qualifier = acl_get_qualifier (ace);
+ if (qualifier != NULL)
+ {
+ gid_t group_id = *(gid_t const *) qualifier;
+ acl_free (qualifier);
+ struct group *group_details = getgrgid (group_id);
+ if (group_details != NULL)
+ {
+ const char *group_sid = group_details->gr_passwd;
+ /* Ignore the ace if the group_sid is one of
+ - S-1-5-18 (group "SYSTEM")
+ - S-1-5-32-544 (group "Administrators")
+ Cf. <https://learn.microsoft.com/en-us/windows/win32/secauthz/well-known-sids> */
+ ignorable = (strcmp (group_sid, "S-1-5-18") == 0
+ || strcmp (group_sid, "S-1-5-32-544") == 0);
+ }
+ }
+ if (!ignorable)
+ return 1;
+ }
+ break;
+ case ACL_MASK:
+ /* XXX Is it OK to ignore acl_get_permset (ace, ...) ? */
+ break;
+# endif
+ default:
+ return 1;
+ }
}
return got_one;
_GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED,
_GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL,
_GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED,
- _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_RETURNS_NONNULL,
- _GL_ATTRIBUTE_SENTINEL. */
+ _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_REPRODUCIBLE,
+ _GL_ATTRIBUTE_RETURNS_NONNULL, _GL_ATTRIBUTE_SENTINEL,
+ _GL_ATTRIBUTE_UNSEQUENCED. */
#if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first."
#endif
is the size of the returned memory block.
ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
to determine the size of the returned memory block. */
-/* Applies to: function, pointer to function, function types. */
+/* Applies to: functions, pointer to functions, function types. */
#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
/* Attributes regarding debugging information emitted by the compiler. */
/* Omit the function from stack traces when debugging. */
-/* Applies to: function. */
+/* Applies to: functions. */
#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */
/* Always inline the function, and report an error if the compiler
cannot inline. */
-/* Applies to: function. */
+/* Applies to: functions. */
#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
-/* It is OK for a compiler to omit duplicate calls with the same arguments.
+/* It is OK for a compiler to move calls to the function and to omit
+ calls to the function if another call has the same arguments or the
+ result is not used.
This attribute is safe for a function that neither depends on
- nor affects observable state, and always returns exactly once -
- e.g., does not loop forever, and does not call longjmp.
- (This attribute is stricter than ATTRIBUTE_PURE.) */
+ nor affects state, and always returns exactly once -
+ e.g., does not raise an exception, call longjmp, or loop forever.
+ (This attribute is stricter than ATTRIBUTE_PURE because the
+ function cannot observe state. It is stricter than UNSEQUENCED
+ because the function must return exactly once and cannot depend on
+ state addressed by its arguments.) */
/* Applies to: functions. */
#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
-/* It is OK for a compiler to omit duplicate calls with the same
- arguments if observable state is not changed between calls.
- This attribute is safe for a function that does not affect
- observable state, and always returns exactly once.
- (This attribute is looser than ATTRIBUTE_CONST.) */
+/* It is OK for a compiler to move calls to the function and to omit duplicate
+ calls to the function with the same arguments, so long as the state
+ addressed by its arguments is the same.
+ This attribute is safe for a function that is effectless, idempotent,
+ stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of
+ these terms.
+ (This attribute is stricter than REPRODUCIBLE because the function
+ must be stateless and independent. It is looser than ATTRIBUTE_CONST
+ because the function need not return exactly once and can depend
+ on state addressed by its arguments.)
+ See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
+ <https://stackoverflow.com/questions/76847905/>. */
+/* Applies to: functions, pointer to functions, function type. */
+#define UNSEQUENCED _GL_ATTRIBUTE_UNSEQUENCED
+
+/* It is OK for a compiler to move calls to the function and to omit
+ calls to the function if another call has the same arguments or the
+ result is not used, and if observable state is the same.
+ This attribute is safe for a function that does not affect observable state
+ and always returns exactly once.
+ (This attribute is looser than ATTRIBUTE_CONST because the function
+ can depend on observable state. It is stricter than REPRODUCIBLE
+ because the function must return exactly once and cannot affect
+ state addressed by its arguments.) */
/* Applies to: functions. */
#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
+/* It is OK for a compiler to move calls to the function and to omit duplicate
+ calls to the function with the same arguments, so long as the state
+ addressed by its arguments is the same and is updated in time for
+ the rest of the program.
+ This attribute is safe for a function that is effectless and idempotent; see
+ ISO C 23 § 6.7.12.7 for a definition of these terms.
+ (This attribute is looser than UNSEQUENCED because the function need
+ not be stateless and idempotent. It is looser than ATTRIBUTE_PURE
+ because the function need not return exactly once and can affect
+ state addressed by its arguments.)
+ See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
+ <https://stackoverflow.com/questions/76847905/>. */
+/* Applies to: functions, pointer to functions, function type. */
+#define REPRODUCIBLE _GL_ATTRIBUTE_REPRODUCIBLE
+
/* The function is rarely executed. */
/* Applies to: functions. */
#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
struct stat statbuf;
if (stat (filename, &statbuf) >= 0)
{
- *p_boot_time = get_stat_mtime (&statbuf);
- return 0;
+ struct timespec boot_time = get_stat_mtime (&statbuf);
+ /* On Alpine 3.20.0_rc2 /var/run/utmp was observed with bogus
+ timestamps of ~10 s. Reject timestamps before
+ 2005-07-25 23:34:15 UTC (1122334455), as neither Alpine
+ nor Devuan existed then. */
+ if (boot_time.tv_sec >= 1122334455)
+ {
+ *p_boot_time = boot_time;
+ return 0;
+ }
}
}
return -1;
return -1;
}
+# ifndef __CYGWIN__
+# if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
+
+/* Don't assume that UNICODE is not defined. */
+# undef LoadLibrary
+# define LoadLibrary LoadLibraryA
+
+/* Avoid warnings from gcc -Wcast-function-type. */
+# define GetProcAddress \
+ (void *) GetProcAddress
+
+/* GetTickCount64 is only available on Windows Vista and later. */
+typedef ULONGLONG (WINAPI * GetTickCount64FuncType) (void);
+
+static GetTickCount64FuncType GetTickCount64Func = NULL;
+static BOOL initialized = FALSE;
+
+static void
+initialize (void)
+{
+ HMODULE kernel32 = LoadLibrary ("kernel32.dll");
+ if (kernel32 != NULL)
+ {
+ GetTickCount64Func =
+ (GetTickCount64FuncType) GetProcAddress (kernel32, "GetTickCount64");
+ }
+ initialized = TRUE;
+}
+
+# else
+
+# define GetTickCount64Func GetTickCount64
+
+# endif
+
+/* Fallback for Windows in the form:
+ boot time = current time - uptime
+ This uses the GetTickCount64 function which is only available on Windows
+ Vista and later. See:
+ <https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64>. */
+static int
+get_windows_boot_time_fallback (struct timespec *p_boot_time)
+{
+# if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
+ if (! initialized)
+ initialize ();
+# endif
+ if (GetTickCount64Func != NULL)
+ {
+ ULONGLONG uptime_ms = GetTickCount64Func ();
+ struct timespec uptime;
+ struct timespec result;
+ struct timeval tv;
+ if (gettimeofday (&tv, NULL) >= 0)
+ {
+ uptime.tv_sec = uptime_ms / 1000;
+ uptime.tv_nsec = (uptime_ms % 1000) * 1000000;
+ result.tv_sec = tv.tv_sec;
+ result.tv_nsec = tv.tv_usec * 1000;
+ if (result.tv_nsec < uptime.tv_nsec)
+ {
+ result.tv_nsec += 1000000000;
+ result.tv_sec -= 1;
+ }
+ result.tv_sec -= uptime.tv_sec;
+ result.tv_nsec -= uptime.tv_nsec;
+ *p_boot_time = result;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+# endif
#endif
# include <OS.h>
#endif
+#if defined _WIN32 && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# include <sysinfoapi.h>
+# include <sys/time.h>
+#endif
+
#include "idx.h"
#include "readutmp.h"
#include "stat-time.h"
{
/* Workaround for Windows: */
get_windows_boot_time (&found_boot_time);
+# ifndef __CYGWIN__
+ if (found_boot_time.tv_sec == 0)
+ get_windows_boot_time_fallback (&found_boot_time);
+# endif
}
# endif
--- /dev/null
+/* Inline functions for <endian.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/>. */
+
+/* Written by Collin Funk. */
+
+#include <config.h>
+
+#define _GL_ENDIAN_INLINE _GL_EXTERN_INLINE
+#include <endian.h>
--- /dev/null
+/* endian.h - Byte order macros
+
+ 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/>. */
+
+/* Written by Collin Funk. */
+
+#ifndef _@GUARD_PREFIX@_ENDIAN_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+#if @HAVE_ENDIAN_H@
+
+/* The include_next requires a split double-inclusion guard. */
+# @INCLUDE_NEXT@ @NEXT_ENDIAN_H@
+
+#endif
+
+
+/* glibc defines all macros and functions but is missing types from
+ stdint.h. */
+#if @ENDIAN_H_JUST_MISSING_STDINT@
+# include <stdint.h>
+#else
+
+/* Others platforms. */
+#ifndef _@GUARD_PREFIX@_ENDIAN_H
+#define _@GUARD_PREFIX@_ENDIAN_H 1
+
+/* This file uses _GL_INLINE, WORDS_BIGENDIAN. */
+#if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+#endif
+
+/* Define uint16_t and uint32_t.
+ Define uint64_t if it is available. */
+#include <stdint.h>
+
+/* Byteswap functions. */
+#include <byteswap.h>
+
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_ENDIAN_INLINE
+# define _GL_ENDIAN_INLINE _GL_INLINE
+#endif
+
+#define LITTLE_ENDIAN 1234
+#define BIG_ENDIAN 4321
+#define PDP_ENDIAN 3412
+
+#ifdef WORDS_BIGENDIAN
+# define BYTE_ORDER BIG_ENDIAN
+#else
+# define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+/* Make sure function-like macros get undefined. */
+#if @HAVE_ENDIAN_H@
+# undef be16toh
+# undef be32toh
+# undef be64toh
+# undef htobe16
+# undef htobe32
+# undef htobe64
+# undef le16toh
+# undef le32toh
+# undef le64toh
+# undef htole16
+# undef htole32
+# undef htole64
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Big endian to host. */
+
+_GL_ENDIAN_INLINE uint16_t
+be16toh (uint16_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return x;
+#else
+ return bswap_16 (x);
+#endif
+}
+
+_GL_ENDIAN_INLINE uint32_t
+be32toh (uint32_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return x;
+#else
+ return bswap_32 (x);
+#endif
+}
+
+#ifdef UINT64_MAX
+_GL_ENDIAN_INLINE uint64_t
+be64toh (uint64_t x)
+{
+# if BYTE_ORDER == BIG_ENDIAN
+ return x;
+# else
+ return bswap_64 (x);
+# endif
+}
+#endif
+
+/* Host to big endian. */
+
+_GL_ENDIAN_INLINE uint16_t
+htobe16 (uint16_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return x;
+#else
+ return bswap_16 (x);
+#endif
+}
+
+_GL_ENDIAN_INLINE uint32_t
+htobe32 (uint32_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return x;
+#else
+ return bswap_32 (x);
+#endif
+}
+
+#ifdef UINT64_MAX
+_GL_ENDIAN_INLINE uint64_t
+htobe64 (uint64_t x)
+{
+# if BYTE_ORDER == BIG_ENDIAN
+ return x;
+# else
+ return bswap_64 (x);
+# endif
+}
+#endif
+
+/* Little endian to host. */
+
+_GL_ENDIAN_INLINE uint16_t
+le16toh (uint16_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return bswap_16 (x);
+#else
+ return x;
+#endif
+}
+
+_GL_ENDIAN_INLINE uint32_t
+le32toh (uint32_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return bswap_32 (x);
+#else
+ return x;
+#endif
+}
+
+#ifdef UINT64_MAX
+_GL_ENDIAN_INLINE uint64_t
+le64toh (uint64_t x)
+{
+# if BYTE_ORDER == BIG_ENDIAN
+ return bswap_64 (x);
+# else
+ return x;
+# endif
+}
+#endif
+
+/* Host to little endian. */
+
+_GL_ENDIAN_INLINE uint16_t
+htole16 (uint16_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return bswap_16 (x);
+#else
+ return x;
+#endif
+}
+
+_GL_ENDIAN_INLINE uint32_t
+htole32 (uint32_t x)
+{
+#if BYTE_ORDER == BIG_ENDIAN
+ return bswap_32 (x);
+#else
+ return x;
+#endif
+}
+
+#ifdef UINT64_MAX
+_GL_ENDIAN_INLINE uint64_t
+htole64 (uint64_t x)
+{
+# if BYTE_ORDER == BIG_ENDIAN
+ return bswap_64 (x);
+# else
+ return x;
+# endif
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+_GL_INLINE_HEADER_END
+
+#endif /* @ENDIAN_H_JUST_MISSING_STDINT@ */
+#endif /* _@GUARD_PREFIX@_ENDIAN_H */
+#endif /* _@GUARD_PREFIX@_ENDIAN_H */
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#if defined _WIN32 && ! defined __CYGWIN__
-# include <io.h>
-#else
+#if !(defined _WIN32 && ! defined __CYGWIN__)
# include "root-uid.h"
#endif
#elif HAVE_EACCESS /* FreeBSD */
return eaccess (file, mode);
#elif defined _WIN32 && ! defined __CYGWIN__ /* mingw */
- return _access (file, mode);
+ return access (file, mode);
#else /* Mac OS X, NetBSD, OpenBSD, HP-UX, Solaris, Cygwin, BeOS */
uid_t uid = getuid ();
return result;
}
-/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt.
+/* glibc gets a LSB-compliant getopt and a POSIX-compliant __posix_getopt.
Standalone applications just get a POSIX-compliant getopt.
POSIX and LSB both require these functions to take 'char *const *argv'
even though this is incorrect (because of the permutation). */
EMACS_MANIFEST = @EMACS_MANIFEST@
EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
EMULTIHOP_VALUE = @EMULTIHOP_VALUE@
+ENDIAN_H = @ENDIAN_H@
+ENDIAN_H_JUST_MISSING_STDINT = @ENDIAN_H_JUST_MISSING_STDINT@
ENOLINK_HIDDEN = @ENOLINK_HIDDEN@
ENOLINK_VALUE = @ENOLINK_VALUE@
EOVERFLOW_HIDDEN = @EOVERFLOW_HIDDEN@
GL_GENERATE_ALLOCA_H_CONDITION = @GL_GENERATE_ALLOCA_H_CONDITION@
GL_GENERATE_ASSERT_H_CONDITION = @GL_GENERATE_ASSERT_H_CONDITION@
GL_GENERATE_BYTESWAP_H_CONDITION = @GL_GENERATE_BYTESWAP_H_CONDITION@
+GL_GENERATE_ENDIAN_H_CONDITION = @GL_GENERATE_ENDIAN_H_CONDITION@
GL_GENERATE_ERRNO_H_CONDITION = @GL_GENERATE_ERRNO_H_CONDITION@
GL_GENERATE_EXECINFO_H_CONDITION = @GL_GENERATE_EXECINFO_H_CONDITION@
GL_GENERATE_GETOPT_CDEFS_H_CONDITION = @GL_GENERATE_GETOPT_CDEFS_H_CONDITION@
HAVE_DIRENT_H = @HAVE_DIRENT_H@
HAVE_DPRINTF = @HAVE_DPRINTF@
HAVE_DUP3 = @HAVE_DUP3@
+HAVE_ENDIAN_H = @HAVE_ENDIAN_H@
HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
HAVE_EXECVPE = @HAVE_EXECVPE@
HAVE_EXPLICIT_BZERO = @HAVE_EXPLICIT_BZERO@
NEXT_ASSERT_H = @NEXT_ASSERT_H@
NEXT_AS_FIRST_DIRECTIVE_ASSERT_H = @NEXT_AS_FIRST_DIRECTIVE_ASSERT_H@
NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@
+NEXT_AS_FIRST_DIRECTIVE_ENDIAN_H = @NEXT_AS_FIRST_DIRECTIVE_ENDIAN_H@
NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = @NEXT_AS_FIRST_DIRECTIVE_GETOPT_H@
NEXT_AS_FIRST_DIRECTIVE_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_TIME_H@
NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
NEXT_DIRENT_H = @NEXT_DIRENT_H@
+NEXT_ENDIAN_H = @NEXT_ENDIAN_H@
NEXT_ERRNO_H = @NEXT_ERRNO_H@
NEXT_FCNTL_H = @NEXT_FCNTL_H@
NEXT_GETOPT_H = @NEXT_GETOPT_H@
REPLACE_GETRANDOM = @REPLACE_GETRANDOM@
REPLACE_GETSUBOPT = @REPLACE_GETSUBOPT@
REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
+REPLACE_GETUSERSHELL = @REPLACE_GETUSERSHELL@
REPLACE_GMTIME = @REPLACE_GMTIME@
REPLACE_IMAXABS = @REPLACE_IMAXABS@
REPLACE_IMAXDIV = @REPLACE_IMAXDIV@
gl_GNULIB_ENABLED_dirfd_CONDITION = @gl_GNULIB_ENABLED_dirfd_CONDITION@
gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b_CONDITION = @gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b_CONDITION@
gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION = @gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION@
+gl_GNULIB_ENABLED_endian_CONDITION = @gl_GNULIB_ENABLED_endian_CONDITION@
gl_GNULIB_ENABLED_euidaccess_CONDITION = @gl_GNULIB_ENABLED_euidaccess_CONDITION@
gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION = @gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION@
gl_GNULIB_ENABLED_getdelim_CONDITION = @gl_GNULIB_ENABLED_getdelim_CONDITION@
endif
## end gnulib module eloop-threshold
+## begin gnulib module endian
+ifeq (,$(OMIT_GNULIB_MODULE_endian))
+
+ifneq (,$(gl_GNULIB_ENABLED_endian_CONDITION))
+BUILT_SOURCES += $(ENDIAN_H)
+
+# We need the following in order to create <endian.h> when the system
+# doesn't have one.
+ifneq (,$(GL_GENERATE_ENDIAN_H_CONDITION))
+endian.h: endian.in.h $(top_builddir)/config.status
+ $(gl_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''HAVE_ENDIAN_H''@|$(HAVE_ENDIAN_H)|g' \
+ -e 's|@''NEXT_ENDIAN_H''@|$(NEXT_ENDIAN_H)|g' \
+ -e 's|@''ENDIAN_H_JUST_MISSING_STDINT''@|$(ENDIAN_H_JUST_MISSING_STDINT)|g' \
+ $(srcdir)/endian.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
+libgnu_a_SOURCES += endian.c
+else
+endian.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += endian.h endian.h-t
+
+endif
+EXTRA_DIST += endian.in.h
+
+endif
+## end gnulib module endian
+
## begin gnulib module errno
ifeq (,$(OMIT_GNULIB_MODULE_errno))
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
-e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
-e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \
+ -e 's|@''REPLACE_GETUSERSHELL''@|$(REPLACE_GETUSERSHELL)|g' \
-e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
-e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
-e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
<https://www.gnu.org/licenses/>. */
#ifndef _IEEE754_H
-
#define _IEEE754_H 1
#ifndef _GL_GNULIB_HEADER
/* Ordinary glibc usage. */
# include <features.h>
-# include <endian.h>
+# include <bits/endian.h>
+# define _IEEE754_BYTE_ORDER __BYTE_ORDER
+# define _IEEE754_BIG_ENDIAN __BIG_ENDIAN
+# define _IEEE754_LITTLE_ENDIAN __LITTLE_ENDIAN
+# define _IEEE754_FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
#else
/* Gnulib usage. */
-# ifndef __BEGIN_DECLS
-# ifdef __cplusplus
-# define __BEGIN_DECLS extern "C" {
-# define __END_DECLS }
-# else
-# define __BEGIN_DECLS
-# define __END_DECLS
-# endif
-# endif
-# ifndef __FLOAT_WORD_ORDER
-# define __LITTLE_ENDIAN 1234
-# define __BIG_ENDIAN 4321
-# ifdef WORDS_BIGENDIAN
-# define __BYTE_ORDER __BIG_ENDIAN
-# else
-# define __BYTE_ORDER __LITTLE_ENDIAN
-# endif
-# define __FLOAT_WORD_ORDER __BYTE_ORDER
-# endif
+# include <endian.h>
+# define _IEEE754_BYTE_ORDER BYTE_ORDER
+# define _IEEE754_BIG_ENDIAN BIG_ENDIAN
+# define _IEEE754_LITTLE_ENDIAN LITTLE_ENDIAN
+# define _IEEE754_FLOAT_WORD_ORDER BYTE_ORDER
#endif
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
union ieee754_float
{
/* This is the IEEE 754 single-precision format. */
struct
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:8;
unsigned int mantissa:23;
#endif /* Big endian. */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_LITTLE_ENDIAN
unsigned int mantissa:23;
unsigned int exponent:8;
unsigned int negative:1;
/* This format makes it easier to see if a NaN is a signalling NaN. */
struct
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:8;
unsigned int quiet_nan:1;
unsigned int mantissa:22;
#endif /* Big endian. */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_LITTLE_ENDIAN
unsigned int mantissa:22;
unsigned int quiet_nan:1;
unsigned int exponent:8;
/* This is the IEEE 754 double-precision format. */
struct
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:11;
/* Together these comprise the mantissa. */
unsigned int mantissa0:20;
unsigned int mantissa1:32;
#endif /* Big endian. */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_LITTLE_ENDIAN
+# if _IEEE754_FLOAT_WORD_ORDER == _IEEE754_BIG_ENDIAN
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
/* This format makes it easier to see if a NaN is a signalling NaN. */
struct
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:11;
unsigned int quiet_nan:1;
unsigned int mantissa0:19;
unsigned int mantissa1:32;
#else
-# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
+# if _IEEE754_FLOAT_WORD_ORDER == _IEEE754_BIG_ENDIAN
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
/* This is the IEEE 854 double-extended-precision format. */
struct
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:15;
unsigned int empty:16;
unsigned int mantissa0:32;
unsigned int mantissa1:32;
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_LITTLE_ENDIAN
+# if _IEEE754_FLOAT_WORD_ORDER == _IEEE754_BIG_ENDIAN
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
/* This is for NaNs in the IEEE 854 double-extended-precision format. */
struct
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_BIG_ENDIAN
unsigned int negative:1;
unsigned int exponent:15;
unsigned int empty:16;
unsigned int mantissa0:30;
unsigned int mantissa1:32;
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# if __FLOAT_WORD_ORDER == __BIG_ENDIAN
+#if _IEEE754_BYTE_ORDER == _IEEE754_LITTLE_ENDIAN
+# if _IEEE754_FLOAT_WORD_ORDER == _IEEE754_BIG_ENDIAN
unsigned int exponent:15;
unsigned int negative:1;
unsigned int empty:16;
#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* ieee754.h */
}
# endif
+# if defined __CYGWIN__
+ /* On Cygwin 3.3.6, readlink("/dev/null") returns "\\Device\\Null", which
+ is unusable. Better fail with EINVAL. */
+ if (r > 0 && strncmp (file, "/dev/", 5) == 0 && buf[0] == '\\')
+ {
+ errno = EINVAL;
+ return -1;
+ }
+# endif
+
return r;
}
}
# endif
+# if defined __CYGWIN__
+ /* On Cygwin 3.3.6, readlinkat(AT_FDCWD,"/dev/null") returns "\\Device\\Null",
+ which is unusable. Better fail with EINVAL. */
+ if (r > 0 && strncmp (file, "/dev/", 5) == 0 && buf[0] == '\\')
+ {
+ errno = EINVAL;
+ return -1;
+ }
+# endif
+
return r;
}
#define _@GUARD_PREFIX@_STDINT_H
/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
- LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
+ LONG_MIN, LONG_MAX, ULONG_MAX, CHAR_BIT, _GL_INTEGER_WIDTH. */
#include <limits.h>
/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
# define int64_t gl_int64_t
# define GL_INT64_T
# else
+/* Verify that 'long long' has exactly 64 bits. */
+typedef _gl_verify_int64_bits[
+ _STDINT_MAX (1, sizeof (long long) * CHAR_BIT, 0ll) >> 31 >> 31 == 1
+ ? 1 : -1];
# undef int64_t
typedef long long int gl_int64_t;
# define int64_t gl_int64_t
# define uint64_t gl_uint64_t
# define GL_UINT64_T
# else
+/* Verify that 'unsigned long long' has exactly 64 bits. */
+typedef _gl_verify_uint64_bits[
+ _STDINT_MAX (0, sizeof (unsigned long long) * CHAR_BIT, 0ull)
+ >> 31 >> 31 >> 1 == 1
+ ? 1 : -1];
# undef uint64_t
typedef unsigned long long int gl_uint64_t;
# define uint64_t gl_uint64_t
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
+/* Make sure that the macros that indicate the special invocation convention
+ get undefined. This is needed at least on CentOS 7. */
+#undef __need_malloc_and_calloc
+
#else
/* Normal invocation convention. */
cpy (am_len, a_month);
break;
#else
+# if defined _WIN32 && !defined __CYGWIN__
+ format_char = L_('b');
+# endif
goto underlying_strftime;
#endif
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
#elif USE_C_LOCALE && !HAVE_STRFTIME_L
subfmt = L_("%a %b %e %H:%M:%S %Y");
+#elif defined _WIN32 && !defined __CYGWIN__
+ /* On native Windows, "%c" is "%d/%m/%Y %H:%M:%S" by default. */
+ subfmt = L_("%a %b %e %H:%M:%S %Y");
#else
goto underlying_strftime;
#endif
#elif USE_C_LOCALE && !HAVE_STRFTIME_L
subfmt = L_("%I:%M:%S %p");
goto subformat;
-#elif (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__
- /* macOS, FreeBSD strftime() may produce empty output for "%r". */
+#elif (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || (defined _WIN32 && !defined __CYGWIN__)
+ /* macOS, FreeBSD, native Windows strftime() may produce empty output
+ for "%r". */
subfmt = L_("%I:%M:%S %p");
goto subformat;
#else
#if @GNULIB_GETUSERSHELL@
+# if @REPLACE_GETUSERSHELL@
/* Return the next valid login shell on the system, or NULL when the end of
the list has been reached. */
-# if !@HAVE_DECL_GETUSERSHELL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getusershell
+# define getusershell rpl_getusershell
+# endif
+_GL_FUNCDECL_RPL (getusershell, char *, (void));
+_GL_CXXALIAS_RPL (getusershell, char *, (void));
+# else
+# if !@HAVE_DECL_GETUSERSHELL@
_GL_FUNCDECL_SYS (getusershell, char *, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (getusershell, char *, (void));
+# endif
_GL_CXXALIASWARN (getusershell);
#elif defined GNULIB_POSIXCHECK
# undef getusershell
#if @GNULIB_GETUSERSHELL@
/* Rewind to pointer that is advanced at each getusershell() call. */
-# if !@HAVE_DECL_GETUSERSHELL@
+# if @REPLACE_GETUSERSHELL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef setusershell
+# define setusershell rpl_setusershell
+# endif
+_GL_FUNCDECL_RPL (setusershell, void, (void));
+_GL_CXXALIAS_RPL (setusershell, void, (void));
+# else
+# if !@HAVE_DECL_GETUSERSHELL@
_GL_FUNCDECL_SYS (setusershell, void, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (setusershell, void, (void));
+# endif
_GL_CXXALIASWARN (setusershell);
#elif defined GNULIB_POSIXCHECK
# undef setusershell
#if @GNULIB_GETUSERSHELL@
/* Free the pointer that is advanced at each getusershell() call and
associated resources. */
-# if !@HAVE_DECL_GETUSERSHELL@
+# if @REPLACE_GETUSERSHELL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef endusershell
+# define endusershell rpl_endusershell
+# endif
+_GL_FUNCDECL_RPL (endusershell, void, (void));
+_GL_CXXALIAS_RPL (endusershell, void, (void));
+# else
+# if !@HAVE_DECL_GETUSERSHELL@
_GL_FUNCDECL_SYS (endusershell, void, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (endusershell, void, (void));
+# endif
_GL_CXXALIASWARN (endusershell);
#elif defined GNULIB_POSIXCHECK
# undef endusershell
if (0 <= utimensat_works_really)
{
int result;
-# if __linux__ || __sun
+# if defined __linux__ || defined __sun || defined __NetBSD__
/* As recently as Linux kernel 2.6.32 (Dec 2009), several file
systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
but work if both times are either explicitly specified or
where UTIME_OMIT would have worked.
The same bug occurs in Solaris 11.1 (Apr 2013).
+ The same bug occurs in NetBSD 10.0 (May 2024).
FIXME: Simplify this in 2024, when these file system bugs are
no longer common on Gnulib target platforms. */
# endif
if (futimes (fd, t) == 0)
{
-# if __linux__ && __GLIBC__
+# if defined __linux__ && defined __GLIBC__
/* Work around a longstanding glibc bug, still present as
of 2010-12-27. On older Linux kernels that lack both
utimensat and utimes, glibc's futimes rounds instead of
if (0 <= lutimensat_works_really)
{
int result;
-# if __linux__ || __sun
+# if defined __linux__ || defined __sun || defined __NetBSD__
/* As recently as Linux kernel 2.6.32 (Dec 2009), several file
systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
but work if both times are either explicitly specified or
UTIME_OMIT would have worked.
The same bug occurs in Solaris 11.1 (Apr 2013).
+ The same bug occurs in NetBSD 10.0 (May 2024).
FIXME: Simplify this for Linux in 2016 and for Solaris in
2024, when file system bugs are no longer common. */
int flag)
# undef utimensat
{
-# if defined __linux__ || defined __sun
+# if defined __linux__ || defined __sun || defined __NetBSD__
struct timespec ts[2];
# endif
if (0 <= utimensat_works_really)
{
int result;
-# if defined __linux__ || defined __sun
+# if defined __linux__ || defined __sun || defined __NetBSD__
struct stat st;
/* As recently as Linux kernel 2.6.32 (Dec 2009), several file
systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
UTIME_OMIT would have worked.
The same bug occurs in Solaris 11.1 (Apr 2013).
+ The same bug occurs in NetBSD 10.0 (May 2024).
FIXME: Simplify this in 2024, when these file system bugs are
no longer common on Gnulib target platforms. */
ts[1] = times[1];
times = ts;
}
-# ifdef __hppa__
+# if defined __hppa__ || defined __NetBSD__
/* Linux kernel 2.6.22.19 on hppa does not reject invalid tv_nsec
- values. */
+ values.
+
+ The same bug occurs in NetBSD 10.0 (May 2024). */
else if (times
&& ((times[0].tv_nsec != UTIME_NOW
&& ! (0 <= times[0].tv_nsec
&& (!defined __cplusplus \
|| (__cpp_static_assert < 201411 \
&& __GNUG__ < 6 && __clang_major__ < 6 && _MSC_VER < 1910)))
-# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
+# if (defined __cplusplus && defined __GNUG__ && __GNUG__ < 6 \
+ && __cplusplus == 201103L && !defined __clang__)
+/* g++ >= 4.7, < 6 with option -std=c++11 or -std=gnu++11 supports the
+ two-arguments static_assert but not the one-argument static_assert, and
+ it does not support _Static_assert.
+ We have to play preprocessor tricks to distinguish the two cases. */
+# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
+# define _GL_SA2 static_assert
+# define _GL_SA3 static_assert
+# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
+# define static_assert(...) _GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1) (__VA_ARGS__)
+# elif defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
the one-argument static_assert, and it does not support _Static_assert.
We have to play preprocessor tricks to distinguish the two cases.
- Since the MSVC preprocessor is not ISO C compliant (see above),.
+ Since the MSVC preprocessor is not ISO C compliant (see above),
the solution is specific to MSVC. */
# define _GL_EXPAND(x) x
# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
--- /dev/null
+# endian_h.m4
+# serial 4
+dnl Copyright 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl A placeholder for <endian.h>, for platforms that have issues.
+
+AC_DEFUN_ONCE([gl_ENDIAN_H],
+[
+ AC_REQUIRE([gl_BIGENDIAN])
+
+ AC_CHECK_HEADERS_ONCE([endian.h])
+ gl_CHECK_NEXT_HEADERS([endian.h])
+ if test $ac_cv_header_endian_h = yes; then
+ HAVE_ENDIAN_H=1
+ dnl Check if endian.h defines uint16_t, uint32_t, and uint64_t.
+ AC_CACHE_CHECK([if endian.h defines stdint types],
+ [gl_cv_header_endian_h_stdint_types],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <endian.h>
+ ]],
+ [[uint16_t t1 = 0;
+ uint32_t t2 = 0;
+ uint64_t t3 = 0;
+ return !(t1 + t2 + t3);
+ ]])],
+ [gl_cv_header_endian_h_stdint_types=yes],
+ [gl_cv_header_endian_h_stdint_types=no])
+ ])
+ AC_CACHE_CHECK([if endian.h defines functions and macros],
+ [gl_cv_header_working_endian_h],
+ [gl_cv_header_working_endian_h=no
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+[[
+#include <endian.h>
+]],
+[[
+#if LITTLE_ENDIAN == BIG_ENDIAN
+# error "Endian macros not unique."
+#endif
+#if BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN
+# error "Byte order not defined."
+#endif
+
+/* Big endian to host. */
+int value16_1 = be16toh (0.0);
+int value32_1 = be32toh (0.0);
+int value64_1 = be64toh (0.0);
+
+/* Host to big endian. */
+int value16_2 = htobe16 (0.0);
+int value32_2 = htobe32 (0.0);
+int value64_2 = htobe64 (0.0);
+
+/* Little endian to host. */
+int value16_3 = le16toh (0.0);
+int value32_3 = le32toh (0.0);
+int value64_3 = le64toh (0.0);
+
+/* Host to little endian. */
+int value16_4 = htole16 (0.0);
+int value32_4 = htole32 (0.0);
+int value64_4 = htole64 (0.0);
+
+/* Make sure the variables get used. */
+return !(value16_1 + value32_1 + value64_1
+ + value16_2 + value32_2 + value64_2
+ + value16_3 + value32_3 + value64_3
+ + value16_4 + value32_4 + value64_4);
+]])],
+ [gl_cv_header_working_endian_h=yes],
+ [gl_cv_header_working_endian_h=no])
+ ])
+ else
+ HAVE_ENDIAN_H=0
+ fi
+
+ dnl Check if endian.h should be generated.
+ if test "$gl_cv_header_endian_h_stdint_types" = yes \
+ && test "$gl_cv_header_working_endian_h" = yes; then
+ GL_GENERATE_ENDIAN_H=false
+ else
+ GL_GENERATE_ENDIAN_H=true
+ fi
+
+ dnl Check if endian.h works but is missing types from stdint.h.
+ if test $GL_GENERATE_ENDIAN_H; then
+ if test "$gl_cv_header_working_endian_h" = yes; then
+ ENDIAN_H_JUST_MISSING_STDINT=1
+ else
+ ENDIAN_H_JUST_MISSING_STDINT=0
+ fi
+ else
+ ENDIAN_H_JUST_MISSING_STDINT=0
+ fi
+
+ AC_SUBST([HAVE_ENDIAN_H])
+ AC_SUBST([ENDIAN_H_JUST_MISSING_STDINT])
+])
# getopt.m4
-# serial 49
+# serial 50
dnl Copyright (C) 2002-2006, 2008-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,
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
[
- AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
- if test $ac_cv_header_sys_cdefs_h = yes; then
- HAVE_SYS_CDEFS_H=1
- else
- HAVE_SYS_CDEFS_H=0
- fi
- AC_SUBST([HAVE_SYS_CDEFS_H])
-
+ gl_CHECK_HEADER_SYS_CDEFS_H
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
[Define to rpl_ if the getopt replacement functions and variables
should be used.])
# gnulib-common.m4
-# serial 93
+# serial 95
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,
# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
+# define _GL_ATTR_reproducible 0 /* not yet supported, as of GCC 14 */
# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
+# define _GL_ATTR_unsequenced 0 /* not yet supported, as of GCC 14 */
# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
# endif
_GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
by the Nth argument of the function is the size of the returned memory block.
*/
-/* Applies to: function, pointer to function, function types. */
+/* Applies to: functions, pointer to functions, function types. */
#ifndef _GL_ATTRIBUTE_ALLOC_SIZE
# if _GL_HAS_ATTRIBUTE (alloc_size)
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
function and report an error if it cannot do so. */
-/* Applies to: function. */
+/* Applies to: functions. */
#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE
# if _GL_HAS_ATTRIBUTE (always_inline)
# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
in stack traces when debugging. The compiler should omit the function from
stack traces. */
-/* Applies to: function. */
+/* Applies to: functions. */
#ifndef _GL_ATTRIBUTE_ARTIFICIAL
# if _GL_HAS_ATTRIBUTE (artificial)
# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
# endif
#endif
-/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
- calls to the function with the same arguments.
- This attribute is safe for a function that neither depends on nor affects
- observable state, and always returns exactly once - e.g., does not loop
- forever, and does not call longjmp.
- (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */
+/* _GL_ATTRIBUTE_CONST declares:
+ It is OK for a compiler to move calls to the function and to omit
+ calls to the function if another call has the same arguments or the
+ result is not used.
+ This attribute is safe for a function that neither depends on
+ nor affects state, and always returns exactly once -
+ e.g., does not raise an exception, call longjmp, or loop forever.
+ (This attribute is stricter than _GL_ATTRIBUTE_PURE because the
+ function cannot observe state. It is stricter than
+ _GL_ATTRIBUTE_UNSEQUENCED because the function must return exactly
+ once and cannot depend on state addressed by its arguments.) */
/* Applies to: functions. */
#ifndef _GL_ATTRIBUTE_CONST
# if _GL_HAS_ATTRIBUTE (const)
# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
# else
-# define _GL_ATTRIBUTE_CONST
+# define _GL_ATTRIBUTE_CONST _GL_ATTRIBUTE_UNSEQUENCED
# endif
#endif
minimizing the memory required. */
/* Applies to: struct members, struct, union,
in C++ also: class. */
+#ifndef _GL_ATTRIBUTE_PACKED
/* Oracle Studio 12.6 miscompiles code with __attribute__ ((__packed__)) despite
__has_attribute OK. */
-#ifndef _GL_ATTRIBUTE_PACKED
# if _GL_HAS_ATTRIBUTE (packed) && !defined __SUNPRO_C
# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
# else
# endif
#endif
-/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
- calls to the function with the same arguments if observable state is not
- changed between calls.
- This attribute is safe for a function that does not affect
- observable state, and always returns exactly once.
- (This attribute is looser than _GL_ATTRIBUTE_CONST.) */
+/* _GL_ATTRIBUTE_PURE declares:
+ It is OK for a compiler to move calls to the function and to omit
+ calls to the function if another call has the same arguments or the
+ result is not used, and if observable state is the same.
+ This attribute is safe for a function that does not affect observable state
+ and always returns exactly once.
+ (This attribute is looser than _GL_ATTRIBUTE_CONST because the function
+ can depend on observable state. It is stricter than
+ _GL_ATTRIBUTE_REPRODUCIBLE because the function must return exactly
+ once and cannot affect state addressed by its arguments.) */
/* Applies to: functions. */
#ifndef _GL_ATTRIBUTE_PURE
# if _GL_HAS_ATTRIBUTE (pure)
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
-# define _GL_ATTRIBUTE_PURE
+# define _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_REPRODUCIBLE
+# endif
+#endif
+
+/* _GL_ATTRIBUTE_REPRODUCIBLE declares:
+ It is OK for a compiler to move calls to the function and to omit duplicate
+ calls to the function with the same arguments, so long as the state
+ addressed by its arguments is the same and is updated in time for
+ the rest of the program.
+ This attribute is safe for a function that is effectless and idempotent; see
+ ISO C 23 § 6.7.12.7 for a definition of these terms.
+ (This attribute is looser than _GL_ATTRIBUTE_UNSEQUENCED because
+ the function need not be stateless and idempotent. It is looser
+ than _GL_ATTRIBUTE_PURE because the function need not return
+ exactly once and can affect state addressed by its arguments.)
+ See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
+ <https://stackoverflow.com/questions/76847905/>. */
+/* Applies to: functions, pointer to functions, function types. */
+#ifndef _GL_ATTRIBUTE_REPRODUCIBLE
+/* This may be revisited when gcc and clang support [[reproducible]] or possibly
+ __attribute__ ((__reproducible__)). */
+# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
+# if _GL_HAS_ATTRIBUTE (reproducible)
+# define _GL_ATTRIBUTE_REPRODUCIBLE [[reproducible]]
+# endif
+# endif
+# ifndef _GL_ATTRIBUTE_REPRODUCIBLE
+# define _GL_ATTRIBUTE_REPRODUCIBLE
# endif
#endif
# endif
#endif
+/* _GL_ATTRIBUTE_UNSEQUENCED declares:
+ It is OK for a compiler to move calls to the function and to omit duplicate
+ calls to the function with the same arguments, so long as the state
+ addressed by its arguments is the same.
+ This attribute is safe for a function that is effectless, idempotent,
+ stateless, and independent; see ISO C 23 § 6.7.12.7 for a definition of
+ these terms.
+ (This attribute is stricter than _GL_ATTRIBUTE_REPRODUCIBLE because
+ the function must be stateless and independent. It is looser than
+ _GL_ATTRIBUTE_CONST because the function need not return exactly
+ once and can depend on state addressed by its arguments.)
+ See also <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2956.htm> and
+ <https://stackoverflow.com/questions/76847905/>. */
+/* Applies to: functions, pointer to functions, function types. */
+#ifndef _GL_ATTRIBUTE_UNSEQUENCED
+/* This may be revisited when gcc and clang support [[unsequenced]] or possibly
+ __attribute__ ((__unsequenced__)). */
+# ifndef _GL_BRACKET_BEFORE_ATTRIBUTE
+# if _GL_HAS_ATTRIBUTE (unsequenced)
+# define _GL_ATTRIBUTE_UNSEQUENCED [[unsequenced]]
+# endif
+# endif
+# ifndef _GL_ATTRIBUTE_UNSEQUENCED
+# define _GL_ATTRIBUTE_UNSEQUENCED
+# endif
+#endif
+
/* A helper macro. Don't use it directly. */
#ifndef _GL_ATTRIBUTE_UNUSED
# if _GL_HAS_ATTRIBUTE (unused)
# Code from module dtotimespec:
# Code from module dup2:
# Code from module eloop-threshold:
+ # Code from module endian:
# Code from module environ:
# Code from module errno:
# Code from module euidaccess:
gl_gnulib_enabled_cloexec=false
gl_gnulib_enabled_dirfd=false
gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c=false
+ gl_gnulib_enabled_endian=false
gl_gnulib_enabled_euidaccess=false
gl_gnulib_enabled_getdelim=false
gl_gnulib_enabled_getdtablesize=false
gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c=true
fi
}
+ func_gl_gnulib_m4code_endian ()
+ {
+ if $gl_gnulib_enabled_endian; then :; else
+ gl_ENDIAN_H
+ gl_CONDITIONAL_HEADER([endian.h])
+ AC_PROG_MKDIR_P
+ gl_gnulib_enabled_endian=true
+ fi
+ }
func_gl_gnulib_m4code_euidaccess ()
{
if $gl_gnulib_enabled_euidaccess; then :; else
if case $host_os in mingw* | windows*) false;; *) test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1;; esac; then
func_gl_gnulib_m4code_open
fi
+ if $GL_GENERATE_IEEE754_H; then
+ func_gl_gnulib_m4code_endian
+ fi
if test $REPLACE_MKTIME = 1; then
func_gl_gnulib_m4code_verify
fi
AM_CONDITIONAL([gl_GNULIB_ENABLED_cloexec], [$gl_gnulib_enabled_cloexec])
AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd])
AM_CONDITIONAL([gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c], [$gl_gnulib_enabled_925677f0343de64b89a9f0c790b4104c])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_endian], [$gl_gnulib_enabled_endian])
AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess])
AM_CONDITIONAL([gl_GNULIB_ENABLED_getdelim], [$gl_gnulib_enabled_getdelim])
AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize])
lib/dup2.c
lib/dynarray.h
lib/eloop-threshold.h
+ lib/endian.c
+ lib/endian.in.h
lib/errno.in.h
lib/euidaccess.c
lib/execinfo.c
m4/double-slash-root.m4
m4/dup2.m4
m4/eealloc.m4
+ m4/endian_h.m4
m4/environ.m4
m4/errno_h.m4
m4/euidaccess.m4
m4/strtoimax.m4
m4/strtoll.m4
m4/symlink.m4
+ m4/sys_cdefs_h.m4
m4/sys_random_h.m4
m4/sys_select_h.m4
m4/sys_socket_h.m4
# readlink.m4
-# serial 17
+# serial 18
dnl Copyright (C) 2003, 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,
AC_DEFUN([gl_FUNC_READLINK],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_CHECK_FUNCS_ONCE([readlink])
if test $ac_cv_func_readlink = no; then
HAVE_READLINK=0
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <unistd.h>
- /* Cause compilation failure if original declaration has wrong type. */
- ssize_t readlink (const char *, char *, size_t);]])],
+ /* Cause compilation failure if original declaration has
+ wrong type. */
+ ssize_t readlink (const char *, char *, size_t);
+ ]])
+ ],
[gl_cv_decl_readlink_works=yes], [gl_cv_decl_readlink_works=no])])
+
dnl Solaris 9 ignores trailing slash.
dnl FreeBSD 7.2 dereferences only one level of links with trailing slash.
AC_CACHE_CHECK([whether readlink handles trailing slash correctly],
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <unistd.h>
-]], [[char buf[20];
- return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;]])],
+ ]],
+ [[char buf[20];
+ return readlink ("conftest.lnk2/", buf, sizeof buf) != -1;
+ ]])
+ ],
[gl_cv_func_readlink_trailing_slash=yes],
[gl_cv_func_readlink_trailing_slash=no],
[case "$host_os" in
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <unistd.h>
-]], [[char c;
- return readlink ("conftest.link", &c, 1) != 1;]])],
+ ]],
+ [[char c;
+ return readlink ("conftest.link", &c, 1) != 1;
+ ]])
+ ],
[gl_cv_func_readlink_truncate=yes],
[gl_cv_func_readlink_truncate=no],
[case "$host_os" in
REPLACE_READLINK=1
;;
esac
+
+ dnl On Cygwin 3.3.6, readlink("/dev/null") returns "\\Device\\Null", which
+ dnl is unusable.
+ case "$host_os" in
+ cygwin*)
+ REPLACE_READLINK=1
+ ;;
+ esac
fi
])
# readlinkat.m4
-# serial 8
+# serial 9
dnl Copyright (C) 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,
[AC_LANG_PROGRAM(
[[#include <unistd.h>
/* Check whether original declaration has correct type. */
- ssize_t readlinkat (int, char const *, char *, size_t);]])],
+ ssize_t readlinkat (int, char const *, char *, size_t);
+ ]])
+ ],
[gl_cv_decl_readlinkat_works=yes],
- [gl_cv_decl_readlinkat_works=no])])
+ [gl_cv_decl_readlinkat_works=no])
+ ])
# Assume readlinkat has the same bugs as readlink,
# as is the case on OS X 10.10 with trailing slashes.
case $gl_cv_decl_readlinkat_works,$gl_cv_func_readlink_trailing_slash,$gl_cv_func_readlink_truncate in
REPLACE_READLINKAT=1
;;
esac
+
+ dnl On Cygwin 3.3.6, readlinkat(AT_FDCWD,"/dev/null") returns
+ dnl "\\Device\\Null", which is unusable.
+ case "$host_os" in
+ cygwin*)
+ REPLACE_READLINKAT=1
+ ;;
+ esac
fi
])
--- /dev/null
+# sys_cdefs_h.m4 - Is <sys/cdefs.h> compatible enough with glibc?
+# serial 2
+dnl Copyright 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,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+AC_DEFUN_ONCE([gl_CHECK_HEADER_SYS_CDEFS_H],
+ [AC_CACHE_CHECK([for glibc-compatible sys/cdefs.h],
+ [gl_cv_header_sys_cdefs_h],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_DEFINES_PROVIDED
+ [#include <sys/cdefs.h>
+ enum { foo = __GNUC_PREREQ (14, 1) } bar;
+ ]],
+ [gl_cv_header_sys_cdefs_h=yes],
+ [gl_cv_header_sys_cdefs_h=no])])
+ if test "$gl_cv_header_sys_cdefs_h" = yes; then
+ HAVE_SYS_CDEFS_H=1
+ else
+ HAVE_SYS_CDEFS_H=0
+ fi
+ AC_SUBST([HAVE_SYS_CDEFS_H])])
# unistd_h.m4
-# serial 95
+# serial 96
dnl Copyright (C) 2006-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,
REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS])
REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
+ REPLACE_GETUSERSHELL=0; AC_SUBST([REPLACE_GETUSERSHELL])
REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])