1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Update from Gnulib by running admin/merge-gnulib

* admin/merge-gnulib (AVOIDED_MODULES): Avoid gnulib-i18n.
* lib/stdlib.c, m4/selinux-selinux-h.m4:
New files, taken from Gnulib.
This commit is contained in:
Paul Eggert 2024-12-17 14:02:41 -08:00
parent 22806c65f4
commit b1e5f6d6ef
172 changed files with 1541 additions and 667 deletions

View file

@ -53,7 +53,7 @@ GNULIB_MODULES='
' '
AVOIDED_MODULES=' AVOIDED_MODULES='
access btowc chmod close crypto/af_alg dup fchdir fstat access btowc chmod close crypto/af_alg dup fchdir fstat gnulib-i18n
iswblank iswctype iswdigit iswxdigit langinfo libgmp-mpq iswblank iswctype iswdigit iswxdigit langinfo libgmp-mpq
localename-unsafe-limited lock localename-unsafe-limited lock
mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# install - install a program, script, or datafile # install - install a program, script, or datafile
scriptversion=2024-06-19.01; # UTC scriptversion=2024-12-03.03; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was # This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the # later released in X11R6 (xc/config/util/install.sh) with the
@ -533,7 +533,7 @@ do
done done
# Local variables: # Local variables:
# eval: (add-hook 'before-save-hook 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0" # time-stamp-time-zone: "UTC0"

View file

@ -19,10 +19,12 @@
#include <config.h> #include <config.h>
#include "acl.h" /* Specification. */
#define ACL_INTERNAL_INLINE _GL_EXTERN_INLINE
#include "acl-internal.h" #include "acl-internal.h"
#include "acl.h"
#if defined __CYGWIN__ #if defined __CYGWIN__
# include <sys/types.h> # include <sys/types.h>
# include <grp.h> # include <grp.h>

View file

