diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2025-05-07 23:57:18 -0700 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2025-05-08 00:16:46 -0700 |
| commit | c9c6abfa81c58b4a62f4fa5fcaad94b219f5d706 (patch) | |
| tree | d018390e6532a07121cc64e4ce7c80c7618f9876 /lib | |
| parent | 322ed637b4c2fe826d41c5af3800b2f2e381bb0f (diff) | |
Update from Gnulib by running admin/merge-gnulib
The following changes were made by hand,
so that admin/merge-gnulib could succeed
instead of failing because the diff didn’t match.
* admin/gnulib-patches/lib/getloadavg.c.diff:
Remove, as it is no longer needed now that recent
Gnulib has been merged.
* admin/merge-gnulib (GNULIB_TOOL_FLAGS):
Remove the --local-dir="$src"admin/gnulib-patches option,
as it is no longer needed either.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/attribute.h | 14 | ||||
| -rw-r--r-- | lib/cdefs.h | 2 | ||||
| -rw-r--r-- | lib/diffseq.h | 7 | ||||
| -rw-r--r-- | lib/getloadavg.c | 10 | ||||
| -rw-r--r-- | lib/gnulib.mk.in | 1 | ||||
| -rw-r--r-- | lib/stddef.in.h | 2 | ||||
| -rw-r--r-- | lib/stdlib.in.h | 30 | ||||
| -rw-r--r-- | lib/string.in.h | 75 | ||||
| -rw-r--r-- | lib/utimensat.c | 2 |
9 files changed, 117 insertions, 26 deletions
diff --git a/lib/attribute.h b/lib/attribute.h index 625195c8565..ae7bbe8e2cb 100644 --- a/lib/attribute.h +++ b/lib/attribute.h @@ -85,10 +85,10 @@ _GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_LEAF, _GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_MAY_ALIAS, _GL_ATTRIBUTE_MAYBE_UNUSED, _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE, _GL_ATTRIBUTE_NONNULL, - _GL_ATTRIBUTE_NONSTRING, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, - _GL_ATTRIBUTE_PURE, _GL_ATTRIBUTE_REPRODUCIBLE, - _GL_ATTRIBUTE_RETURNS_NONNULL, _GL_ATTRIBUTE_SENTINEL, - _GL_ATTRIBUTE_UNSEQUENCED. */ + _GL_ATTRIBUTE_NONNULL_IF_NONZERO, _GL_ATTRIBUTE_NONSTRING, + _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE, + _GL_ATTRIBUTE_REPRODUCIBLE, _GL_ATTRIBUTE_RETURNS_NONNULL, + _GL_ATTRIBUTE_SENTINEL, _GL_ATTRIBUTE_UNSEQUENCED. */ #if !_GL_CONFIG_H_INCLUDED #error "Please include config.h first." #endif @@ -170,6 +170,12 @@ /* Applies to: functions. */ #define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args) +/* ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) - Argument NP (a pointer) + must not be NULL if the argument NI (an integer) is != 0. */ +/* Applies to: functions. */ +#define ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (np, ni) + + /* The function's return value is a non-NULL pointer. */ /* Applies to: functions. */ #define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL diff --git a/lib/cdefs.h b/lib/cdefs.h index 53269033d9d..65da09dc096 100644 --- a/lib/cdefs.h +++ b/lib/cdefs.h @@ -482,7 +482,7 @@ run in pedantic mode if the uses are carefully marked using the `__extension__' keyword. But this is not generally available before version 2.8. */ -#if !(__GNUC_PREREQ (2,8) || defined __clang__) +#if ! (__GNUC_PREREQ (2,8) || defined __clang__ || 0x5150 <= __SUNPRO_C) # define __extension__ /* Ignore */ #endif diff --git a/lib/diffseq.h b/lib/diffseq.h index 8a823f98ea0..914bc643bb4 100644 --- a/lib/diffseq.h +++ b/lib/diffseq.h @@ -77,6 +77,11 @@ #include "minmax.h" */ +/* This file uses _GL_GNUC_PREREQ. */ +#if !_GL_CONFIG_H_INCLUDED + #error "Please include config.h first." +#endif + /* Maximum value of type OFFSET. */ #ifndef OFFSET_MAX # define OFFSET_MAX \ @@ -93,7 +98,7 @@ #endif /* Suppress gcc's "...may be used before initialized" warnings, - generated by GCC versions up to at least GCC 14.2. + generated by GCC versions up to at least GCC 15.1. Likewise for gcc -fanalyzer's "use of uninitialized value" warnings. */ #if _GL_GNUC_PREREQ (4, 7) # pragma GCC diagnostic push diff --git a/lib/getloadavg.c b/lib/getloadavg.c index 1cb1c01097d..752ec1f5ae7 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -140,7 +140,7 @@ # define SUNOS_5 # endif -# if defined (__osf__) && (defined (__alpha) || defined (__alpha__)) +# if defined (__osf__) && defined (__alpha) # define OSF_ALPHA # include <sys/mbuf.h> # include <sys/socket.h> @@ -499,9 +499,9 @@ getloadavg (double loadavg[], int nelem) } # endif -# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__) \ - && (!defined __ANDROID__ || __ANDROID_API__ >= 13) - /* Linux without glibc, Android, Cygwin */ +# if (!defined LDAV_DONE \ + && (defined __ANDROID__ ? 13 <= __ANDROID_API__ : defined __linux__)) + /* non-Android Linux without glibc, Android 3.2+, Cygwin */ # define LDAV_DONE # undef LOAD_AVE_TYPE @@ -514,7 +514,7 @@ getloadavg (double loadavg[], int nelem) loadavg[2] = info.loads[2] / (double)(1U << SI_LOAD_SHIFT); elem = 3; } -# endif /* __linux__ || __ANDROID__ */ +# endif /* __ANDROID__ ? 13 <= __ANDROID_API__ : __linux__ */ # if !defined (LDAV_DONE) && defined __CYGWIN__ /* Cygwin */ diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index cf7d0470f67..fb34cf2cc1d 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -22,7 +22,6 @@ # Generated by gnulib-tool. # Reproduce by: # gnulib-tool --import \ -# --local-dir=./admin/gnulib-patches \ # --lib=libgnu \ # --source-base=lib \ # --m4-base=m4 \ diff --git a/lib/stddef.in.h b/lib/stddef.in.h index 3e4a8ec6032..dc689b8df80 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -31,7 +31,7 @@ || defined __need_ptrdiff_t || defined __need_NULL \ || defined __need_wint_t) \ /* Avoid warning triggered by "gcc -std=gnu23 -Wsystem-headers" \ - in Fedora 40 with gcc 14.0.1. \ + in GCC 13.3 and 14.2 \ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870>. */ \ && !@STDDEF_NOT_IDEMPOTENT@ /* Special invocation convention inside gcc header files. In diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index dbe8ebc8502..1342db48772 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -168,6 +168,18 @@ _GL_INLINE_HEADER_BEGIN # endif #endif +/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP + (a pointer) must not be NULL if the argument NI (an integer) is != 0. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO +# if __GNUC__ >= 15 && !defined __clang__ +# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \ + __attribute__ ((__nonnull_if_nonzero__ (np, ni))) +# else +# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) +# endif +#endif + /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. */ #ifndef _GL_ATTRIBUTE_NOTHROW @@ -223,6 +235,18 @@ _GL_INLINE_HEADER_BEGIN #endif +/* Declarations for ISO C N3322. */ +#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__ +_GL_EXTERN_C void *bsearch (const void *__key, + const void *__base, size_t __nmemb, size_t __size, + int (*__compare) (const void *, const void *)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3) _GL_ARG_NONNULL ((5)); +_GL_EXTERN_C void qsort (void *__base, size_t __nmemb, size_t __size, + int (*__compare) (const void *, const void *)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ARG_NONNULL ((4)); +#endif + + #if @GNULIB__EXIT@ /* Terminate the current process with the given return code, without running the 'atexit' handlers. */ @@ -1182,7 +1206,8 @@ typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *); _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, void *arg), - _GL_ARG_NONNULL ((1, 4))); + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) + _GL_ARG_NONNULL ((4))); _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, void *arg)); @@ -1191,7 +1216,8 @@ _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, void *arg), - _GL_ARG_NONNULL ((1, 4))); + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) + _GL_ARG_NONNULL ((4))); # endif _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, _gl_qsort_r_compar_fn compare, diff --git a/lib/string.in.h b/lib/string.in.h index 44b9497d802..e7642211685 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -116,6 +116,18 @@ # endif #endif +/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP + (a pointer) must not be NULL if the argument NI (an integer) is != 0. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO +# if __GNUC__ >= 15 && !defined __clang__ +# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \ + __attribute__ ((__nonnull_if_nonzero__ (np, ni))) +# else +# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) +# endif +#endif + /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. */ #ifndef _GL_ATTRIBUTE_NOTHROW @@ -154,6 +166,7 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ + /* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have been included yet. */ #if @GNULIB_FREE_POSIX@ @@ -198,6 +211,44 @@ _GL_EXTERN_C void free (void *); # endif #endif + +/* Declarations for ISO C N3322. */ +#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__ +_GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +_GL_EXTERN_C void *memccpy (void *__dest, const void *__src, int __c, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 4) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 4); +_GL_EXTERN_C void *memmove (void *__dest, const void *__src, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +_GL_EXTERN_C char *strncpy (char *__dest, const char *__src, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +_GL_EXTERN_C char *strndup (const char *__s, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2); +_GL_EXTERN_C char *strncat (char *__dest, const char *__src, size_t __n) + _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +_GL_EXTERN_C int memcmp (const void *__s1, const void *__s2, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +_GL_EXTERN_C int strncmp (const char *__s1, const char *__s2, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +# ifndef __cplusplus +_GL_EXTERN_C void *memchr (const void *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); +_GL_EXTERN_C void *memrchr (const void *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); +# endif +_GL_EXTERN_C void *memset (void *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); +_GL_EXTERN_C void *memset_explicit (void *__s, int __c, size_t __n) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); +#endif + + /* Clear a block of memory. The compiler will not delete a call to this function, even if the block is dead after the call. */ #if @GNULIB_EXPLICIT_BZERO@ @@ -215,6 +266,7 @@ _GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - " # endif #endif + /* Find the index of the least-significant set bit. */ #if @GNULIB_FFSL@ # if !@HAVE_FFSL@ @@ -281,7 +333,7 @@ _GL_CXXALIASWARN (memccpy); # endif _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n), _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else /* On some systems, this function is defined as an overloaded function: @@ -388,7 +440,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " # if ! @HAVE_DECL_MEMRCHR@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t), _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const void * std::memrchr (const void *, int, size_t); } @@ -425,12 +477,14 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " # define memset_explicit rpl_memset_explicit # endif _GL_FUNCDECL_RPL (memset_explicit, void *, - (void *__dest, int __c, size_t __n), _GL_ARG_NONNULL ((1))); + (void *__dest, int __c, size_t __n), + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); _GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n)); # else # if !@HAVE_MEMSET_EXPLICIT@ _GL_FUNCDECL_SYS (memset_explicit, void *, - (void *__dest, int __c, size_t __n), _GL_ARG_NONNULL ((1))); + (void *__dest, int __c, size_t __n), + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)); # endif _GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n)); # endif @@ -697,7 +751,8 @@ _GL_CXXALIASWARN (strdup); # endif _GL_FUNCDECL_RPL (strncat, char *, (char *restrict dest, const char *restrict src, size_t n), - _GL_ARG_NONNULL ((1, 2))); + _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3)); _GL_CXXALIAS_RPL (strncat, char *, (char *restrict dest, const char *restrict src, size_t n)); # else @@ -724,7 +779,7 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - " # endif _GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n), - _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); # else @@ -733,13 +788,13 @@ _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n), - _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n), - _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif # endif @@ -752,13 +807,13 @@ _GL_CXXALIASWARN (strndup); # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n), - _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE) _GL_ATTRIBUTE_NOTHROW; # else _GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n), - _GL_ARG_NONNULL ((1)) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); # endif # endif diff --git a/lib/utimensat.c b/lib/utimensat.c index ca1d39e5900..fcf2d27eb3e 100644 --- a/lib/utimensat.c +++ b/lib/utimensat.c @@ -118,7 +118,7 @@ rpl_utimensat (int fd, char const *file, struct timespec const times[2], ts[1] = times[1]; times = ts; } -# if defined __hppa__ || defined __NetBSD__ +# if defined __hppa || defined __NetBSD__ /* Linux kernel 2.6.22.19 on hppa does not reject invalid tv_nsec values. |