@ -32,9 +32,68 @@
extern "C" { extern "C" {
#endif #endif
/* file_has_acl flags guaranteed to not collide with any <dirent.h>
DT_* or _GL_DT_* value. */
enum
{
/* Get scontext information as well. */
ACL_GET_SCONTEXT = 0x10000,
/* Follow symlinks. */
ACL_SYMLINK_FOLLOW = 0x20000,
};
/* Information about an ACL. */
struct aclinfo
{
/* If 'size' is nonnegative, a buffer holding the concatenation
of extended attribute names, each terminated by NUL
(either u.__gl_acl_ch, or heap-allocated). */
char *buf;
/* The number of useful bytes at the start of buf, counting trailing NULs.
If negative, there was an error in getting the ACL info,
and u.err is the corresponding errno. */
ssize_t size;
/* Security context string. Do not modify its contents. */
char *scontext;
/* Security context errno value. It is zero if there was no
error getting the security context. When nonzero, scontext is "?". */
int scontext_err;
union
{
/* An errno value, when there was an error getting the ACL info. */
int err;
/* A small array of char, big enough for most listxattr results.
The size is somewhat arbitrary; it equals the max length of a
trivial NFSv4 ACL (a size used by file-has-acl.c in 2023-2024
but no longer relevant now), and a different value might be
better once experience is gained. For internal use only. */
char __gl_acl_ch[152];
} u;
};
bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST; bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST;
int file_has_acl (char const *, struct stat const *); int file_has_acl (char const *, struct stat const *);
int file_has_aclinfo (char const *restrict, struct aclinfo *restrict, int);
#if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR
bool aclinfo_has_xattr (struct aclinfo const *, char const *)
_GL_ATTRIBUTE_PURE;
void aclinfo_free (struct aclinfo *);
#else
# define aclinfo_has_xattr(ai, xattr) false
# define aclinfo_free(ai) ((void) 0)
#endif
#if (HAVE_LINUX_XATTR_H && HAVE_LISTXATTR \
&& (HAVE_SMACK || USE_SELINUX_SELINUX_H))
void aclinfo_scontext_free (char *);
#else
# define aclinfo_scontext_free(s) ((void) 0)
#endif
int qset_acl (char const *, int, mode_t); int qset_acl (char const *, int, mode_t);
int xset_acl (char const *, int, mode_t); int xset_acl (char const *, int, mode_t);

View file

@ -46,20 +46,95 @@ struct dirent
char d_type; char d_type;
char d_name[1]; char d_name[1];
}; };
/* Possible values for 'd_type'. */
# define DT_UNKNOWN 0
# define DT_FIFO 1 /* FIFO */
# define DT_CHR 2 /* character device */
# define DT_DIR 4 /* directory */
# define DT_BLK 6 /* block device */
# define DT_REG 8 /* regular file */
# define DT_LNK 10 /* symbolic link */
# define DT_SOCK 12 /* socket */
# define DT_WHT 14 /* whiteout */
# define GNULIB_defined_struct_dirent 1 # define GNULIB_defined_struct_dirent 1
# endif # endif
#endif #endif
/* 'd_type' macros specified in GNU, i.e., POSIX.1-2024 plus DT_WHT,
but not (yet) DT_MQ, DT_SEM, DT_SHM, DT_TMO.
These macros can be useful even on platforms that do not support
d_type or the corresponding file types.
The values of these macros are all in the 'unsigned char' range.
Default to the Linux values which are also popular elsewhere,
and check that all macros have distinct values. */
#ifndef DT_UNKNOWN
# define DT_UNKNOWN 0
#endif
#ifndef DT_FIFO
# define DT_FIFO 1 /* FIFO */
#endif
#ifndef DT_CHR
# define DT_CHR 2 /* character device */
#endif
#ifndef DT_DIR
# define DT_DIR 4 /* directory */
#endif
#ifndef DT_BLK
# define DT_BLK 6 /* block device */
#endif
#ifndef DT_REG
# define DT_REG 8 /* regular file */
#endif
#ifndef DT_LNK
# define DT_LNK 10 /* symbolic link */
#endif
#ifndef DT_SOCK
# define DT_SOCK 12 /* socket */
#endif
#ifndef DT_WHT
# define DT_WHT 14 /* whiteout */
#endif
static_assert (DT_UNKNOWN != DT_FIFO && DT_UNKNOWN != DT_CHR
&& DT_UNKNOWN != DT_BLK && DT_UNKNOWN != DT_REG
&& DT_UNKNOWN != DT_LNK && DT_UNKNOWN != DT_SOCK
&& DT_UNKNOWN != DT_WHT
&& DT_FIFO != DT_CHR && DT_FIFO != DT_BLK && DT_FIFO != DT_REG
&& DT_FIFO != DT_LNK && DT_FIFO != DT_SOCK && DT_FIFO != DT_WHT
&& DT_CHR != DT_BLK && DT_CHR != DT_REG && DT_CHR != DT_LNK
&& DT_CHR != DT_SOCK && DT_CHR != DT_WHT
&& DT_BLK != DT_REG && DT_BLK != DT_LNK && DT_BLK != DT_SOCK
&& DT_BLK != DT_WHT
&& DT_REG != DT_LNK && DT_REG != DT_SOCK && DT_REG != DT_WHT
&& DT_LNK != DT_SOCK && DT_LNK != DT_WHT
&& DT_SOCK != DT_WHT);
/* Other optional information about a directory entry. */
#define _GL_DT_NOTDIR 0x100 /* Not a directory */
/* Conversion between S_IF* and DT_* file types. */
#if ! (defined IFTODT && defined DTTOIF)
# include <sys/stat.h>
# ifdef S_ISWHT
# define _GL_DIRENT_S_ISWHT(mode) S_ISWHT(mode)
# else
# define _GL_DIRENT_S_ISWHT(mode) 0
# endif
# ifdef S_IFWHT
# define _GL_DIRENT_S_IFWHT S_IFWHT
# else
# define _GL_DIRENT_S_IFWHT (DT_WHT << 12) /* just a guess */
# endif
#endif
/* Conversion from a 'stat' mode to a DT_* value. */
#ifndef IFTODT
# define IFTODT(mode) \
(S_ISREG (mode) ? DT_REG : S_ISDIR (mode) ? DT_DIR \
: S_ISLNK (mode) ? DT_LNK : S_ISBLK (mode) ? DT_BLK \
: S_ISCHR (mode) ? DT_CHR : S_ISFIFO (mode) ? DT_FIFO \
: S_ISSOCK (mode) ? DT_SOCK \
: _GL_DIRENT_S_ISWHT (mode) ? DT_WHT : DT_UNKNOWN)
#endif
/* Conversion from a DT_* value to a 'stat' mode. */
#ifndef DTTOIF
# define DTTOIF(dirtype) \
((dirtype) == DT_REG ? S_IFREG : (dirtype) == DT_DIR ? S_IFDIR \
: (dirtype) == DT_LNK ? S_IFLNK : (dirtype) == DT_BLK ? S_IFBLK \
: (dirtype) == DT_CHR ? S_IFCHR : dirtype == DT_FIFO ? S_IFIFO \
: (dirtype) == DT_SOCK ? S_IFSOCK \
: (dirtype) == DT_WHT ? _GL_DIRENT_S_IFWHT \
: (dirtype) << 12 /* just a guess */)
#endif
#if !@DIR_HAS_FD_MEMBER@ #if !@DIR_HAS_FD_MEMBER@
# if !GNULIB_defined_DIR # if !GNULIB_defined_DIR
/* struct gl_directory is a type with a field 'int fd_to_close'. /* struct gl_directory is a type with a field 'int fd_to_close'.

View file

@ -27,12 +27,30 @@
#include "acl.h" #include "acl.h"
#include <dirent.h>
#include <limits.h>
#include "acl-internal.h" #include "acl-internal.h"
#include "attribute.h" #include "attribute.h"
#include "minmax.h" #include "minmax.h"
#if USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR /* Check the assumption that UCHAR_MAX < INT_MAX. */
static_assert (ACL_SYMLINK_FOLLOW & ~ (unsigned char) -1);
static char const UNKNOWN_SECURITY_CONTEXT[] = "?";
#if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR
# define USE_LINUX_XATTR true
#else
# define USE_LINUX_XATTR false
#endif
#if USE_LINUX_XATTR
# if USE_SELINUX_SELINUX_H
# include <selinux/selinux.h>
# endif
# include <stdckdint.h> # include <stdckdint.h>
# include <stdint.h>
# include <string.h> # include <string.h>
# include <arpa/inet.h> # include <arpa/inet.h>
# include <sys/xattr.h> # include <sys/xattr.h>
@ -47,26 +65,186 @@
# define XATTR_NAME_POSIX_ACL_DEFAULT "system.posix_acl_default" # define XATTR_NAME_POSIX_ACL_DEFAULT "system.posix_acl_default"
# endif # endif
# ifdef HAVE_SMACK
# include <sys/smack.h>
# else
static char const *
smack_smackfs_path (void)
{
return NULL;
}
static ssize_t
smack_new_label_from_path (MAYBE_UNUSED const char *path,
MAYBE_UNUSED const char *xattr,
MAYBE_UNUSED int follow, MAYBE_UNUSED char **label)
{
return -1;
}
# endif
static bool
is_smack_enabled (void)
{
return !!smack_smackfs_path ();
}
enum { enum {
/* ACE4_ACCESS_ALLOWED_ACE_TYPE = 0x00000000, */ /* ACE4_ACCESS_ALLOWED_ACE_TYPE = 0x00000000, */
ACE4_ACCESS_DENIED_ACE_TYPE = 0x00000001, ACE4_ACCESS_DENIED_ACE_TYPE = 0x00000001,
ACE4_IDENTIFIER_GROUP = 0x00000040 ACE4_IDENTIFIER_GROUP = 0x00000040
}; };
/* Return true if ATTR is in the set represented by the NUL-terminated /* Does AI's xattr set contain XATTR? */
strings in LISTBUF, which is of size LISTSIZE. */
ATTRIBUTE_PURE static bool bool
have_xattr (char const *attr, char const *listbuf, ssize_t listsize) aclinfo_has_xattr (struct aclinfo const *ai, char const *xattr)
{ {
char const *blim = listbuf + listsize; if (0 < ai->size)
for (char const *b = listbuf; b < blim; b += strlen (b) + 1) {
for (char const *a = attr; *a == *b; a++, b++) char const *blim = ai->buf + ai->size;
for (char const *b = ai->buf; b < blim; b += strlen (b) + 1)
for (char const *a = xattr; *a == *b; a++, b++)
if (!*a) if (!*a)
return true; return true;
}
return false; return false;
} }
/* Get attributes of the file NAME into AI, if USE_ACL.
If FLAGS & ACL_GET_SCONTEXT, also get security context.
If FLAGS & ACL_SYMLINK_FOLLOW, follow symbolic links. */
static void
get_aclinfo (char const *name, struct aclinfo *ai, int flags)
{
int scontext_err = ENOTSUP;
ai->buf = ai->u.__gl_acl_ch;
ssize_t acl_alloc = sizeof ai->u.__gl_acl_ch;
if (! (USE_ACL || flags & ACL_GET_SCONTEXT))
ai->size = 0;
else
{
ssize_t (*lsxattr) (char const *, char *, size_t)
= (flags & ACL_SYMLINK_FOLLOW ? listxattr : llistxattr);
while (true)
{
ai->size = lsxattr (name, ai->buf, acl_alloc);
if (0 < ai->size)
break;
ai->u.err = ai->size < 0 ? errno : 0;
if (! (ai->size < 0 && ai->u.err == ERANGE && acl_alloc < SSIZE_MAX))
break;
/* The buffer was too small. Find how large it should have been. */
ssize_t size = lsxattr (name, NULL, 0);
if (size <= 0)
{
ai->size = size;
ai->u.err = size < 0 ? errno : 0;
break;
}
/* Grow allocation to at least 'size'. Grow it by a nontrivial
amount, to defend against denial of service by an adversary
that fiddles with ACLs. */
if (ai->buf != ai->u.__gl_acl_ch)
{
free (ai->buf);
ai->buf = ai->u.__gl_acl_ch;
}
if (ckd_add (&acl_alloc, acl_alloc, acl_alloc >> 1))
acl_alloc = SSIZE_MAX;
if (acl_alloc < size)
acl_alloc = size;
if (SIZE_MAX < acl_alloc)
{
ai->u.err = ENOMEM;
break;
}
char *newbuf = malloc (acl_alloc);
if (!newbuf)
{
ai->u.err = errno;
break;
}
ai->buf = newbuf;
}
}
if (0 < ai->size && flags & ACL_GET_SCONTEXT)
{
if (is_smack_enabled ())
{
if (aclinfo_has_xattr (ai, XATTR_NAME_SMACK))
{
ssize_t r = smack_new_label_from_path (name, "security.SMACK64",
flags & ACL_SYMLINK_FOLLOW,
&ai->scontext);
scontext_err = r < 0 ? errno : 0;
}
}
else
{
# if USE_SELINUX_SELINUX_H
if (aclinfo_has_xattr (ai, XATTR_NAME_SELINUX))
{
ssize_t r =
((flags & ACL_SYMLINK_FOLLOW ? getfilecon : lgetfilecon)
(name, &ai->scontext));
scontext_err = r < 0 ? errno : 0;
# ifndef SE_SELINUX_INLINE
/* Gnulib's selinux-h module is not in use, so getfilecon and
lgetfilecon can misbehave, be it via an old version of
libselinux where these would return 0 and set the result
context to NULL, or via a modern kernel+lib operating on a
file from a disk whose attributes were set by a kernel from
around 2006. In that latter case, the functions return a
length of 10 for the "unlabeled" context. Map both failures
to a return value of -1, and set errno to ENOTSUP in the
first case, and ENODATA in the latter. */
if (r == 0)
scontext_err = ENOTSUP;
if (r == 10 && memcmp (ai->scontext, "unlabeled", 10) == 0)
{
freecon (ai->scontext);
scontext_err = ENODATA;
}
# endif
}
# endif
}
}
ai->scontext_err = scontext_err;
if (scontext_err)
ai->scontext = (char *) UNKNOWN_SECURITY_CONTEXT;
}
# ifndef aclinfo_scontext_free
/* Free the pointer that file_has_aclinfo put into scontext.
However, do nothing if the argument is a null pointer;
This lets the caller replace the scontext member with a null pointer if it
is willing to own the member and call this function later. */
void
aclinfo_scontext_free (char *scontext)
{
if (scontext != UNKNOWN_SECURITY_CONTEXT)
{
if (is_smack_enabled ())
free (scontext);
else if (scontext)
freecon (scontext);
}
}
# endif
/* Free AI's heap storage. */
void
aclinfo_free (struct aclinfo *ai)
{
if (ai->buf != ai->u.__gl_acl_ch)
free (ai->buf);
aclinfo_scontext_free (ai->scontext);
}
/* Return 1 if given ACL in XDR format is non-trivial, 0 if it is trivial. /* Return 1 if given ACL in XDR format is non-trivial, 0 if it is trivial.
-1 upon failure to determine it. Possibly change errno. Assume that -1 upon failure to determine it. Possibly change errno. Assume that
the ACL is valid, except avoid undefined behavior even if invalid. the ACL is valid, except avoid undefined behavior even if invalid.
@ -150,131 +328,98 @@ acl_nfs4_nontrivial (uint32_t *xattr, ssize_t nbytes)
0 if ACLs are not supported, or if NAME has no or only a base ACL, 0 if ACLs are not supported, or if NAME has no or only a base ACL,
and -1 (setting errno) on error. Note callers can determine and -1 (setting errno) on error. Note callers can determine
if ACLs are not supported as errno is set in that case also. if ACLs are not supported as errno is set in that case also.
SB must be set to the stat buffer of NAME, Set *AI to ACL info regardless of return value.
obtained through stat() or lstat(). */ FLAGS should be a <dirent.h> d_type value, optionally ORed with
- _GL_DT_NOTDIR if it is known that NAME is not a directory,
- ACL_GET_SCONTEXT to retrieve security context and return 1 if present,
- ACL_SYMLINK_FOLLOW to follow the link if NAME is a symbolic link;
otherwise do not follow them if possible.
If the d_type value is not known, use DT_UNKNOWN though this may be less
efficient. */
int int
file_has_acl (char const *name, struct stat const *sb) file_has_aclinfo (MAYBE_UNUSED char const *restrict name,
{ struct aclinfo *restrict ai, int flags)
#if USE_ACL
if (! S_ISLNK (sb->st_mode))
{ {
MAYBE_UNUSED unsigned char d_type = flags & UCHAR_MAX;
# if HAVE_LINUX_XATTR_H && HAVE_LISTXATTR #if USE_LINUX_XATTR
int initial_errno = errno; int initial_errno = errno;
get_aclinfo (name, ai, flags);
/* The max length of a trivial NFSv4 ACL is 6 words for owner, if (ai->size <= 0)
6 for group, 7 for everyone, all times 2 because there are
both allow and deny ACEs. There are 6 words for owner
because of type, flag, mask, wholen, "OWNER@"+pad and
similarly for group; everyone is another word to hold
"EVERYONE@". */
typedef uint32_t trivial_NFSv4_xattr_buf[2 * (6 + 6 + 7)];
/* A buffer large enough to hold any trivial NFSv4 ACL,
and also useful as a small array of char. */
union {
trivial_NFSv4_xattr_buf xattr;
char ch[sizeof (trivial_NFSv4_xattr_buf)];
} stackbuf;
char *listbuf = stackbuf.ch;
ssize_t listbufsize = sizeof stackbuf.ch;
char *heapbuf = NULL;
ssize_t listsize;
/* Use listxattr first, as this means just one syscall in the
typical case where the file lacks an ACL. Try stackbuf
first, falling back on malloc if stackbuf is too small. */
while ((listsize = listxattr (name, listbuf, listbufsize)) < 0
&& errno == ERANGE)
{ {
free (heapbuf); errno = ai->size < 0 ? ai->u.err : initial_errno;
ssize_t newsize = listxattr (name, NULL, 0); return ai->size;
if (newsize <= 0)
return newsize;
/* Grow LISTBUFSIZE to at least NEWSIZE. Grow it by a
nontrivial amount too, to defend against denial of
service by an adversary that fiddles with ACLs. */
bool overflow = ckd_add (&listbufsize, listbufsize, listbufsize >> 1);
listbufsize = MAX (listbufsize, newsize);
if (overflow || SIZE_MAX < listbufsize)
{
errno = ENOMEM;
return -1;
}
listbuf = heapbuf = malloc (listbufsize);
if (!listbuf)
return -1;
} }
/* In Fedora 39, a file can have both NFSv4 and POSIX ACLs, /* In Fedora 39, a file can have both NFSv4 and POSIX ACLs,
but if it has an NFSv4 ACL that's the one that matters. but if it has an NFSv4 ACL that's the one that matters.
In earlier Fedora the two types of ACLs were mutually exclusive. In earlier Fedora the two types of ACLs were mutually exclusive.
Attempt to work correctly on both kinds of systems. */ Attempt to work correctly on both kinds of systems. */
bool nfsv4_acl
= 0 < listsize && have_xattr (XATTR_NAME_NFSV4_ACL, listbuf, listsize);
int ret
= (listsize <= 0 ? listsize
: (nfsv4_acl
|| have_xattr (XATTR_NAME_POSIX_ACL_ACCESS, listbuf, listsize)
|| (S_ISDIR (sb->st_mode)
&& have_xattr (XATTR_NAME_POSIX_ACL_DEFAULT,
listbuf, listsize))));
free (heapbuf);
/* If there is an NFSv4 ACL, follow up with a getxattr syscall if (!aclinfo_has_xattr (ai, XATTR_NAME_NFSV4_ACL))
to see whether the NFSv4 ACL is nontrivial. */ return
if (nfsv4_acl) (aclinfo_has_xattr (ai, XATTR_NAME_POSIX_ACL_ACCESS)
{ || ((d_type == DT_DIR || d_type == DT_UNKNOWN)
ret = getxattr (name, XATTR_NAME_NFSV4_ACL, && aclinfo_has_xattr (ai, XATTR_NAME_POSIX_ACL_DEFAULT)));
stackbuf.xattr, sizeof stackbuf.xattr);
/* A buffer large enough to hold any trivial NFSv4 ACL.
The max length of a trivial NFSv4 ACL is 6 words for owner,
6 for group, 7 for everyone, all times 2 because there are both
allow and deny ACEs. There are 6 words for owner because of
type, flag, mask, wholen, "OWNER@"+pad and similarly for group;
everyone is another word to hold "EVERYONE@". */
uint32_t buf[2 * (6 + 6 + 7)];
int ret = ((flags & ACL_SYMLINK_FOLLOW ? getxattr : lgetxattr)
(name, XATTR_NAME_NFSV4_ACL, buf, sizeof buf));
if (ret < 0) if (ret < 0)
switch (errno) switch (errno)
{ {
case ENODATA: return 0; case ENODATA: return 0;
case ERANGE : return 1; /* ACL must be nontrivial. */ case ERANGE : return 1; /* ACL must be nontrivial. */
default: return - acl_errno_valid (errno);
} }
else
{
/* It looks like a trivial ACL, but investigate further. */ /* It looks like a trivial ACL, but investigate further. */
ret = acl_nfs4_nontrivial (stackbuf.xattr, ret); ret = acl_nfs4_nontrivial (buf, ret);
if (ret < 0) errno = ret < 0 ? EINVAL : initial_errno;
return ret;
#else /* !USE_LINUX_XATTR */
ai->buf = ai->u.__gl_acl_ch;
ai->size = -1;
ai->u.err = ENOTSUP;
ai->scontext = (char *) UNKNOWN_SECURITY_CONTEXT;
ai->scontext_err = ENOTSUP;
# if USE_ACL
# if HAVE_ACL_GET_FILE
{ {
errno = EINVAL;
return ret;
}
errno = initial_errno;
}
}
if (ret < 0)
return - acl_errno_valid (errno);
return ret;
# elif HAVE_ACL_GET_FILE
/* POSIX 1003.1e (draft 17 -- abandoned) specific version. */ /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
/* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ /* Linux, FreeBSD, NetBSD >= 10, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */
int ret; int ret;
if (HAVE_ACL_EXTENDED_FILE) /* Linux */ # if HAVE_ACL_EXTENDED_FILE /* Linux */
{
/* On Linux, acl_extended_file is an optimized function: It only /* On Linux, acl_extended_file is an optimized function: It only
makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for
ACL_TYPE_DEFAULT. */ ACL_TYPE_DEFAULT. */
ret = acl_extended_file (name); ret = ((flags & ACL_SYMLINK_FOLLOW
} ? acl_extended_file
else /* FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */ : acl_extended_file_nofollow)
{ (name));
# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ # elif HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
/* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS) /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
and acl_get_file (name, ACL_TYPE_DEFAULT) and acl_get_file (name, ACL_TYPE_DEFAULT)
always return NULL / EINVAL. There is no point in making always return NULL / EINVAL. There is no point in making
these two useless calls. The real ACL is retrieved through these two useless calls. The real ACL is retrieved through
acl_get_file (name, ACL_TYPE_EXTENDED). */ acl_get_file (name, ACL_TYPE_EXTENDED). */
acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED); acl_t acl = ((flags & ACL_SYMLINK_FOLLOW
? acl_get_file
: acl_get_link_np)
(name, ACL_TYPE_EXTENDED));
if (acl) if (acl)
{ {
ret = acl_extended_nontrivial (acl); ret = acl_extended_nontrivial (acl);
@ -282,29 +427,36 @@ file_has_acl (char const *name, struct stat const *sb)
} }
else else
ret = -1; ret = -1;
# else /* FreeBSD, IRIX, Tru64, Cygwin >= 2.5 */ # else /* FreeBSD, NetBSD >= 10, IRIX, Tru64, Cygwin >= 2.5 */
acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS); acl_t (*acl_get_file_or_link) (char const *, acl_type_t) = acl_get_file;
# if HAVE_ACL_GET_LINK_NP /* FreeBSD, NetBSD >= 10 */
if (! (flags & ACL_SYMLINK_FOLLOW))
acl_get_file_or_link = acl_get_link_np;
# endif
acl_t acl = acl_get_file_or_link (name, ACL_TYPE_ACCESS);
if (acl) if (acl)
{ {
int saved_errno;
ret = acl_access_nontrivial (acl); ret = acl_access_nontrivial (acl);
saved_errno = errno; int saved_errno = errno;
acl_free (acl); acl_free (acl);
errno = saved_errno; errno = saved_errno;
# if HAVE_ACL_FREE_TEXT /* Tru64 */ # if HAVE_ACL_FREE_TEXT /* Tru64 */
/* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always
returns NULL with errno not set. There is no point in returns NULL with errno not set. There is no point in
making this call. */ making this call. */
# else /* FreeBSD, IRIX, Cygwin >= 2.5 */ # else /* FreeBSD, NetBSD >= 10, IRIX, Cygwin >= 2.5 */
/* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS) /* On Linux, FreeBSD, NetBSD, IRIX,
acl_get_file (name, ACL_TYPE_ACCESS)
and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory
either both succeed or both fail; it depends on the either both succeed or both fail; it depends on the
file system. Therefore there is no point in making the second file system. Therefore there is no point in making the second
call if the first one already failed. */ call if the first one already failed. */
if (ret == 0 && S_ISDIR (sb->st_mode)) if (ret == 0
&& (d_type == DT_DIR
|| (d_type == DT_UNKNOWN && !(flags & _GL_DT_NOTDIR))))
{ {
acl = acl_get_file (name, ACL_TYPE_DEFAULT); acl = acl_get_file_or_link (name, ACL_TYPE_DEFAULT);
if (acl) if (acl)
{ {
# ifdef __CYGWIN__ /* Cygwin >= 2.5 */ # ifdef __CYGWIN__ /* Cygwin >= 2.5 */
@ -318,21 +470,34 @@ file_has_acl (char const *name, struct stat const *sb)
# endif # endif
} }
else else
{
ret = -1; ret = -1;
# ifdef __CYGWIN__ /* Cygwin >= 2.5 */
if (d_type == DT_UNKNOWN)
ret = 0;
# endif
}
} }
# endif # endif
} }
else else
ret = -1; ret = -1;
# endif # endif
return ret < 0 ? - acl_errno_valid (errno) : ret;
} }
if (ret < 0)
return - acl_errno_valid (errno);
return ret;
# elif HAVE_FACL && defined GETACL /* Solaris, Cygwin < 2.5, not HP-UX */ # else /* !HAVE_ACL_GET_FILE */
# if defined ACL_NO_TRIVIAL /* The remaining APIs always follow symlinks and operate on
platforms where symlinks do not have ACLs, so skip the APIs if
NAME is known to be a symlink. */
if (d_type != DT_LNK)
{
# if HAVE_FACL && defined GETACL /* Solaris, Cygwin < 2.5, not HP-UX */
# ifdef ACL_NO_TRIVIAL
/* Solaris 10 (newer version), which has additional API declared in /* Solaris 10 (newer version), which has additional API declared in
<sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial, <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial,
@ -374,10 +539,7 @@ file_has_acl (char const *name, struct stat const *sb)
entries = malloced = entries = malloced =
(aclent_t *) malloc (alloc * sizeof (aclent_t)); (aclent_t *) malloc (alloc * sizeof (aclent_t));
if (entries == NULL) if (entries == NULL)
{
errno = ENOMEM;
return -1; return -1;
}
continue; continue;
} }
break; break;
@ -447,10 +609,7 @@ file_has_acl (char const *name, struct stat const *sb)
alloc = 2 * alloc; /* <= alloc_max */ alloc = 2 * alloc; /* <= alloc_max */
entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t)); entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t));
if (entries == NULL) if (entries == NULL)
{
errno = ENOMEM;
return -1; return -1;
}
continue; continue;
} }
break; break;
@ -604,11 +763,8 @@ file_has_acl (char const *name, struct stat const *sb)
free (acl); free (acl);
acl = malloc (aclsize); acl = malloc (aclsize);
if (acl == NULL) if (acl == NULL)
{
errno = ENOMEM;
return -1; return -1;
} }
}
if (type.u64 == ACL_AIXC) if (type.u64 == ACL_AIXC)
{ {
@ -675,10 +831,29 @@ file_has_acl (char const *name, struct stat const *sb)
return acl_nontrivial (count, entries); return acl_nontrivial (count, entries);
} }
} }
# endif # endif
} }
# endif
# endif
#endif #endif
return 0; return 0;
} }
/* Return 1 if NAME has a nontrivial access control list,
0 if ACLs are not supported, or if NAME has no or only a base ACL,
and -1 (setting errno) on error. Note callers can determine
if ACLs are not supported as errno is set in that case also.
SB must be set to the stat buffer of NAME,
obtained through stat() or lstat(). */
int
file_has_acl (char const *name, struct stat const *sb)
{
int flags = IFTODT (sb->st_mode);
if (!S_ISDIR (sb->st_mode))
flags |= _GL_DT_NOTDIR;
struct aclinfo ai;
int r = file_has_aclinfo (name, &ai, flags);
aclinfo_free (&ai);
return r;
}

View file

@ -46,10 +46,14 @@
# endif # endif
#endif #endif
#if defined __clang__
/* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
# undef __GNUC_PREREQ
# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
#endif
#ifndef __GNUC_PREREQ #ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_VERSION__ # if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \ # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else # else
# define __GNUC_PREREQ(maj, min) 0 # define __GNUC_PREREQ(maj, min) 0
# endif # endif

View file

@ -31,6 +31,13 @@
functions and variables. Renaming avoids problems with some functions and variables. Renaming avoids problems with some
compilers and linkers. */ compilers and linkers. */
#ifdef __GETOPT_PREFIX #ifdef __GETOPT_PREFIX
/* Include platform-dependent header files that may declare getopt() and
friends. */
# if defined _AIX || defined __hpux || defined __sun || defined __QNX__
# include <stdio.h>
# endif
# ifndef __GETOPT_ID # ifndef __GETOPT_ID
# define __GETOPT_CONCAT(x, y) x ## y # define __GETOPT_CONCAT(x, y) x ## y
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)

View file

@ -42,7 +42,7 @@
# define funlockfile(fp) _IO_funlockfile (fp) # define funlockfile(fp) _IO_funlockfile (fp)
#else #else
# include "gettext.h" # include "gettext.h"
# define _(msgid) gettext (msgid) # define _(msgid) dgettext ("gnulib", msgid)
/* When used standalone, flockfile and funlockfile might not be /* When used standalone, flockfile and funlockfile might not be
available. */ available. */
# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \ # if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
@ -732,7 +732,7 @@ _getopt_internal (int argc, char **argv, const char *optstring,
NAME (int argc, char *const *argv, const char *optstring) \ NAME (int argc, char *const *argv, const char *optstring) \
{ \ { \
return _getopt_internal (argc, (char **)argv, optstring, \ return _getopt_internal (argc, (char **)argv, optstring, \
0, 0, 0, POSIXLY_CORRECT); \ NULL, NULL, 0, POSIXLY_CORRECT); \
} }
#ifdef _LIBC #ifdef _LIBC

View file

@ -1,6 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>. /* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2024 Free Software Copyright (C) 1995-2024 Free Software Foundation, Inc.
Foundation, Inc.
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as it under the terms of the GNU Lesser General Public License as
@ -18,6 +17,7 @@
#ifndef _LIBGETTEXT_H #ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1 #define _LIBGETTEXT_H 1
/* NLS can be disabled through the configure --disable-nls option /* NLS can be disabled through the configure --disable-nls option
or through "#define ENABLE NLS 0" before including this file. */ or through "#define ENABLE NLS 0" before including this file. */
#if defined ENABLE_NLS && ENABLE_NLS #if defined ENABLE_NLS && ENABLE_NLS
@ -93,12 +93,14 @@
#endif #endif
/* Prefer gnulib's setlocale override over libintl's setlocale override. */ /* Prefer gnulib's setlocale override over libintl's setlocale override. */
#ifdef GNULIB_defined_setlocale #ifdef GNULIB_defined_setlocale
# undef setlocale # undef setlocale
# define setlocale rpl_setlocale # define setlocale rpl_setlocale
#endif #endif
/* A pseudo function call that serves as a marker for the automated /* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code. translation is done at a different place in the code.
@ -108,6 +110,7 @@
initializer for static 'char[]' or 'const char[]' variables. */ initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String #define gettext_noop(String) String
/* The separator between msgctxt and msgid in a .mo file. */ /* The separator between msgctxt and msgid in a .mo file. */
#define GETTEXT_CONTEXT_GLUE "\004" #define GETTEXT_CONTEXT_GLUE "\004"
@ -115,6 +118,9 @@
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
short and rarely need to change. short and rarely need to change.
The letter 'p' stands for 'particular' or 'special'. */ The letter 'p' stands for 'particular' or 'special'. */
#include <locale.h> /* for LC_MESSAGES */
#ifdef DEFAULT_TEXT_DOMAIN #ifdef DEFAULT_TEXT_DOMAIN
# define pgettext(Msgctxt, Msgid) \ # define pgettext(Msgctxt, Msgid) \
pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
@ -178,11 +184,12 @@ npgettext_aux (const char *domain,
return translation; return translation;
} }
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID /* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
can be arbitrary expressions. But for string literals these macros are can be arbitrary expressions. But for string literals these macros are
less efficient than those above. */ less efficient than those above. */
#include <string.h> #include <string.h> /* for memcpy */
/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported. /* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
This relates to the -Wvla and -Wvla-larger-than warnings, enabled in This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
@ -199,7 +206,7 @@ npgettext_aux (const char *domain,
#endif #endif
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h> # include <stdlib.h> /* for malloc, free */
#endif #endif
#define pgettext_expr(Msgctxt, Msgid) \ #define pgettext_expr(Msgctxt, Msgid) \
@ -297,4 +304,5 @@ dcnpgettext_expr (const char *domain,
return (n == 1 ? msgid : msgid_plural); return (n == 1 ? msgid : msgid_plural);
} }
#endif /* _LIBGETTEXT_H */ #endif /* _LIBGETTEXT_H */

View file

@ -42,6 +42,7 @@
# --avoid=dup \ # --avoid=dup \
# --avoid=fchdir \ # --avoid=fchdir \
# --avoid=fstat \ # --avoid=fstat \
# --avoid=gnulib-i18n \
# --avoid=iswblank \ # --avoid=iswblank \
# --avoid=iswctype \ # --avoid=iswctype \
# --avoid=iswdigit \ # --avoid=iswdigit \
@ -80,6 +81,7 @@
# alloca-opt \ # alloca-opt \
# binary-io \ # binary-io \
# boot-time \ # boot-time \
# builtin-expect \
# byteswap \ # byteswap \
# c-ctype \ # c-ctype \
# c-strcase \ # c-strcase \
@ -261,7 +263,6 @@ DYNLIB_OBJ = @DYNLIB_OBJ@
ECHO_C = @ECHO_C@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EMACSRES = @EMACSRES@ EMACSRES = @EMACSRES@
EMACS_MANIFEST = @EMACS_MANIFEST@ EMACS_MANIFEST = @EMACS_MANIFEST@
EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@ EMULTIHOP_HIDDEN = @EMULTIHOP_HIDDEN@
@ -336,6 +337,7 @@ GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION = @GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION@
GL_COND_OBJ_RAWMEMCHR_CONDITION = @GL_COND_OBJ_RAWMEMCHR_CONDITION@ GL_COND_OBJ_RAWMEMCHR_CONDITION = @GL_COND_OBJ_RAWMEMCHR_CONDITION@
GL_COND_OBJ_READLINKAT_CONDITION = @GL_COND_OBJ_READLINKAT_CONDITION@ GL_COND_OBJ_READLINKAT_CONDITION = @GL_COND_OBJ_READLINKAT_CONDITION@
GL_COND_OBJ_READLINK_CONDITION = @GL_COND_OBJ_READLINK_CONDITION@ GL_COND_OBJ_READLINK_CONDITION = @GL_COND_OBJ_READLINK_CONDITION@
GL_COND_OBJ_REALLOC_POSIX_CONDITION = @GL_COND_OBJ_REALLOC_POSIX_CONDITION@
GL_COND_OBJ_REGEX_CONDITION = @GL_COND_OBJ_REGEX_CONDITION@ GL_COND_OBJ_REGEX_CONDITION = @GL_COND_OBJ_REGEX_CONDITION@
GL_COND_OBJ_SIG2STR_CONDITION = @GL_COND_OBJ_SIG2STR_CONDITION@ GL_COND_OBJ_SIG2STR_CONDITION = @GL_COND_OBJ_SIG2STR_CONDITION@
GL_COND_OBJ_SIGDESCR_NP_CONDITION = @GL_COND_OBJ_SIGDESCR_NP_CONDITION@ GL_COND_OBJ_SIGDESCR_NP_CONDITION = @GL_COND_OBJ_SIGDESCR_NP_CONDITION@
@ -584,7 +586,6 @@ GL_GNULIB_READDIR = @GL_GNULIB_READDIR@
GL_GNULIB_READLINK = @GL_GNULIB_READLINK@ GL_GNULIB_READLINK = @GL_GNULIB_READLINK@
GL_GNULIB_READLINKAT = @GL_GNULIB_READLINKAT@ GL_GNULIB_READLINKAT = @GL_GNULIB_READLINKAT@
GL_GNULIB_REALLOCARRAY = @GL_GNULIB_REALLOCARRAY@ GL_GNULIB_REALLOCARRAY = @GL_GNULIB_REALLOCARRAY@
GL_GNULIB_REALLOC_GNU = @GL_GNULIB_REALLOC_GNU@
GL_GNULIB_REALLOC_POSIX = @GL_GNULIB_REALLOC_POSIX@ GL_GNULIB_REALLOC_POSIX = @GL_GNULIB_REALLOC_POSIX@
GL_GNULIB_REALPATH = @GL_GNULIB_REALPATH@ GL_GNULIB_REALPATH = @GL_GNULIB_REALPATH@
GL_GNULIB_REMOVE = @GL_GNULIB_REMOVE@ GL_GNULIB_REMOVE = @GL_GNULIB_REMOVE@
@ -707,7 +708,6 @@ GNUSTEP_CFLAGS = @GNUSTEP_CFLAGS@
GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@ GNU_OBJC_CFLAGS = @GNU_OBJC_CFLAGS@
GOBJECT_CFLAGS = @GOBJECT_CFLAGS@ GOBJECT_CFLAGS = @GOBJECT_CFLAGS@
GOBJECT_LIBS = @GOBJECT_LIBS@ GOBJECT_LIBS = @GOBJECT_LIBS@
GREP = @GREP@
GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@ GSETTINGS_CFLAGS = @GSETTINGS_CFLAGS@
GSETTINGS_LIBS = @GSETTINGS_LIBS@ GSETTINGS_LIBS = @GSETTINGS_LIBS@
GTK_CFLAGS = @GTK_CFLAGS@ GTK_CFLAGS = @GTK_CFLAGS@
@ -1031,6 +1031,7 @@ LIB_MATH = @LIB_MATH@
LIB_NANOSLEEP = @LIB_NANOSLEEP@ LIB_NANOSLEEP = @LIB_NANOSLEEP@
LIB_PTHREAD = @LIB_PTHREAD@ LIB_PTHREAD = @LIB_PTHREAD@
LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
LIB_SELINUX = @LIB_SELINUX@
LIB_TIMER_TIME = @LIB_TIMER_TIME@ LIB_TIMER_TIME = @LIB_TIMER_TIME@
LIB_WSOCK32 = @LIB_WSOCK32@ LIB_WSOCK32 = @LIB_WSOCK32@
LIB_XATTR = @LIB_XATTR@ LIB_XATTR = @LIB_XATTR@
@ -1277,7 +1278,6 @@ REPLACE_READDIR = @REPLACE_READDIR@
REPLACE_READLINK = @REPLACE_READLINK@ REPLACE_READLINK = @REPLACE_READLINK@
REPLACE_READLINKAT = @REPLACE_READLINKAT@ REPLACE_READLINKAT = @REPLACE_READLINKAT@
REPLACE_REALLOCARRAY = @REPLACE_REALLOCARRAY@ REPLACE_REALLOCARRAY = @REPLACE_REALLOCARRAY@
REPLACE_REALLOC_FOR_REALLOC_GNU = @REPLACE_REALLOC_FOR_REALLOC_GNU@
REPLACE_REALLOC_FOR_REALLOC_POSIX = @REPLACE_REALLOC_FOR_REALLOC_POSIX@ REPLACE_REALLOC_FOR_REALLOC_POSIX = @REPLACE_REALLOC_FOR_REALLOC_POSIX@
REPLACE_REALPATH = @REPLACE_REALPATH@ REPLACE_REALPATH = @REPLACE_REALPATH@
REPLACE_REMOVE = @REPLACE_REMOVE@ REPLACE_REMOVE = @REPLACE_REMOVE@
@ -1384,6 +1384,7 @@ UNISTD_H_HAVE_SYS_RANDOM_H = @UNISTD_H_HAVE_SYS_RANDOM_H@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
USE_ACL = @USE_ACL@ USE_ACL = @USE_ACL@
USE_SELINUX_SELINUX_H = @USE_SELINUX_SELINUX_H@
USE_STARTUP_NOTIFICATION = @USE_STARTUP_NOTIFICATION@ USE_STARTUP_NOTIFICATION = @USE_STARTUP_NOTIFICATION@
VMLIMIT_OBJ = @VMLIMIT_OBJ@ VMLIMIT_OBJ = @VMLIMIT_OBJ@
W32_LIBS = @W32_LIBS@ W32_LIBS = @W32_LIBS@
@ -1470,16 +1471,13 @@ gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b_CONDITION = @gl_GNULIB_ENABLE
gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION@ gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31_CONDITION@
gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION@ gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c_CONDITION@
gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION = @gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION@ gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION = @gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION@
gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION = @gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION@
gl_GNULIB_ENABLED_8444034ea779b88768865bb60b4fb8c9_CONDITION = @gl_GNULIB_ENABLED_8444034ea779b88768865bb60b4fb8c9_CONDITION@ gl_GNULIB_ENABLED_8444034ea779b88768865bb60b4fb8c9_CONDITION = @gl_GNULIB_ENABLED_8444034ea779b88768865bb60b4fb8c9_CONDITION@
gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION = @gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION@ gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION = @gl_GNULIB_ENABLED_925677f0343de64b89a9f0c790b4104c_CONDITION@
gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION@ gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION = @gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION@
gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION@ gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION = @gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36_CONDITION@
gl_GNULIB_ENABLED_cloexec_CONDITION = @gl_GNULIB_ENABLED_cloexec_CONDITION@ gl_GNULIB_ENABLED_cloexec_CONDITION = @gl_GNULIB_ENABLED_cloexec_CONDITION@
gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION = @gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION@
gl_GNULIB_ENABLED_dirfd_CONDITION = @gl_GNULIB_ENABLED_dirfd_CONDITION@ gl_GNULIB_ENABLED_dirfd_CONDITION = @gl_GNULIB_ENABLED_dirfd_CONDITION@
gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b_CONDITION = @gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b_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_endian_CONDITION = @gl_GNULIB_ENABLED_endian_CONDITION@
gl_GNULIB_ENABLED_euidaccess_CONDITION = @gl_GNULIB_ENABLED_euidaccess_CONDITION@ gl_GNULIB_ENABLED_euidaccess_CONDITION = @gl_GNULIB_ENABLED_euidaccess_CONDITION@
gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION = @gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION@ gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION = @gl_GNULIB_ENABLED_fd38c7e463b54744b77b98aeafb4fa7c_CONDITION@
@ -2694,9 +2692,7 @@ endif
## begin gnulib module malloc-posix ## begin gnulib module malloc-posix
ifeq (,$(OMIT_GNULIB_MODULE_malloc-posix)) ifeq (,$(OMIT_GNULIB_MODULE_malloc-posix))
ifneq (,$(gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866_CONDITION))
endif
EXTRA_DIST += malloc.c EXTRA_DIST += malloc.c
EXTRA_libgnu_a_SOURCES += malloc.c EXTRA_libgnu_a_SOURCES += malloc.c
@ -2925,29 +2921,15 @@ EXTRA_libgnu_a_SOURCES += at-func.c
endif endif
## end gnulib module readlinkat ## end gnulib module readlinkat
## begin gnulib module realloc-gnu
ifeq (,$(OMIT_GNULIB_MODULE_realloc-gnu))
ifneq (,$(gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b_CONDITION))
endif
EXTRA_DIST += realloc.c
EXTRA_libgnu_a_SOURCES += realloc.c
endif
## end gnulib module realloc-gnu
## begin gnulib module realloc-posix ## begin gnulib module realloc-posix
ifeq (,$(OMIT_GNULIB_MODULE_realloc-posix)) ifeq (,$(OMIT_GNULIB_MODULE_realloc-posix))
ifneq (,$(gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION)) ifneq (,$(gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4_CONDITION))
ifneq (,$(GL_COND_OBJ_REALLOC_POSIX_CONDITION))
libgnu_a_SOURCES += realloc.c
endif
endif endif
EXTRA_DIST += realloc.c
EXTRA_libgnu_a_SOURCES += realloc.c
endif endif
## end gnulib module realloc-posix ## end gnulib module realloc-posix
@ -3459,9 +3441,8 @@ endif
ifeq (,$(OMIT_GNULIB_MODULE_stdlib)) ifeq (,$(OMIT_GNULIB_MODULE_stdlib))
BUILT_SOURCES += stdlib.h BUILT_SOURCES += stdlib.h
libgnu_a_SOURCES += stdlib.c
# We need the following in order to create <stdlib.h> when the system
# doesn't have one that works with the given compiler.
stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
$(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(gl_V_at)$(SED_HEADER_STDOUT) \ $(gl_V_at)$(SED_HEADER_STDOUT) \
@ -3500,7 +3481,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's/@''GNULIB_RAND''@/$(GL_GNULIB_RAND)/g' \ -e 's/@''GNULIB_RAND''@/$(GL_GNULIB_RAND)/g' \
-e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \ -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \
-e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \ -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \
-e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \
-e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \ -e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \
-e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \ -e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \
-e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \ -e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \
@ -3602,7 +3582,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \ -e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \
-e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \ -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
-e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
-e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \
-e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \ -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \
-e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \ -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
@ -4446,17 +4425,6 @@ EXTRA_DIST += vla.h
endif endif
## end gnulib module vla ## end gnulib module vla
## begin gnulib module xalloc-oversized
ifeq (,$(OMIT_GNULIB_MODULE_xalloc-oversized))
ifneq (,$(gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec_CONDITION))
endif
EXTRA_DIST += xalloc-oversized.h
endif
## end gnulib module xalloc-oversized
mostlyclean-local: mostlyclean-generic mostlyclean-local: mostlyclean-generic
@for dir in '' $(MOSTLYCLEANDIRS); do \ @for dir in '' $(MOSTLYCLEANDIRS); do \

View file

@ -17,28 +17,33 @@
/* written by Jim Meyering and Bruno Haible */ /* written by Jim Meyering and Bruno Haible */
/* Ensure that we call the system's malloc() below. */
#define _GL_USE_STDLIB_ALLOC 1 #define _GL_USE_STDLIB_ALLOC 1
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <stdckdint.h>
#include "xalloc-oversized.h"
/* Allocate an N-byte block of memory from the heap, even if N is 0. */ /* Allocate an N-byte block of memory from the heap, even if N is 0. */
void * void *
rpl_malloc (size_t n) rpl_malloc (size_t n)
{ {
#if !HAVE_MALLOC_0_NONNULL
if (n == 0) if (n == 0)
n = 1; n = 1;
#endif
if (xalloc_oversized (n, 1)) #if !HAVE_MALLOC_PTRDIFF
ptrdiff_t signed_n;
if (ckd_add (&signed_n, n, 0))
{ {
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }
#endif
void *result = malloc (n); void *result = malloc (n);

View file

@ -22,9 +22,6 @@
#include <config.h> #include <config.h>
/* Specification. */ /* Specification. */
#if HAVE_OPENSSL_MD5
# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
#endif
#include "md5.h" #include "md5.h"
#include <stdlib.h> #include <stdlib.h>

View file

@ -52,10 +52,14 @@
#define MD5_DIGEST_SIZE 16 #define MD5_DIGEST_SIZE 16
#define MD5_BLOCK_SIZE 64 #define MD5_BLOCK_SIZE 64
#if defined __clang__
/* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */
# undef __GNUC_PREREQ
# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2))
#endif
#ifndef __GNUC_PREREQ #ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__ # if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \ # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else # else
# define __GNUC_PREREQ(maj, min) 0 # define __GNUC_PREREQ(maj, min) 0
# endif # endif

View file

@ -27,6 +27,9 @@ memset_explicit (void *s, int c, size_t len)
#if HAVE_EXPLICIT_MEMSET #if HAVE_EXPLICIT_MEMSET
return explicit_memset (s, c, len); return explicit_memset (s, c, len);
#elif HAVE_MEMSET_S #elif HAVE_MEMSET_S
# if !HAVE_MEMSET_S_SUPPORTS_ZERO
if (len > 0)
# endif
(void) memset_s (s, len, c, len); (void) memset_s (s, len, c, len);
return s; return s;
#elif defined __GNUC__ && !defined __clang__ #elif defined __GNUC__ && !defined __clang__

View file

@ -2706,6 +2706,66 @@ mpn_gcd_11 (mp_limb_t u, mp_limb_t v)
return u << shift; return u << shift;
} }
mp_size_t
mpn_gcd (mp_ptr rp, mp_ptr up, mp_size_t un, mp_ptr vp, mp_size_t vn)
{
assert (un >= vn);
assert (vn > 0);
assert (!GMP_MPN_OVERLAP_P (up, un, vp, vn));
assert (vp[vn-1] > 0);
assert ((up[0] | vp[0]) & 1);
if (un > vn)
mpn_div_qr (NULL, up, un, vp, vn);
un = mpn_normalized_size (up, vn);
if (un == 0)
{
mpn_copyi (rp, vp, vn);
return vn;
}
if (!(vp[0] & 1))
MPN_PTR_SWAP (up, un, vp, vn);
while (un > 1 || vn > 1)
{
int shift;
assert (vp[0] & 1);
while (up[0] == 0)
{
up++;
un--;
}
gmp_ctz (shift, up[0]);
if (shift > 0)
{
gmp_assert_nocarry (mpn_rshift(up, up, un, shift));
un -= (up[un-1] == 0);
}
if (un < vn)
MPN_PTR_SWAP (up, un, vp, vn);
else if (un == vn)
{
int c = mpn_cmp (up, vp, un);
if (c == 0)
{
mpn_copyi (rp, up, un);
return un;
}
else if (c < 0)
MP_PTR_SWAP (up, vp);
}
gmp_assert_nocarry (mpn_sub (up, up, un, vp, vn));
un = mpn_normalized_size (up, un);
}
rp[0] = mpn_gcd_11 (up[0], vp[0]);
return 1;
}
unsigned long unsigned long
mpz_gcd_ui (mpz_t g, const mpz_t u, unsigned long v) mpz_gcd_ui (mpz_t g, const mpz_t u, unsigned long v)
{ {
@ -2765,42 +2825,11 @@ mpz_gcd (mpz_t g, const mpz_t u, const mpz_t v)
if (tu->_mp_size < tv->_mp_size) if (tu->_mp_size < tv->_mp_size)
mpz_swap (tu, tv); mpz_swap (tu, tv);
mpz_tdiv_r (tu, tu, tv); tu->_mp_size = mpn_gcd (tu->_mp_d, tu->_mp_d, tu->_mp_size, tv->_mp_d, tv->_mp_size);
if (tu->_mp_size == 0) mpz_mul_2exp (g, tu, gz);
{
mpz_swap (g, tv);
}
else
for (;;)
{
int c;
mpz_make_odd (tu);
c = mpz_cmp (tu, tv);
if (c == 0)
{
mpz_swap (g, tu);
break;
}
if (c < 0)
mpz_swap (tu, tv);
if (tv->_mp_size == 1)
{
mp_limb_t *gp;
mpz_tdiv_r (tu, tu, tv);
gp = MPZ_REALLOC (g, 1); /* gp = mpz_limbs_modify (g, 1); */
*gp = mpn_gcd_11 (tu->_mp_d[0], tv->_mp_d[0]);
g->_mp_size = *gp != 0; /* mpz_limbs_finish (g, 1); */
break;
}
mpz_sub (tu, tu, tv);
}
mpz_clear (tu); mpz_clear (tu);
mpz_clear (tv); mpz_clear (tv);
mpz_mul_2exp (g, g, gz);
} }
void void

View file

@ -105,6 +105,7 @@ void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t); void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t);
int mpn_perfect_square_p (mp_srcptr, mp_size_t); int mpn_perfect_square_p (mp_srcptr, mp_size_t);
mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t);
mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t);
mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);
mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);

View file

@ -71,9 +71,8 @@ typedef int mktime_offset_t;
#endif #endif
/* Subroutine of mktime. Return the time_t representation of TP and /* Subroutine of mktime. Return the time_t representation of TP and
normalize TP, given that a struct tm * maps to a time_t as performed normalize TP, given that a struct tm * maps to a time_t. If
by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */ LOCAL, the mapping is performed by localtime_r, otherwise by gmtime_r.
extern __time64_t __mktime_internal (struct tm *tp, Record next guess for localtime-gmtime offset in *OFFSET. */
struct tm *(*func) (__time64_t const *, extern __time64_t __mktime_internal (struct tm *tp, bool local,
struct tm *),
mktime_offset_t *offset) attribute_hidden; mktime_offset_t *offset) attribute_hidden;

View file

@ -51,7 +51,6 @@
#include <string.h> #include <string.h>
#include <intprops.h> #include <intprops.h>
#include <verify.h>
#ifndef NEED_MKTIME_INTERNAL #ifndef NEED_MKTIME_INTERNAL
# define NEED_MKTIME_INTERNAL 0 # define NEED_MKTIME_INTERNAL 0
@ -124,7 +123,7 @@ typedef long int long_int;
# else # else
typedef long long int long_int; typedef long long int long_int;
# endif # endif
verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60); static_assert (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60);
/* Shift A right by B bits portably, by dividing A by 2**B and /* Shift A right by B bits portably, by dividing A by 2**B and
truncating towards minus infinity. B should be in the range 0 <= B truncating towards minus infinity. B should be in the range 0 <= B
@ -157,7 +156,7 @@ static long_int const mktime_max
# define EPOCH_YEAR 1970 # define EPOCH_YEAR 1970
# define TM_YEAR_BASE 1900 # define TM_YEAR_BASE 1900
verify (TM_YEAR_BASE % 100 == 0); static_assert (TM_YEAR_BASE % 100 == 0);
/* Is YEAR + TM_YEAR_BASE a leap year? */ /* Is YEAR + TM_YEAR_BASE a leap year? */
static bool static bool
@ -206,7 +205,7 @@ static long_int
ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
int year0, int yday0, int hour0, int min0, int sec0) int year0, int yday0, int hour0, int min0, int sec0)
{ {
verify (-1 / 2 == 0); static_assert (-1 / 2 == 0);
/* Compute intervening leap days correctly even if year is negative. /* Compute intervening leap days correctly even if year is negative.
Take care to avoid integer overflow here. */ Take care to avoid integer overflow here. */
@ -251,29 +250,33 @@ tm_diff (long_int year, long_int yday, int hour, int min, int sec,
tp->tm_hour, tp->tm_min, tp->tm_sec); tp->tm_hour, tp->tm_min, tp->tm_sec);
} }
/* Use CONVERT to convert T to a struct tm value in *TM. T must be in /* Convert T to a struct tm value in *TM. Use localtime64_r if LOCAL,
range for __time64_t. Return TM if successful, NULL (setting errno) on otherwise gmtime64_r. T must be in range for __time64_t. Return
failure. */ TM if successful, NULL (setting errno) on failure. */
static struct tm * static struct tm *
convert_time (struct tm *(*convert) (const __time64_t *, struct tm *), convert_time (long_int t, bool local, struct tm *tm)
long_int t, struct tm *tm)
{ {
__time64_t x = t; __time64_t x = t;
return convert (&x, tm); if (local)
return __localtime64_r (&x, tm);
else
return __gmtime64_r (&x, tm);
} }
/* Call it __tzconvert to sync with other parts of glibc. */
#define __tz_convert convert_time
/* Use CONVERT to convert *T to a broken down time in *TP. /* Convert *T to a broken down time in *TP (as if by localtime if
If *T is out of range for conversion, adjust it so that LOCAL, otherwise as if by gmtime). If *T is out of range for
it is the nearest in-range value and then convert that. conversion, adjust it so that it is the nearest in-range value and
A value is in range if it fits in both __time64_t and long_int. then convert that. A value is in range if it fits in both
Return TP on success, NULL (setting errno) on failure. */ __time64_t and long_int. Return TP on success, NULL (setting
errno) on failure. */
static struct tm * static struct tm *
ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), ranged_convert (bool local, long_int *t, struct tm *tp)
long_int *t, struct tm *tp)
{ {
long_int t1 = (*t < mktime_min ? mktime_min long_int t1 = (*t < mktime_min ? mktime_min
: *t <= mktime_max ? *t : mktime_max); : *t <= mktime_max ? *t : mktime_max);
struct tm *r = convert_time (convert, t1, tp); struct tm *r = __tz_convert (t1, local, tp);
if (r) if (r)
{ {
*t = t1; *t = t1;
@ -294,7 +297,7 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
long_int mid = long_int_avg (ok, bad); long_int mid = long_int_avg (ok, bad);
if (mid == ok || mid == bad) if (mid == ok || mid == bad)
break; break;
if (convert_time (convert, mid, tp)) if (__tz_convert (mid, local, tp))
ok = mid, oktm = *tp; ok = mid, oktm = *tp;
else if (errno != EOVERFLOW) else if (errno != EOVERFLOW)
return NULL; return NULL;
@ -310,36 +313,45 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
} }
/* Convert *TP to a __time64_t value, inverting /* Convert *TP to a __time64_t value. If LOCAL, the reverse mapping
the monotonic and mostly-unit-linear conversion function CONVERT. is performed as if localtime, otherwise as if by gmtime. Use
Use *OFFSET to keep track of a guess at the offset of the result, *OFFSET to keep track of a guess at the offset of the result,
compared to what the result would be for UTC without leap seconds. compared to what the result would be for UTC without leap seconds.
If *OFFSET's guess is correct, only one CONVERT call is needed. If *OFFSET's guess is correct, only one reverse mapping call is
If successful, set *TP to the canonicalized struct tm; needed. If successful, set *TP to the canonicalized struct tm;
otherwise leave *TP alone, return ((time_t) -1) and set errno. otherwise leave *TP alone, return ((time_t) -1) and set errno.
This function is external because it is used also by timegm.c. */ This function is external because it is used also by timegm.c. */
__time64_t __time64_t
__mktime_internal (struct tm *tp, __mktime_internal (struct tm *tp, bool local, mktime_offset_t *offset)
struct tm *(*convert) (const __time64_t *, struct tm *),
mktime_offset_t *offset)
{ {
struct tm tm; struct tm tm;
/* The maximum number of probes (calls to CONVERT) should be enough /* The maximum number of probes should be enough to handle any
to handle any combinations of time zone rule changes, solar time, combinations of time zone rule changes, solar time, leap seconds,
leap seconds, and oscillations around a spring-forward gap. and oscillations around a spring-forward gap. POSIX.1 prohibits
POSIX.1 prohibits leap seconds, but some hosts have them anyway. */ leap seconds, but some hosts have them anyway. */
int remaining_probes = 6; int remaining_probes = 6;
/* Time requested. Copy it in case CONVERT modifies *TP; this can #ifndef _LIBC
occur if TP is localtime's returned value and CONVERT is localtime. */ /* Gnulib mktime doesn't lock the tz state, so it may need to probe
more often if some other thread changes local time while
__mktime_internal is probing. Double the number of probes; this
should suffice for practical cases that are at all likely. */
remaining_probes *= 2;
#endif
/* Time requested. Copy it in case gmtime/localtime modify *TP;
this can occur if TP is localtime's returned value and CONVERT is
localtime. */
int sec = tp->tm_sec; int sec = tp->tm_sec;
int min = tp->tm_min; int min = tp->tm_min;
int hour = tp->tm_hour; int hour = tp->tm_hour;
int mday = tp->tm_mday; int mday = tp->tm_mday;
int mon = tp->tm_mon; int mon = tp->tm_mon;
int year_requested = tp->tm_year; int year_requested = tp->tm_year;
int isdst = tp->tm_isdst;
/* Ignore any tm_isdst request for timegm. */
int isdst = local ? tp->tm_isdst : 0;
/* 1 if the previous probe was DST. */ /* 1 if the previous probe was DST. */
int dst2 = 0; int dst2 = 0;
@ -390,7 +402,7 @@ __mktime_internal (struct tm *tp,
while (true) while (true)
{ {
if (! ranged_convert (convert, &t, &tm)) if (! ranged_convert (local, &t, &tm))
return -1; return -1;
long_int dt = tm_diff (year, yday, hour, min, sec, &tm); long_int dt = tm_diff (year, yday, hour, min, sec, &tm);
if (dt == 0) if (dt == 0)
@ -469,7 +481,7 @@ __mktime_internal (struct tm *tp,
if (! ckd_add (&ot, t, delta * direction)) if (! ckd_add (&ot, t, delta * direction))
{ {
struct tm otm; struct tm otm;
if (! ranged_convert (convert, &ot, &otm)) if (! ranged_convert (local, &ot, &otm))
return -1; return -1;
if (! isdst_differ (isdst, otm.tm_isdst)) if (! isdst_differ (isdst, otm.tm_isdst))
{ {
@ -479,7 +491,7 @@ __mktime_internal (struct tm *tp,
&otm); &otm);
if (mktime_min <= gt && gt <= mktime_max) if (mktime_min <= gt && gt <= mktime_max)
{ {
if (convert_time (convert, gt, &tm)) if (__tz_convert (gt, local, &tm))
{ {
t = gt; t = gt;
goto offset_found; goto offset_found;
@ -493,7 +505,7 @@ __mktime_internal (struct tm *tp,
/* No unusual DST offset was found nearby. Assume one-hour DST. */ /* No unusual DST offset was found nearby. Assume one-hour DST. */
t += 60 * 60 * dst_difference; t += 60 * 60 * dst_difference;
if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm)) if (mktime_min <= t && t <= mktime_max && __tz_convert (t, local, &tm))
goto offset_found; goto offset_found;
__set_errno (EOVERFLOW); __set_errno (EOVERFLOW);
@ -520,7 +532,7 @@ __mktime_internal (struct tm *tp,
__set_errno (EOVERFLOW); __set_errno (EOVERFLOW);
return -1; return -1;
} }
if (! convert_time (convert, t, &tm)) if (! __tz_convert (t, local, &tm))
return -1; return -1;
} }
@ -536,14 +548,13 @@ __mktime_internal (struct tm *tp,
__time64_t __time64_t
__mktime64 (struct tm *tp) __mktime64 (struct tm *tp)
{ {
/* POSIX.1 8.1.1 requires that whenever mktime() is called, the /* POSIX.1 requires mktime to set external variables like 'tzname'
time zone names contained in the external variable 'tzname' shall as though tzset had been called. */
be set as if the tzset() function had been called. */
__tzset (); __tzset ();
# if defined _LIBC || NEED_MKTIME_WORKING # if defined _LIBC || NEED_MKTIME_WORKING
static mktime_offset_t localtime_offset; static mktime_offset_t localtime_offset;
return __mktime_internal (tp, __localtime64_r, &localtime_offset); return __mktime_internal (tp, true, &localtime_offset);
# else # else
# undef mktime # undef mktime
return mktime (tp); return mktime (tp);

View file

@ -20,6 +20,7 @@
#include <config.h> #include <config.h>
#include "nproc.h" #include "nproc.h"
#include <errno.h>
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -125,6 +126,46 @@ num_processors_via_affinity_mask (void)
} }
} }
#elif HAVE_SCHED_GETAFFINITY_LIKE_GLIBC /* glibc >= 2.3.4 */ #elif HAVE_SCHED_GETAFFINITY_LIKE_GLIBC /* glibc >= 2.3.4 */
/* There are two ways to use the sched_getaffinity() function:
- With a statically-sized cpu_set_t.
- With a dynamically-sized cpu_set_t.
Documentation:
<https://www.kernel.org/doc/man-pages/online/pages/man2/sched_getaffinity.2.html>
<https://www.kernel.org/doc/man-pages/online/pages/man3/CPU_SET.3.html>
The second way has the advantage that it works on systems with more than
1024 CPUs. The first way has the advantage that it works also when memory
is tight. */
# if defined CPU_ALLOC_SIZE /* glibc >= 2.6 */
{
unsigned int alloc_count = 1024;
for (;;)
{
cpu_set_t *set = CPU_ALLOC (alloc_count);
if (set == NULL)
/* Out of memory. */
break;
unsigned int size = CPU_ALLOC_SIZE (alloc_count);
if (sched_getaffinity (0, size, set) == 0)
{
unsigned int count = CPU_COUNT_S (size, set);
CPU_FREE (set);
return count;
}
if (errno != EINVAL)
{
/* Some other error. */
CPU_FREE (set);
return 0;
}
CPU_FREE (set);
/* Retry with some larger cpu_set_t. */
alloc_count *= 2;
if (alloc_count == 0)
/* Integer overflow. Avoid an endless loop. */
return 0;
}
}
# endif
{ {
cpu_set_t set; cpu_set_t set;

View file

@ -40,7 +40,7 @@ pipe2 (int fd[2], int flags)
{ {
/* Mingw _pipe() corrupts fd on failure; also, if we succeed at /* Mingw _pipe() corrupts fd on failure; also, if we succeed at
creating the pipe but later fail at changing fcntl, we want creating the pipe but later fail at changing fcntl, we want
to leave fd unchanged: http://austingroupbugs.net/view.php?id=467 */ to leave fd unchanged: https://austingroupbugs.net/view.php?id=467 */
int tmp[2]; int tmp[2];
tmp[0] = fd[0]; tmp[0] = fd[0];
tmp[1] = fd[1]; tmp[1] = fd[1];

View file

@ -18,17 +18,21 @@
/* written by Jim Meyering and Bruno Haible */ /* written by Jim Meyering and Bruno Haible */
/* Ensure that we call the system's realloc() below. */
#define _GL_USE_STDLIB_ALLOC 1
#include <config.h> #include <config.h>
#define _GL_REALLOC_INLINE _GL_EXTERN_INLINE
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <stdckdint.h>
#include "xalloc-oversized.h" #ifdef __CHERI_PURE_CAPABILITY__
# include <cheri.h>
#endif
/* Call the system's realloc below. This file does not define #ifndef _GL_INLINE_RPL_REALLOC
_GL_USE_STDLIB_ALLOC because it needs Gnulib's malloc if present. */
#undef realloc
/* Change the size of an allocated block of memory P to N bytes, /* Change the size of an allocated block of memory P to N bytes,
with error checking. If P is NULL, use malloc. Otherwise if N is zero, with error checking. If P is NULL, use malloc. Otherwise if N is zero,
@ -37,27 +41,70 @@
void * void *
rpl_realloc (void *p, size_t n) rpl_realloc (void *p, size_t n)
{ {
if (p == NULL) size_t n1 = n;
return malloc (n);
if (n == 0) if (n == 0)
{ {
free (p); # if NEED_SANITIZED_REALLOC
return NULL; /* When P is non-null, ISO C23 §7.24.3.7.(3) says realloc (P, 0) has
undefined behavior even though C17 and earlier partially defined
the behavior. Let the programmer know.
When the undefined-behaviour sanitizers report this case, i.e. when
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117233> and
<https://github.com/llvm/llvm-project/issues/113065>
have been closed and new releases of GCC and clang have been made,
we can revisit this code. */
if (p != NULL)
abort ();
# endif
/* realloc (NULL, 0) acts like glibc malloc (0), i.e., like malloc (1)
except the caller cannot dereference any non-null return.
realloc (P, 0) with non-null P is a messier situation.
As mentioned above, C23 says behavior is undefined.
POSIX.1-2024 extends C17 to say realloc (P, 0)
either fails by setting errno and returning a null pointer,
or succeeds by freeing P and then either:
(a) setting errno=EINVAL and returning a null pointer; or
(b) acting like a successful malloc (0).
glibc 1 through 2.1 realloc acted like (b),
which conforms to C17, to C23 and to POSIX.1-2024.
glibc 2.1.1+ realloc acts like (a) except it does not set errno;
this conforms to C17 and to C23 but not to POSIX.1-2024.
Quite possibly future versions of POSIX will change,
due either to C23 or to (a)'s semantics being messy.
Act like (b), as that's easy, matches GNU, BSD and V7 malloc,
matches BSD and V7 realloc, and requires no extra code at
caller sites. */
# if !HAVE_REALLOC_0_NONNULL
n1 = 1;
# endif
} }
if (xalloc_oversized (n, 1)) # if !HAVE_MALLOC_PTRDIFF
ptrdiff_t signed_n;
if (ckd_add (&signed_n, n, 0))
{ {
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }
# endif
void *result = realloc (p, n); void *result = realloc (p, n1);
# if !HAVE_MALLOC_POSIX # if !HAVE_MALLOC_POSIX
if (result == NULL) if (result == NULL)
errno = ENOMEM; errno = ENOMEM;
# endif # endif
# ifdef __CHERI_PURE_CAPABILITY__
if (result != NULL)
result = cheri_bounds_set (result, n);
# endif
return result; return result;
} }
#endif

View file

@ -647,12 +647,14 @@ extern int re_exec (const char *);
|| 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
|| __clang_major__ >= 3 || __clang_major__ >= 3
# define _Restrict_ __restrict # define _Restrict_ __restrict
# elif 199901L <= __STDC_VERSION__ || defined restrict # else
# if 199901L <= __STDC_VERSION__ || defined restrict
# define _Restrict_ restrict # define _Restrict_ restrict
# else # else
# define _Restrict_ # define _Restrict_
# endif # endif
# endif # endif
#endif
/* For the ISO C99 syntax /* For the ISO C99 syntax
array_name[restrict] array_name[restrict]
use glibc's __restrict_arr if available. use glibc's __restrict_arr if available.
@ -661,7 +663,8 @@ extern int re_exec (const char *);
#ifndef _Restrict_arr_ #ifndef _Restrict_arr_
# ifdef __restrict_arr # ifdef __restrict_arr
# define _Restrict_arr_ __restrict_arr # define _Restrict_arr_ __restrict_arr
# elif ((199901L <= __STDC_VERSION__ \ # else
# if ((199901L <= __STDC_VERSION__ \
|| 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
|| __clang_major__ >= 3) \ || __clang_major__ >= 3) \
&& !defined __cplusplus) && !defined __cplusplus)
@ -670,6 +673,7 @@ extern int re_exec (const char *);
# define _Restrict_arr_ # define _Restrict_arr_
# endif # endif
# endif # endif
#endif
/* POSIX compatibility. */ /* POSIX compatibility. */
extern int regcomp (regex_t *_Restrict_ __preg, extern int regcomp (regex_t *_Restrict_ __preg,

View file

@ -937,8 +937,7 @@ re_node_set_alloc (re_node_set *set, Idx size)
set->alloc = size; set->alloc = size;
set->nelem = 0; set->nelem = 0;
set->elems = re_malloc (Idx, size); set->elems = re_malloc (Idx, size);
if (__glibc_unlikely (set->elems == NULL) if (__glibc_unlikely (set->elems == NULL))
&& (MALLOC_0_IS_NONNULL || size != 0))
return REG_ESPACE; return REG_ESPACE;
return REG_NOERROR; return REG_NOERROR;
} }

View file

@ -100,10 +100,12 @@
/* This is for other GNU distributions with internationalized messages. */ /* This is for other GNU distributions with internationalized messages. */
#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC #if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
# include <libintl.h> # include <libintl.h>
# ifdef _LIBC
# undef gettext # undef gettext
# ifdef _LIBC
# define gettext(msgid) \ # define gettext(msgid) \
__dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
# else
# define gettext(msgid) dgettext ("gnulib", msgid)
# endif # endif
#else #else
# undef gettext # undef gettext
@ -436,12 +438,6 @@ typedef struct re_dfa_t re_dfa_t;
#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
#ifdef _LIBC
# define MALLOC_0_IS_NONNULL 1
#elif !defined MALLOC_0_IS_NONNULL
# define MALLOC_0_IS_NONNULL 0
#endif
#ifndef MAX #ifndef MAX
# define MAX(a,b) ((a) < (b) ? (b) : (a)) # define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif #endif

View file

@ -110,7 +110,7 @@
# endif # endif
# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */ # if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
/* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> /* See <https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */ and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
struct __sfileext struct __sfileext

21
lib/stdlib.c Normal file
View file

@ -0,0 +1,21 @@
/* Inline functions for <stdlib.h>.
Copyright (C) 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_STDLIB_INLINE _GL_EXTERN_INLINE
#include <stdlib.h>

View file

@ -54,7 +54,7 @@
/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, /* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
_GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE,
GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */ _GL_INLINE_HEADER_BEGIN, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
#if !_GL_CONFIG_H_INCLUDED #if !_GL_CONFIG_H_INCLUDED
#error "Please include config.h first." #error "Please include config.h first."
#endif #endif
@ -130,6 +130,14 @@ struct random_data
# include <string> # include <string>
#endif #endif
_GL_INLINE_HEADER_BEGIN
#ifndef _GL_STDLIB_INLINE
# define _GL_STDLIB_INLINE _GL_INLINE
#endif
#ifndef _GL_REALLOC_INLINE
# define _GL_REALLOC_INLINE _GL_INLINE
#endif
/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
that can be freed by passing them as the Ith argument to the that can be freed by passing them as the Ith argument to the
function F. */ function F. */
@ -283,8 +291,8 @@ _GL_CXXALIASWARN (free);
#elif defined GNULIB_POSIXCHECK #elif defined GNULIB_POSIXCHECK
# undef free # undef free
/* Assume free is always declared. */ /* Assume free is always declared. */
_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - " _GL_WARN_ON_USE (free, "free is not POSIX:2024 compliant everywhere - "
"use gnulib module free for portability"); "use gnulib module free-posix for portability");
#endif #endif
@ -367,9 +375,10 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
#endif #endif
#if @GNULIB_CALLOC_POSIX@ #if @GNULIB_CALLOC_POSIX@
# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \ # if @REPLACE_CALLOC_FOR_CALLOC_POSIX@ \
|| (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@) || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
|| _GL_USE_STDLIB_ALLOC)
# undef calloc # undef calloc
# define calloc rpl_calloc # define calloc rpl_calloc
# endif # endif
@ -681,7 +690,7 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
by never specifying a zero size), so it does not need malloc or by never specifying a zero size), so it does not need malloc or
realloc to be redefined. */ realloc to be redefined. */
#if @GNULIB_MALLOC_POSIX@ #if @GNULIB_MALLOC_POSIX@
# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \ # if @REPLACE_MALLOC_FOR_MALLOC_POSIX@ \
|| (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@) || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
|| _GL_USE_STDLIB_ALLOC) || _GL_USE_STDLIB_ALLOC)
@ -740,11 +749,12 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
/* Return maximum number of bytes of a multibyte character. */ /* Return maximum number of bytes of a multibyte character. */
#if @REPLACE_MB_CUR_MAX@ #if @REPLACE_MB_CUR_MAX@
# if !GNULIB_defined_MB_CUR_MAX # if !GNULIB_defined_MB_CUR_MAX
static inline _GL_STDLIB_INLINE int
int gl_MB_CUR_MAX (void) gl_MB_CUR_MAX (void)
{ {
/* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */ /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */
return MB_CUR_MAX + (MB_CUR_MAX == 3); int gl_mb_cur_max = MB_CUR_MAX;
return gl_mb_cur_max == 3 ? 4 : gl_mb_cur_max;
} }
# undef MB_CUR_MAX # undef MB_CUR_MAX
# define MB_CUR_MAX gl_MB_CUR_MAX () # define MB_CUR_MAX gl_MB_CUR_MAX ()
@ -1454,16 +1464,25 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
#if @GNULIB_REALLOC_POSIX@ #if @GNULIB_REALLOC_POSIX@
# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \ # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@
|| (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@) # if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2
# define _GL_INLINE_RPL_REALLOC 1
_GL_REALLOC_INLINE void *
rpl_realloc (void *ptr, size_t size)
{
return realloc (ptr, size ? size : 1);
}
# endif
# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
|| _GL_USE_STDLIB_ALLOC) || _GL_USE_STDLIB_ALLOC)
# undef realloc # undef realloc
# define realloc rpl_realloc # define realloc rpl_realloc
# endif # endif
# if !defined _GL_INLINE_RPL_REALLOC
_GL_FUNCDECL_RPL (realloc, void *, _GL_FUNCDECL_RPL (realloc, void *,
(void *ptr, size_t size), (void *ptr, size_t size),
_GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD); _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD);
# endif
_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
# else # else
# if __GNUC__ >= 11 && !defined __clang__ # if __GNUC__ >= 11 && !defined __clang__
@ -1968,6 +1987,8 @@ _GL_CXXALIASWARN (wctomb);
#endif #endif
_GL_INLINE_HEADER_END
#endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif /* _@GUARD_PREFIX@_STDLIB_H */
#endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif /* _@GUARD_PREFIX@_STDLIB_H */
#endif #endif

View file

@ -30,8 +30,7 @@ __time64_t
__timegm64 (struct tm *tmp) __timegm64 (struct tm *tmp)
{ {
static mktime_offset_t gmtime_offset; static mktime_offset_t gmtime_offset;
tmp->tm_isdst = 0; return __mktime_internal (tmp, false, &gmtime_offset);
return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset);
} }
#if defined _LIBC && __TIMESIZE != 64 #if defined _LIBC && __TIMESIZE != 64

View file

@ -181,6 +181,9 @@ _GL_INLINE_HEADER_BEGIN
#ifndef _GL_UNISTD_INLINE #ifndef _GL_UNISTD_INLINE
# define _GL_UNISTD_INLINE _GL_INLINE # define _GL_UNISTD_INLINE _GL_INLINE
#endif #endif
#ifndef _GL_GETPAGESIZE_INLINE
# define _GL_GETPAGESIZE_INLINE _GL_INLINE
#endif
/* Hide some function declarations from <winsock2.h>. */ /* Hide some function declarations from <winsock2.h>. */
@ -1478,7 +1481,7 @@ _GL_FUNCDECL_SYS (getpagesize, int, (void), );
# define getpagesize() _gl_getpagesize () # define getpagesize() _gl_getpagesize ()
# else # else
# if !GNULIB_defined_getpagesize_function # if !GNULIB_defined_getpagesize_function
_GL_UNISTD_INLINE int _GL_GETPAGESIZE_INLINE int
getpagesize () getpagesize ()
{ {
return _gl_getpagesize (); return _gl_getpagesize ();

View file

@ -78,6 +78,21 @@ static int utimensat_works_really;
static int lutimensat_works_really; static int lutimensat_works_really;
#endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */ #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */
static bool
is_valid_timespec (struct timespec const *timespec)
{
return (timespec->tv_nsec == UTIME_NOW
|| timespec->tv_nsec == UTIME_OMIT
|| (0 <= timespec->tv_nsec && timespec->tv_nsec < TIMESPEC_HZ));
}
static bool
is_valid_timespecs (struct timespec const timespec[2])
{
return (is_valid_timespec (&timespec[0])
&& is_valid_timespec (&timespec[1]));
}
/* Validate the requested timestamps. Return 0 if the resulting /* Validate the requested timestamps. Return 0 if the resulting
timespec can be used for utimensat (after possibly modifying it to timespec can be used for utimensat (after possibly modifying it to
work around bugs in utimensat). Return a positive value if the work around bugs in utimensat). Return a positive value if the
@ -90,14 +105,7 @@ validate_timespec (struct timespec timespec[2])
{ {
int result = 0; int result = 0;
int utime_omit_count = 0; int utime_omit_count = 0;
if ((timespec[0].tv_nsec != UTIME_NOW if (!is_valid_timespecs (timespec))
&& timespec[0].tv_nsec != UTIME_OMIT
&& ! (0 <= timespec[0].tv_nsec
&& timespec[0].tv_nsec < TIMESPEC_HZ))
|| (timespec[1].tv_nsec != UTIME_NOW
&& timespec[1].tv_nsec != UTIME_OMIT
&& ! (0 <= timespec[1].tv_nsec
&& timespec[1].tv_nsec < TIMESPEC_HZ)))
{ {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
@ -516,24 +524,44 @@ fdutimens (int fd, char const *file, struct timespec const timespec[2])
} }
} }
#if !HAVE_UTIMENS
/* Set the access and modification timestamps of FILE to be /* Set the access and modification timestamps of FILE to be
TIMESPEC[0] and TIMESPEC[1], respectively. */ TIMESPEC[0] and TIMESPEC[1], respectively. */
int int
utimens (char const *file, struct timespec const timespec[2]) utimens (char const *file, struct timespec const timespec[2])
#undef utimens
{ {
return fdutimens (-1, file, timespec); #if HAVE_UTIMENS
/* NetBSD's native utimens() does not fulfil the Gnulib expectations:
At least in NetBSD 10.0, it does not validate the timespec argument. */
if (timespec != NULL && !is_valid_timespecs (timespec))
{
errno = EINVAL;
return -1;
} }
return utimens (file, timespec);
#else
return fdutimens (-1, file, timespec);
#endif #endif
}
#if !HAVE_LUTIMENS
/* Set the access and modification timestamps of FILE to be /* Set the access and modification timestamps of FILE to be
TIMESPEC[0] and TIMESPEC[1], respectively, without dereferencing TIMESPEC[0] and TIMESPEC[1], respectively, without dereferencing
symlinks. Fail with ENOSYS if the platform does not support symlinks. Fail with ENOSYS if the platform does not support
changing symlink timestamps, but FILE was a symlink. */ changing symlink timestamps, but FILE was a symlink. */
int int
lutimens (char const *file, struct timespec const timespec[2]) lutimens (char const *file, struct timespec const timespec[2])
#undef lutimens
{ {
#if HAVE_LUTIMENS
/* NetBSD's native lutimens() does not fulfil the Gnulib expectations:
At least in NetBSD 10.0, it does not validate the timespec argument. */
if (timespec != NULL && !is_valid_timespecs (timespec))
{
errno = EINVAL;
return -1;
}
return lutimens (file, timespec);
#else
struct timespec adjusted_timespec[2]; struct timespec adjusted_timespec[2];
struct timespec *ts = timespec ? adjusted_timespec : NULL; struct timespec *ts = timespec ? adjusted_timespec : NULL;
int adjustment_needed = 0; int adjustment_needed = 0;
@ -648,5 +676,5 @@ lutimens (char const *file, struct timespec const timespec[2])
return fdutimens (-1, file, ts); return fdutimens (-1, file, ts);
errno = ENOSYS; errno = ENOSYS;
return -1; return -1;
}
#endif #endif
}

View file

@ -33,12 +33,16 @@ extern "C" {
#endif #endif
int fdutimens (int, char const *, struct timespec const [2]); int fdutimens (int, char const *, struct timespec const [2]);
#if !HAVE_UTIMENS
#if HAVE_UTIMENS
# define utimens rpl_utimens
#endif
int utimens (char const *, struct timespec const [2]); int utimens (char const *, struct timespec const [2]);
#if HAVE_LUTIMENS
# define lutimens rpl_lutimens
#endif #endif
#if !HAVE_LUTIMENS
int lutimens (char const *, struct timespec const [2]); int lutimens (char const *, struct timespec const [2]);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl This file must be named something that sorts before all other dnl This file must be named something that sorts before all other
dnl gnulib-provided .m4 files. It is needed until the clang fix has dnl gnulib-provided .m4 files. It is needed until the clang fix has

View file

@ -4,6 +4,7 @@ dnl Copyright 2017-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Test for __inline keyword # Test for __inline keyword

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Derek Price. dnl From Derek Price.

View file

@ -1,9 +1,10 @@
# acl.m4 # acl.m4
# serial 31 # serial 34
dnl Copyright (C) 2002, 2004-2024 Free Software Foundation, Inc. dnl Copyright (C) 2002, 2004-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Check for access control list (ACL) primitives # Check for access control list (ACL) primitives
@ -15,9 +16,12 @@ AC_DEFUN([gl_FUNC_ACL_ARG],
AC_ARG_ENABLE([acl], AC_ARG_ENABLE([acl],
AS_HELP_STRING([[--disable-acl]], [do not support ACLs]), AS_HELP_STRING([[--disable-acl]], [do not support ACLs]),
, [enable_acl=auto]) , [enable_acl=auto])
AC_ARG_WITH([libsmack],
[AS_HELP_STRING([--without-libsmack],
[do not use libsmack, even on systems that have it])]
[], [with_libsmack=maybe])
]) ])
AC_DEFUN_ONCE([gl_FUNC_ACL], AC_DEFUN_ONCE([gl_FUNC_ACL],
[ [
AC_REQUIRE([gl_FUNC_ACL_ARG]) AC_REQUIRE([gl_FUNC_ACL_ARG])
@ -30,8 +34,8 @@ AC_DEFUN_ONCE([gl_FUNC_ACL],
if test $ac_cv_header_sys_acl_h = yes; then if test $ac_cv_header_sys_acl_h = yes; then
gl_saved_LIBS=$LIBS gl_saved_LIBS=$LIBS
dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, Mac OS X, dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, NetBSD >= 10,
dnl IRIX, Tru64, Cygwin >= 2.5). dnl Mac OS X, IRIX, Tru64, Cygwin >= 2.5).
dnl -lacl is needed on GNU/Linux, -lpacl on OSF/1. dnl -lacl is needed on GNU/Linux, -lpacl on OSF/1.
if test $use_acl = 0; then if test $use_acl = 0; then
AC_SEARCH_LIBS([acl_get_file], [acl pacl], AC_SEARCH_LIBS([acl_get_file], [acl pacl],
@ -40,6 +44,7 @@ AC_DEFUN_ONCE([gl_FUNC_ACL],
fi fi
AC_CHECK_FUNCS( AC_CHECK_FUNCS(
[acl_get_file acl_get_fd acl_set_file acl_set_fd \ [acl_get_file acl_get_fd acl_set_file acl_set_fd \
acl_get_link_np \
acl_free acl_from_mode acl_from_text \ acl_free acl_from_mode acl_from_text \
acl_delete_def_file acl_extended_file \ acl_delete_def_file acl_extended_file \
acl_delete_fd_np acl_delete_file_np \ acl_delete_fd_np acl_delete_file_np \
@ -189,9 +194,35 @@ AC_DEFUN([gl_FILE_HAS_ACL],
AC_CHECK_HEADERS_ONCE([linux/xattr.h]) AC_CHECK_HEADERS_ONCE([linux/xattr.h])
AC_CHECK_FUNCS_ONCE([listxattr]) AC_CHECK_FUNCS_ONCE([listxattr])
FILE_HAS_ACL_LIB= FILE_HAS_ACL_LIB=
AS_CASE([$enable_acl,$ac_cv_header_linux_xattr_h,$ac_cv_func_listxattr],
[no,*,*], [], gl_file_has_acl_uses_smack=no
[*,yes,yes], [], AS_CASE([$enable_acl,$with_libsmack,$ac_cv_header_linux_xattr_h,$ac_cv_func_listxattr],
[no,* | *,no,*], [],
[*,*,yes,yes],
[AC_CHECK_HEADER([sys/smack.h],
[gl_saved_LIBS=$LIBS
AC_SEARCH_LIBS([smack_new_label_from_path], [smack],
[AC_DEFINE([HAVE_SMACK], [1],
[Define to 1 if libsmack is usable.])
AS_CASE([$ac_cv_search_smack_new_label_from_path],
["none required"], [],
[FILE_HAS_ACL_LIB=$ac_cv_search_new_label_from_path])
gl_file_has_acl_uses_smack=yes],
[AS_CASE([$with_libsmack],
[yes], [AC_MSG_ERROR([libsmack not found or unusable])])])
LIBS=$gl_saved_LIBS])])
gl_file_has_acl_uses_selinux=no
AS_CASE([$enable_acl,$with_selinux,$ac_cv_header_linux_xattr_h,$ac_cv_func_listxattr],
[no,* | *,no,*], [],
[*,*,yes,yes],
[AC_REQUIRE([gl_CHECK_HEADER_SELINUX_SELINUX_H])
AS_IF([test $USE_SELINUX_SELINUX_H = 1],
[FILE_HAS_ACL_LIB="$FILE_HAS_ACL_LIB $LIB_SELINUX"
gl_file_has_acl_uses_selinux=yes])])
AS_CASE([$enable_acl,$gl_file_has_acl_uses_selinux,$gl_file_has_acl_uses_smack],
[no,* | *,yes,* | *,yes], [],
[*], [*],
[dnl Set gl_need_lib_has_acl to a nonempty value, so that any [dnl Set gl_need_lib_has_acl to a nonempty value, so that any
dnl later gl_FUNC_ACL call will set FILE_HAS_ACL_LIB=$LIB_ACL. dnl later gl_FUNC_ACL call will set FILE_HAS_ACL_LIB=$LIB_ACL.

View file

@ -5,6 +5,7 @@ dnl Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_ALLOCA], AC_DEFUN([gl_FUNC_ALLOCA],
[ [

View file

@ -1,9 +1,10 @@
# assert_h.m4 # assert_h.m4
# serial 1 # serial 4
dnl Copyright (C) 2011-2024 Free Software Foundation, Inc. dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Paul Eggert. dnl From Paul Eggert.
@ -14,7 +15,6 @@ AC_DEFUN([gl_ASSERT_H],
for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do
AS_CASE([$gl_working], AS_CASE([$gl_working],
[*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"]) [*assert.h*], [CFLAGS="$gl_saved_CFLAGS -DINCLUDE_ASSERT_H"])
AC_COMPILE_IFELSE( AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[[#if defined __clang__ && __STDC_VERSION__ < 202311 [[#if defined __clang__ && __STDC_VERSION__ < 202311
@ -30,12 +30,14 @@ AC_DEFUN([gl_ASSERT_H],
[[ [[
static_assert (sizeof (char) == 1, "sizeof does not work"); static_assert (sizeof (char) == 1, "sizeof does not work");
static_assert (sizeof (char) == 1); static_assert (sizeof (char) == 1);
]])], ]])
],
[gl_cv_static_assert=$gl_working], [gl_cv_static_assert=$gl_working],
[gl_cv_static_assert=no]) [gl_cv_static_assert=no])
CFLAGS=$gl_saved_CFLAGS CFLAGS=$gl_saved_CFLAGS
test "$gl_cv_static_assert" != no && break test "$gl_cv_static_assert" != no && break
done]) done
])
GL_GENERATE_ASSERT_H=false GL_GENERATE_ASSERT_H=false
AS_CASE([$gl_cv_static_assert], AS_CASE([$gl_cv_static_assert],
@ -48,6 +50,10 @@ AC_DEFUN([gl_ASSERT_H],
dnl The "zz" puts this toward config.h's end, to avoid potential dnl The "zz" puts this toward config.h's end, to avoid potential
dnl collisions with other definitions. dnl collisions with other definitions.
dnl Hardcode the known configuration results for GCC and clang, so that
dnl a configuration made with the C compiler works also with the C++ compiler
dnl and vice versa.
dnl The seemingly redundant parentheses are necessary for MSVC 14.
dnl #undef assert so that programs are not tempted to use it without dnl #undef assert so that programs are not tempted to use it without
dnl specifically including assert.h. dnl specifically including assert.h.
dnl #undef __ASSERT_H__ so that on IRIX, when programs later include dnl #undef __ASSERT_H__ so that on IRIX, when programs later include
@ -55,7 +61,16 @@ AC_DEFUN([gl_ASSERT_H],
dnl Break the #undef_s apart with a comment so that 'configure' does dnl Break the #undef_s apart with a comment so that 'configure' does
dnl not comment them out. dnl not comment them out.
AH_VERBATIM([zzstatic_assert], AH_VERBATIM([zzstatic_assert],
[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ [#if (!(defined __clang__ \
? (defined __cplusplus \
? __cplusplus >= 201703L \
: __STDC_VERSION__ >= 202000L && __clang_major__ >= 16) \
: (defined __GNUC__ \
? (defined __cplusplus \
? __cplusplus >= 201103L && __GNUG__ >= 6 \
: __STDC_VERSION__ >= 202000L && __GNUC__ >= 13) \
: defined HAVE_C_STATIC_ASSERT)) \
&& !defined assert \
&& (!defined __cplusplus \ && (!defined __cplusplus \
|| (__cpp_static_assert < 201411 \ || (__cpp_static_assert < 201411 \
&& __GNUG__ < 6 && __clang_major__ < 6))) && __GNUG__ < 6 && __clang_major__ < 6)))
@ -65,8 +80,9 @@ AC_DEFUN([gl_ASSERT_H],
#undef/**/__ASSERT_H__ #undef/**/__ASSERT_H__
#endif #endif
/* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments. /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
We need it also to be invocable with a single argument. */ We need it also to be invocable with a single argument.
#if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus Haiku 2022 <assert.h> does not define static_assert at all. */
#if (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
#undef/**/static_assert #undef/**/static_assert
#define static_assert _Static_assert #define static_assert _Static_assert
#endif #endif

View file

@ -4,6 +4,7 @@ dnl Copyright 2016-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Provide a GCC-compatible __builtin_expect macro in <config.h>. dnl Provide a GCC-compatible __builtin_expect macro in <config.h>.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2005, 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Written by Oskar Liljeblad. dnl Written by Oskar Liljeblad.

View file

@ -1,9 +1,10 @@
# c-bool.m4 # c-bool.m4
# serial 1 # serial 3
dnl Copyright 2022-2024 Free Software Foundation, Inc. dnl Copyright 2022-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Check for bool that conforms to C2023. # Check for bool that conforms to C2023.
@ -29,12 +30,23 @@ AC_DEFUN([gl_C_BOOL],
dnl The "zz" puts this toward config.h's end, to avoid potential dnl The "zz" puts this toward config.h's end, to avoid potential
dnl collisions with other definitions. dnl collisions with other definitions.
dnl If 'bool', 'true' and 'false' do not work, arrange for them to work. dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
dnl In C, this means including <stdbool.h> if it is not already included. dnl Hardcode the known configuration results for GCC and clang, so that
dnl a configuration made with the C compiler works also with the C++ compiler
dnl and vice versa.
dnl The seemingly redundant parentheses are necessary for MSVC 14.
dnl "Arrange for them to work", in C, means including <stdbool.h> if it is
dnl not already included.
dnl However, if the preprocessor mistakenly treats 'true' as 0, dnl However, if the preprocessor mistakenly treats 'true' as 0,
dnl define it to a bool expression equal to 1; this is needed in dnl define it to a bool expression equal to 1; this is needed in
dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older. dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
AH_VERBATIM([zzbool], AH_VERBATIM([zzbool],
[#ifndef HAVE_C_BOOL [#if !(defined __cplusplus \
? 1 \
: (defined __clang__ \
? __STDC_VERSION__ >= 202000L && __clang_major__ >= 15 \
: (defined __GNUC__ \
? __STDC_VERSION__ >= 202000L && __GNUC__ >= 13 \
: defined HAVE_C_BOOL)))
# if !defined __cplusplus && !defined __bool_true_false_are_defined # if !defined __cplusplus && !defined __bool_true_false_are_defined
# if HAVE_STDBOOL_H # if HAVE_STDBOOL_H
# include <stdbool.h> # include <stdbool.h>

View file

@ -6,6 +6,7 @@ dnl Copyright (C) 2003-2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Provides canonicalize_file_name and canonicalize_filename_mode, but does # Provides canonicalize_file_name and canonicalize_filename_mode, but does
# not provide or fix realpath. # not provide or fix realpath.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2006, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Check for clock_getres, clock_gettime and clock_settime, # Check for clock_getres, clock_gettime and clock_settime,
# and set CLOCK_TIME_LIB. # and set CLOCK_TIME_LIB.

View file

@ -5,6 +5,7 @@ dnl Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Bruno Haible. dnl From Bruno Haible.

View file

@ -4,6 +4,7 @@ dnl Copyright 2019-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_COPY_FILE_RANGE], AC_DEFUN([gl_FUNC_COPY_FILE_RANGE],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 1997, 1999-2004, 2006, 2009-2024 Free Software Foundation, Inc
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Jim Meyering. dnl From Jim Meyering.
dnl dnl

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Written by Bruno Haible. dnl Written by Bruno Haible.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2006, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Find out how to get the file descriptor associated with an open DIR*. dnl Find out how to get the file descriptor associated with an open DIR*.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2006, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_DOUBLE_SLASH_ROOT], AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2005, 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_DUP2], AC_DEFUN([gl_FUNC_DUP2],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright 2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl A placeholder for <endian.h>, for platforms that have issues. dnl A placeholder for <endian.h>, for platforms that have issues.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2004, 2006-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN_ONCE([gl_ENVIRON], AC_DEFUN_ONCE([gl_ENVIRON],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2004, 2006, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_PREREQ([2.61]) AC_PREREQ([2.61])

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_NONREENTRANT_EUIDACCESS], AC_DEFUN([gl_FUNC_NONREENTRANT_EUIDACCESS],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright 2012-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Check for GNU-style execinfo.h. # Check for GNU-style execinfo.h.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# On AIX, most extensions are already enabled through the _ALL_SOURCE macro, # On AIX, most extensions are already enabled through the _ALL_SOURCE macro,
# defined by gl_USE_SYSTEM_EXTENSIONS. gl_USE_AIX_EXTENSIONS additionally # defined by gl_USE_SYSTEM_EXTENSIONS. gl_USE_AIX_EXTENSIONS additionally

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Enable extensions on systems that normally disable them. # Enable extensions on systems that normally disable them.

View file

@ -4,6 +4,7 @@ dnl Copyright 2012-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl 'extern inline' a la ISO C99. dnl 'extern inline' a la ISO C99.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# See if we need to provide faccessat replacement. # See if we need to provide faccessat replacement.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2004-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Written by Jim Meyering. # Written by Jim Meyering.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# For now, this module ensures that fcntl() # For now, this module ensures that fcntl()
# - supports F_DUPFD correctly # - supports F_DUPFD correctly

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Configure fcntl.h. # Configure fcntl.h.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# See if we need to provide fdopendir. # See if we need to provide fdopendir.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2005-2006, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FILEMODE], AC_DEFUN([gl_FILEMODE],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Check for flexible array member support. # Check for flexible array member support.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2000-2001, 2004-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Jim Meyering dnl From Jim Meyering
dnl Using code from emacs, based on suggestions from Paul Eggert dnl Using code from emacs, based on suggestions from Paul Eggert

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl IEEE 754 standardized three items: dnl IEEE 754 standardized three items:
dnl - The formats of single-float and double-float - nowadays commonly dnl - The formats of single-float and double-float - nowadays commonly

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2003-2005, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Written by Paul Eggert and Bruno Haible. # Written by Paul Eggert and Bruno Haible.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2004-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Written by Jim Meyering. # Written by Jim Meyering.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 1997-1998, 2000-2001, 2003-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Obtaining file system usage information. # Obtaining file system usage information.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_FSYNC], AC_DEFUN([gl_FUNC_FSYNC],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# See if we need to provide futimens replacement. # See if we need to provide futimens replacement.

View file

@ -6,6 +6,7 @@ dnl
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_PREREQ([2.59]) AC_PREREQ([2.59])

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_GETDTABLESIZE], AC_DEFUN([gl_FUNC_GETDTABLESIZE],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 1996-1997, 1999-2004, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Jim Meyering. dnl From Jim Meyering.
dnl A wrapper around AC_FUNC_GETGROUPS. dnl A wrapper around AC_FUNC_GETGROUPS.

View file

@ -7,6 +7,7 @@ dnl
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_PREREQ([2.59]) AC_PREREQ([2.59])

View file

@ -5,6 +5,7 @@ dnl Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Check for getloadavg. # Check for getloadavg.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Request a POSIX compliant getopt function. # Request a POSIX compliant getopt function.
AC_DEFUN([gl_FUNC_GETOPT_POSIX], AC_DEFUN([gl_FUNC_GETOPT_POSIX],
@ -77,7 +78,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
fi fi
dnl POSIX 2008 does not specify leading '+' behavior, but see dnl POSIX 2008 does not specify leading '+' behavior, but see
dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on dnl https://austingroupbugs.net/view.php?id=191 for a recommendation on
dnl the next version of POSIX. For now, we only guarantee leading '+' dnl the next version of POSIX. For now, we only guarantee leading '+'
dnl behavior with getopt-gnu. dnl behavior with getopt-gnu.
if test -z "$gl_replace_getopt"; then if test -z "$gl_replace_getopt"; then

View file

@ -4,6 +4,7 @@ dnl Copyright 2020-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Written by Paul Eggert. dnl Written by Paul Eggert.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002, 2004-2006, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_GETTIME], AC_DEFUN([gl_GETTIME],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2001-2003, 2005, 2007, 2009-2024 Free Software Foundation, Inc
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Jim Meyering. dnl From Jim Meyering.

View file

@ -1,9 +1,10 @@
# gnulib-common.m4 # gnulib-common.m4
# serial 103 # serial 106
dnl Copyright (C) 2007-2024 Free Software Foundation, Inc. dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_PREREQ([2.62]) AC_PREREQ([2.62])
@ -842,6 +843,35 @@ AC_DEFUN([gl_COMMON_BODY], [
# define _GL_UNUSED_LABEL # define _GL_UNUSED_LABEL
# endif # endif
#endif #endif
/* The following attributes enable detection of multithread-safety problems
and resource leaks at compile-time, by clang ≥ 15, when the warning option
-Wthread-safety is enabled. For usage, see
<https://clang.llvm.org/docs/ThreadSafetyAnalysis.html>. */
#ifndef _GL_ATTRIBUTE_CAPABILITY_TYPE
# if __clang_major__ >= 15
# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept) \
__attribute__ ((__capability__ (concept)))
# else
# define _GL_ATTRIBUTE_CAPABILITY_TYPE(concept)
# endif
#endif
#ifndef _GL_ATTRIBUTE_ACQUIRE_CAPABILITY
# if __clang_major__ >= 15
# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource) \
__attribute__ ((__acquire_capability__ (resource)))
# else
# define _GL_ATTRIBUTE_ACQUIRE_CAPABILITY(resource)
# endif
#endif
#ifndef _GL_ATTRIBUTE_RELEASE_CAPABILITY
# if __clang_major__ >= 15
# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource) \
__attribute__ ((__release_capability__ (resource)))
# else
# define _GL_ATTRIBUTE_RELEASE_CAPABILITY(resource)
# endif
#endif
]) ])
AH_VERBATIM([c_linkage], AH_VERBATIM([c_linkage],
[/* In C++, there is the concept of "language linkage", that encompasses [/* In C++, there is the concept of "language linkage", that encompasses
@ -1351,6 +1381,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
dnl -Wno-type-limits >= 4.3 >= 3.9 dnl -Wno-type-limits >= 4.3 >= 3.9
dnl -Wno-undef >= 3 >= 3.9 dnl -Wno-undef >= 3 >= 3.9
dnl -Wno-unsuffixed-float-constants >= 4.5 dnl -Wno-unsuffixed-float-constants >= 4.5
dnl -Wno-unused-const-variable >= 4.4 >= 3.9
dnl -Wno-unused-function >= 3 >= 3.9 dnl -Wno-unused-function >= 3 >= 3.9
dnl -Wno-unused-parameter >= 3 >= 3.9 dnl -Wno-unused-parameter >= 3 >= 3.9
dnl dnl
@ -1380,6 +1411,9 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
-Wno-sign-conversion -Wno-sign-conversion
-Wno-type-limits -Wno-type-limits
#endif #endif
#if (__GNUC__ + (__GNUC_MINOR__ >= 4) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
-Wno-unused-const-variable
#endif
#if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__) #if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__)
-Wno-unsuffixed-float-constants -Wno-unsuffixed-float-constants
#endif #endif

View file

@ -162,7 +162,6 @@ AC_DEFUN([gl_EARLY],
# Code from module rawmemchr: # Code from module rawmemchr:
# Code from module readlink: # Code from module readlink:
# Code from module readlinkat: # Code from module readlinkat:
# Code from module realloc-gnu:
# Code from module realloc-posix: # Code from module realloc-posix:
# Code from module regex: # Code from module regex:
# Code from module root-uid: # Code from module root-uid:
@ -221,7 +220,6 @@ AC_DEFUN([gl_EARLY],
# Code from module verify: # Code from module verify:
# Code from module vla: # Code from module vla:
# Code from module warnings: # Code from module warnings:
# Code from module xalloc-oversized:
# Code from module year2038: # Code from module year2038:
AC_REQUIRE([AC_SYS_YEAR2038]) AC_REQUIRE([AC_SYS_YEAR2038])
]) ])
@ -424,6 +422,11 @@ AC_DEFUN([gl_INIT],
]) ])
gl_SYS_STAT_MODULE_INDICATOR([lstat]) gl_SYS_STAT_MODULE_INDICATOR([lstat])
gl_MODULE_INDICATOR([lstat]) gl_MODULE_INDICATOR([lstat])
AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
AC_LIBOBJ([malloc])
fi
gl_STDLIB_MODULE_INDICATOR([malloc-posix])
gl_FUNC_MEMMEM_SIMPLE gl_FUNC_MEMMEM_SIMPLE
if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then
AC_LIBOBJ([memmem]) AC_LIBOBJ([memmem])
@ -681,18 +684,15 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1=false
gl_gnulib_enabled_lchmod=false gl_gnulib_enabled_lchmod=false
gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b=false gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b=false
gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866=false
gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31=false
gl_gnulib_enabled_open=false gl_gnulib_enabled_open=false
gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7=false
gl_gnulib_enabled_rawmemchr=false gl_gnulib_enabled_rawmemchr=false
gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b=false
gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=false gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=false
gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c=false
gl_gnulib_enabled_strtoll=false gl_gnulib_enabled_strtoll=false
gl_gnulib_enabled_utimens=false gl_gnulib_enabled_utimens=false
gl_gnulib_enabled_verify=false gl_gnulib_enabled_verify=false
gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=false
func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b () func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b ()
{ {
if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then :; else if $gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b; then :; else
@ -788,9 +788,6 @@ AC_DEFUN([gl_INIT],
[test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1]) [test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1])
gl_UNISTD_MODULE_INDICATOR([getgroups]) gl_UNISTD_MODULE_INDICATOR([getgroups])
gl_gnulib_enabled_getgroups=true gl_gnulib_enabled_getgroups=true
if test $HAVE_GETGROUPS = 0 || test $REPLACE_GETGROUPS = 1; then
func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866
fi
fi fi
} }
func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 () func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 ()
@ -813,7 +810,6 @@ AC_DEFUN([gl_INIT],
if $gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9; then :; else if $gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9; then :; else
AC_PROG_MKDIR_P AC_PROG_MKDIR_P
gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9=true gl_gnulib_enabled_8444034ea779b88768865bb60b4fb8c9=true
func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866
func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4
fi fi
} }
@ -831,7 +827,7 @@ AC_DEFUN([gl_INIT],
func_gl_gnulib_m4code_getgroups func_gl_gnulib_m4code_getgroups
fi fi
if test $HAVE_GROUP_MEMBER = 0; then if test $HAVE_GROUP_MEMBER = 0; then
func_gl_gnulib_m4code_d3b2383720ee0e541357aa2aac598e2b func_gl_gnulib_m4code_e80bf6f757095d2e5fc94dafb8f8fc8b
fi fi
fi fi
} }
@ -856,24 +852,6 @@ AC_DEFUN([gl_INIT],
fi fi
gl_STDLIB_MODULE_INDICATOR([malloc-gnu]) gl_STDLIB_MODULE_INDICATOR([malloc-gnu])
gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b=true gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b=true
func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866
if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then
func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec
fi
fi
}
func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866 ()
{
if $gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866; then :; else
AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
AC_LIBOBJ([malloc])
fi
gl_STDLIB_MODULE_INDICATOR([malloc-posix])
gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866=true
if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec
fi
fi fi
} }
func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 () func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 ()
@ -920,39 +898,15 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_rawmemchr=true gl_gnulib_enabled_rawmemchr=true
fi fi
} }
func_gl_gnulib_m4code_d3b2383720ee0e541357aa2aac598e2b ()
{
if $gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b; then :; else
gl_FUNC_REALLOC_GNU
if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
AC_LIBOBJ([realloc])
fi
gl_STDLIB_MODULE_INDICATOR([realloc-gnu])
gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b=true
if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
func_gl_gnulib_m4code_e80bf6f757095d2e5fc94dafb8f8fc8b
fi
func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4
if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec
fi
fi
}
func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 () func_gl_gnulib_m4code_61bcaca76b3e6f9ae55d57a1c3193bc4 ()
{ {
if $gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4; then :; else if $gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4; then :; else
gl_FUNC_REALLOC_POSIX gl_FUNC_REALLOC_POSIX
if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then gl_FUNC_REALLOC_0_NONNULL
AC_LIBOBJ([realloc]) gl_CONDITIONAL([GL_COND_OBJ_REALLOC_POSIX],
fi [test $REPLACE_REALLOC_FOR_REALLOC_POSIX != 0])
gl_STDLIB_MODULE_INDICATOR([realloc-posix]) gl_STDLIB_MODULE_INDICATOR([realloc-posix])
gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=true gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4=true
if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then
func_gl_gnulib_m4code_ef455225c00f5049c808c2eda3e76866
fi
if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then
func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec
fi
fi fi
} }
func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c () func_gl_gnulib_m4code_6099e9737f757db36c47fa9d9f02e88c ()
@ -987,12 +941,6 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_verify=true gl_gnulib_enabled_verify=true
fi fi
} }
func_gl_gnulib_m4code_682e609604ccaac6be382e4ee3a4eaec ()
{
if $gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec; then :; else
gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec=true
fi
}
if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then
func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c func_gl_gnulib_m4code_925677f0343de64b89a9f0c790b4104c
fi fi
@ -1053,9 +1001,6 @@ AC_DEFUN([gl_INIT],
if $GL_GENERATE_IEEE754_H; then if $GL_GENERATE_IEEE754_H; then
func_gl_gnulib_m4code_endian func_gl_gnulib_m4code_endian
fi fi
if test $REPLACE_MKTIME = 1; then
func_gl_gnulib_m4code_verify
fi
if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then
func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
fi fi
@ -1065,6 +1010,9 @@ AC_DEFUN([gl_INIT],
if test $ac_use_included_regex = yes; then if test $ac_use_included_regex = yes; then
func_gl_gnulib_m4code_fd38c7e463b54744b77b98aeafb4fa7c func_gl_gnulib_m4code_fd38c7e463b54744b77b98aeafb4fa7c
fi fi
if test $ac_use_included_regex = yes; then
func_gl_gnulib_m4code_e80bf6f757095d2e5fc94dafb8f8fc8b
fi
if test $ac_use_included_regex = yes; then if test $ac_use_included_regex = yes; then
func_gl_gnulib_m4code_verify func_gl_gnulib_m4code_verify
fi fi
@ -1099,18 +1047,15 @@ AC_DEFUN([gl_INIT],
AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1]) AM_CONDITIONAL([gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1], [$gl_gnulib_enabled_a9786850e999ae65a836a6041e8e5ed1])
AM_CONDITIONAL([gl_GNULIB_ENABLED_lchmod], [$gl_gnulib_enabled_lchmod]) AM_CONDITIONAL([gl_GNULIB_ENABLED_lchmod], [$gl_gnulib_enabled_lchmod])
AM_CONDITIONAL([gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b], [$gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b]) AM_CONDITIONAL([gl_GNULIB_ENABLED_e80bf6f757095d2e5fc94dafb8f8fc8b], [$gl_gnulib_enabled_e80bf6f757095d2e5fc94dafb8f8fc8b])
AM_CONDITIONAL([gl_GNULIB_ENABLED_ef455225c00f5049c808c2eda3e76866], [$gl_gnulib_enabled_ef455225c00f5049c808c2eda3e76866])
AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31]) AM_CONDITIONAL([gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31], [$gl_gnulib_enabled_5264294aa0a5557541b53c8c741f7f31])
AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open]) AM_CONDITIONAL([gl_GNULIB_ENABLED_open], [$gl_gnulib_enabled_open])
AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7]) AM_CONDITIONAL([gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7], [$gl_gnulib_enabled_03e0aaad4cb89ca757653bd367a6ccb7])
AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr]) AM_CONDITIONAL([gl_GNULIB_ENABLED_rawmemchr], [$gl_gnulib_enabled_rawmemchr])
AM_CONDITIONAL([gl_GNULIB_ENABLED_d3b2383720ee0e541357aa2aac598e2b], [$gl_gnulib_enabled_d3b2383720ee0e541357aa2aac598e2b])
AM_CONDITIONAL([gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4], [$gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4]) AM_CONDITIONAL([gl_GNULIB_ENABLED_61bcaca76b3e6f9ae55d57a1c3193bc4], [$gl_gnulib_enabled_61bcaca76b3e6f9ae55d57a1c3193bc4])
AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c]) AM_CONDITIONAL([gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c], [$gl_gnulib_enabled_6099e9737f757db36c47fa9d9f02e88c])
AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll]) AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoll], [$gl_gnulib_enabled_strtoll])
AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens]) AM_CONDITIONAL([gl_GNULIB_ENABLED_utimens], [$gl_gnulib_enabled_utimens])
AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify]) AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify])
AM_CONDITIONAL([gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec], [$gl_gnulib_enabled_682e609604ccaac6be382e4ee3a4eaec])
# End of code from modules # End of code from modules
m4_ifval(gl_LIBSOURCES_LIST, [ m4_ifval(gl_LIBSOURCES_LIST, [
m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
@ -1468,6 +1413,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/stdio-read.c lib/stdio-read.c
lib/stdio-write.c lib/stdio-write.c
lib/stdio.in.h lib/stdio.in.h
lib/stdlib.c
lib/stdlib.in.h lib/stdlib.in.h
lib/stpcpy.c lib/stpcpy.c
lib/str-two-way.h lib/str-two-way.h
@ -1506,7 +1452,6 @@ AC_DEFUN([gl_FILE_LIST], [
lib/verify.h lib/verify.h
lib/vla.h lib/vla.h
lib/warn-on-use.h lib/warn-on-use.h
lib/xalloc-oversized.h
m4/00gnulib.m4 m4/00gnulib.m4
m4/__inline.m4 m4/__inline.m4
m4/absolute-header.m4 m4/absolute-header.m4
@ -1525,7 +1470,6 @@ AC_DEFUN([gl_FILE_LIST], [
m4/dirfd.m4 m4/dirfd.m4
m4/double-slash-root.m4 m4/double-slash-root.m4
m4/dup2.m4 m4/dup2.m4
m4/eealloc.m4
m4/endian_h.m4 m4/endian_h.m4
m4/environ.m4 m4/environ.m4
m4/errno_h.m4 m4/errno_h.m4
@ -1605,6 +1549,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/readutmp.m4 m4/readutmp.m4
m4/realloc.m4 m4/realloc.m4
m4/regex.m4 m4/regex.m4
m4/selinux-selinux-h.m4
m4/sha1.m4 m4/sha1.m4
m4/sha256.m4 m4/sha256.m4
m4/sha512.m4 m4/sha512.m4

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 1999-2001, 2003-2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Written by Jim Meyering dnl Written by Jim Meyering

View file

@ -4,6 +4,7 @@ dnl Copyright 2018-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Configure ieee754-h module # Configure ieee754-h module

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Paul Eggert and Derek Price. dnl From Paul Eggert and Derek Price.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2006-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Derek Price, Bruno Haible. dnl From Derek Price, Bruno Haible.
dnl Test whether <inttypes.h> is supported or must be substituted. dnl Test whether <inttypes.h> is supported or must be substituted.

View file

@ -4,6 +4,7 @@ dnl Copyright 1992-1996, 1998-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# Enable large files on systems where this is not the default. # Enable large files on systems where this is not the default.
# Enable support for files on Linux file systems with 64-bit inode numbers. # Enable support for files on Linux file systems with 64-bit inode numbers.
@ -294,7 +295,7 @@ AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])])
# By default, many hosts won't let programs access large files; # By default, many hosts won't let programs access large files;
# one must use special compiler options to get large-file access to work. # one must use special compiler options to get large-file access to work.
# For more details about this brain damage please see: # For more details about this brain damage please see:
# http://www.unix.org/version2/whatsnew/lfs20mar.html # https://www.unix.org/version2/whatsnew/lfs20mar.html
# Additionally, on Linux file systems with 64-bit inodes a file that happens # Additionally, on Linux file systems with 64-bit inodes a file that happens
# to have a 64-bit inode number cannot be accessed by 32-bit applications on # to have a 64-bit inode number cannot be accessed by 32-bit applications on
# Linux x86/x86_64. This can occur with file systems such as XFS and NFS. # Linux x86/x86_64. This can occur with file systems such as XFS and NFS.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2005-2006, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Paul Eggert. dnl From Paul Eggert.
dnl Provide a replacement for lchmod on hosts that lack a working version. dnl Provide a replacement for lchmod on hosts that lack a working version.

View file

@ -5,6 +5,7 @@ dnl Copyright 2020-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl gl_LIBGMP dnl gl_LIBGMP
dnl Search for an installed libgmp. dnl Search for an installed libgmp.

View file

@ -4,6 +4,7 @@ dnl Copyright 2016-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Check whether limits.h has needed features. dnl Check whether limits.h has needed features.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2003-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Bruno Haible. dnl From Bruno Haible.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 1997-2001, 2003-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Jim Meyering. dnl From Jim Meyering.

View file

@ -1,12 +1,24 @@
# malloc.m4 # malloc.m4
# serial 34 # serial 43
dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc. dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# This is adapted with modifications from upstream Autoconf here: m4_version_prereq([2.73], [], [
# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949 # Modules that use this macro directly or indirectly should depend
# on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined
# before this macro gets invoked. This helps on AIX 7.2 and earlier
# if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise.
#
# This is copied from upstream Autoconf here:
# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=1f38316f6af7bf63e5e7dd187ff6456e07ad743e#n971
# _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT[, UNKNOWN-ASSUME])
# ------------------------------------------------------
# If 'malloc (0)' returns nonnull, run IF-WORKS, otherwise, IF-NOT.
# If it is not known whether it works, assume the shell word UNKNOWN-ASSUME,
# which should end in "yes" or in something else (the latter is the default).
AC_DEFUN([_AC_FUNC_MALLOC_IF], AC_DEFUN([_AC_FUNC_MALLOC_IF],
[ [
AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
@ -15,61 +27,81 @@ AC_DEFUN([_AC_FUNC_MALLOC_IF],
[AC_RUN_IFELSE( [AC_RUN_IFELSE(
[AC_LANG_PROGRAM( [AC_LANG_PROGRAM(
[[#include <stdlib.h> [[#include <stdlib.h>
]], /* Use pmalloc to test; 'volatile' prevents the compiler
[[void *p = malloc (0); from optimizing the malloc call away. */
void * volatile vp = p; void *(*volatile pmalloc) (size_t) = malloc;]],
int result = !vp; [[void *p = pmalloc (0);
int result = !p;
free (p); free (p);
return result;]]) return result;]])],
],
[ac_cv_func_malloc_0_nonnull=yes], [ac_cv_func_malloc_0_nonnull=yes],
[ac_cv_func_malloc_0_nonnull=no], [ac_cv_func_malloc_0_nonnull=no],
[case "$host_os" in [AS_CASE([$host_os],
# Guess yes on platforms where we know the result. [# Guess yes on platforms where we know the result.
*-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \ *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
| gnu* | *-musl* | midipix* | midnightbsd* \ | gnu* | *-musl* | midipix* | midnightbsd* \
| hpux* | solaris* | cygwin* | mingw* | windows* | msys* ) | hpux* | solaris* | cygwin* | mingw* | windows* | msys*],
ac_cv_func_malloc_0_nonnull="guessing yes" ;; [ac_cv_func_malloc_0_nonnull="guessing yes"],
# If we don't know, obey --enable-cross-guesses. [# Guess as follows if we don't know.
*) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;; ac_cv_func_malloc_0_nonnull=m4_default([$3], ["guessing no"])])])])
esac
])
])
AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2]) AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2])
])# _AC_FUNC_MALLOC_IF ])# _AC_FUNC_MALLOC_IF
])
# gl_FUNC_MALLOC_0_NONNULL
# ------------------------
# If 'malloc (0)' returns nonnull define HAVE_MALLOC_0_NONNULL.
# Also, set ac_cv_func_malloc_0_nonnull to a string that ends in
# "yes", otherwise set it to something else. If unknown whether
# malloc (0) works, guess as normal for cross-builds.
AC_DEFUN([gl_FUNC_MALLOC_0_NONNULL],
[
_AC_FUNC_MALLOC_IF(
[AC_DEFINE([HAVE_MALLOC_0_NONNULL], [1],
[Define to 1 if malloc (0) returns nonnull.])],
[],
["$gl_cross_guess_normal"])
])
# gl_FUNC_MALLOC_GNU # gl_FUNC_MALLOC_GNU
# ------------------ # ------------------
# Replace malloc if it is not compatible with GNU libc. # Test whether malloc (0) is compatible with GNU libc.
# Replace malloc if not.
# Define HAVE_MALLOC_0_NONNULL if malloc (0) returns nonnull (except upon
# out-of-memory).
# Define HAVE_MALLOC_PTRDIFF if malloc (N) reliably fails when N exceeds
# PTRDIFF_MAX.
AC_DEFUN([gl_FUNC_MALLOC_GNU], AC_DEFUN([gl_FUNC_MALLOC_GNU],
[ [
AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
AC_REQUIRE([gl_FUNC_MALLOC_0_NONNULL])
dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT AS_CASE([$ac_cv_func_malloc_0_nonnull],
dnl gets defined already before this macro gets invoked. This helps [*yes],
dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise. [REPLACE_MALLOC_FOR_MALLOC_GNU=$REPLACE_MALLOC_FOR_MALLOC_POSIX],
[REPLACE_MALLOC_FOR_MALLOC_GNU=1])
REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX"
if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then
_AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
fi
]) ])
# gl_FUNC_MALLOC_PTRDIFF # gl_FUNC_MALLOC_PTRDIFF
# ---------------------- # ----------------------
# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX, # Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX.
# and replace malloc otherwise. # Define HAVE_MALLOC_PTRDIFF if yes.
# Replace malloc if not.
AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF], AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF],
[ [
AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF]) AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1 AS_IF([test "$gl_cv_malloc_ptrdiff" = yes],
[AC_DEFINE([HAVE_MALLOC_PTRDIFF], 1,
[Define to 1 if malloc-like functions do not allocate objects
larger than PTRDIFF_MAX bytes.])],
[REPLACE_MALLOC_FOR_MALLOC_POSIX=1])
]) ])
# Test whether malloc, realloc, calloc refuse to create objects # Test whether malloc, realloc, calloc refuse to create objects
# larger than what can be expressed in ptrdiff_t. # larger than what can be expressed in ptrdiff_t.
# Set gl_cv_func_malloc_gnu to yes or no accordingly. # Set gl_cv_func_malloc_gnu.
AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF], AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF],
[ [
AC_CACHE_CHECK([whether malloc is ptrdiff_t safe], AC_CACHE_CHECK([whether malloc is ptrdiff_t safe],
@ -113,16 +145,19 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF]) AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF])
AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
if test "$gl_cv_func_malloc_posix" = yes; then case "$gl_cv_func_malloc_posix" in
*yes)
AC_DEFINE([HAVE_MALLOC_POSIX], [1], AC_DEFINE([HAVE_MALLOC_POSIX], [1],
[Define if malloc, realloc, and calloc set errno on allocation failure.]) [Define if malloc, realloc, and calloc set errno on allocation failure.])
else ;;
*)
REPLACE_MALLOC_FOR_MALLOC_POSIX=1 REPLACE_MALLOC_FOR_MALLOC_POSIX=1
fi ;;
esac
]) ])
# Test whether malloc, realloc, calloc set errno to ENOMEM on failure. # Test whether malloc, realloc, calloc set errno to ENOMEM on failure.
# Set gl_cv_func_malloc_posix to yes or no accordingly. # Set gl_cv_func_malloc_posix to *yes or *no accordingly.
AC_DEFUN([gl_CHECK_MALLOC_POSIX], AC_DEFUN([gl_CHECK_MALLOC_POSIX],
[ [
AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_CANONICAL_HOST])
@ -133,10 +168,24 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX],
dnl some systems go to their knees when you do that. So assume that dnl some systems go to their knees when you do that. So assume that
dnl all Unix implementations of the function set errno on failure, dnl all Unix implementations of the function set errno on failure,
dnl except on those platforms where we have seen 'test-malloc-gnu', dnl except on those platforms where we have seen 'test-malloc-gnu',
dnl 'test-realloc-gnu', 'test-calloc-gnu' fail. dnl 'test-realloc-posix', 'test-calloc-gnu' fail.
case "$host_os" in case "$host_os" in
mingw* | windows*) mingw* | windows*)
gl_cv_func_malloc_posix=no ;; dnl Old MSVCRT from 2001 did not set errno=ENOMEM when malloc failed.
dnl More recent MSVCRT from 2019 does so.
dnl UCRT is the successor of MSVCRT. Assume that UCRT does so as well.
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdio.h>
#ifndef _UCRT
msvcrt yuck
#endif
]],
[[]])
],
[gl_cv_func_malloc_posix="guessing yes"],
[gl_cv_func_malloc_posix="guessing no"])
;;
irix* | solaris*) irix* | solaris*)
dnl On IRIX 6.5, the three functions return NULL with errno unset dnl On IRIX 6.5, the three functions return NULL with errno unset
dnl when the argument is larger than PTRDIFF_MAX. dnl when the argument is larger than PTRDIFF_MAX.

View file

@ -1,9 +1,10 @@
# manywarnings.m4 # manywarnings.m4
# serial 27 # serial 28
dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl From Simon Josefsson dnl From Simon Josefsson
@ -185,6 +186,9 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC(C)],
esac esac
fi fi
# These options are not supported by gcc, but are useful with clang.
AS_VAR_APPEND([$1], [' -Wthread-safety'])
# Disable specific options as needed. # Disable specific options as needed.
if test "$gl_cv_cc_nomfi_needed" = yes; then if test "$gl_cv_cc_nomfi_needed" = yes; then
AS_VAR_APPEND([$1], [' -Wno-missing-field-initializers']) AS_VAR_APPEND([$1], [' -Wno-missing-field-initializers'])

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2000-2002, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
# From Paul Eggert. # From Paul Eggert.

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_MD5], AC_DEFUN([gl_MD5],
[ [

View file

@ -4,6 +4,7 @@ dnl Copyright (C) 2002-2004, 2007-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
dnl Check that memmem is present and functional. dnl Check that memmem is present and functional.
AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE],

View file

@ -5,6 +5,7 @@ dnl Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_MEMPCPY], AC_DEFUN([gl_FUNC_MEMPCPY],
[ [

View file

@ -5,6 +5,7 @@ dnl Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_MEMRCHR], AC_DEFUN([gl_FUNC_MEMRCHR],
[ [

Some files were not shown because too many files have changed in this diff Show more