diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:06:52 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2025-10-18 19:06:52 +0200 |
commit | 27dae84ed92f1ef0300263091972338d12e78348 (patch) | |
tree | 7c52931f474fafb8a4bd4fd15ca3461c77cdecc2 /lib/stdlib.in.h | |
parent | 4682deeb62247d34de87f8e777f99e2d337fd377 (diff) |
New upstream version 1.4.1upstream/1.4.1upstream
Diffstat (limited to 'lib/stdlib.in.h')
-rw-r--r-- | lib/stdlib.in.h | 118 |
1 files changed, 88 insertions, 30 deletions
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 6667f426..bef0aaaf 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -1,6 +1,6 @@ /* A GNU-like <stdlib.h>. - Copyright (C) 1995, 2001-2004, 2006-2024 Free Software Foundation, Inc. + Copyright (C) 1995, 2001-2004, 2006-2025 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 @@ -54,7 +54,7 @@ /* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, _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 #error "Please include config.h first." #endif @@ -62,11 +62,6 @@ /* NetBSD 5.0 mis-defines NULL. */ #include <stddef.h> -/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */ -#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS -# include <sys/wait.h> -#endif - /* Solaris declares getloadavg() in <sys/loadavg.h>. */ #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ /* OpenIndiana has a bug: <sys/time.h> must be included before @@ -82,13 +77,6 @@ #if @GNULIB_RANDOM_R@ -/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included - from <stdlib.h> if _REENTRANT is defined. Include it whenever we need - 'struct random_data'. */ -# if @HAVE_RANDOM_H@ -# include <random.h> -# endif - # include <stdint.h> # if !@HAVE_STRUCT_RANDOM_DATA@ @@ -119,17 +107,25 @@ struct random_data # include <unistd.h> #endif -#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && defined __sun +#if ((@GNULIB_STRTOL@ && @REPLACE_STRTOL@) || (@GNULIB_STRTOLL@ && @REPLACE_STRTOLL@) || (@GNULIB_STRTOUL@ && @REPLACE_STRTOUL@) || (@GNULIB_STRTOULL@ && @REPLACE_STRTOULL@)) && defined __cplusplus && !defined GNULIB_NAMESPACE && defined __GNUG__ && !defined __clang__ && (defined __sun || defined _AIX) /* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro below, this may cause compilation errors later in the libstdc++ header files (that are part of GCC), such as: error: 'rpl_strtol' is not a member of 'std' To avoid this, include the relevant header files here, before these symbols - get defined as macros. But do so only on Solaris 11 (where it is needed), - not on mingw (where it would cause other compilation errors). */ + get defined as macros. But do so only on Solaris 11 and AIX (where it is + needed), not on mingw (where it would cause other compilation errors). */ # include <string> #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 that can be freed by passing them as the Ith argument to the function F. */ @@ -159,6 +155,18 @@ struct random_data # 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 @@ -214,6 +222,18 @@ struct random_data #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. */ @@ -283,8 +303,8 @@ _GL_CXXALIASWARN (free); #elif defined GNULIB_POSIXCHECK # undef free /* Assume free is always declared. */ -_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - " - "use gnulib module free for portability"); +_GL_WARN_ON_USE (free, "free is not POSIX:2024 compliant everywhere - " + "use gnulib module free-posix for portability"); #endif @@ -367,9 +387,10 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - " #endif #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@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ + || _GL_USE_STDLIB_ALLOC) # undef calloc # define calloc rpl_calloc # endif @@ -681,7 +702,7 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - " by never specifying a zero size), so it does not need malloc or realloc to be redefined. */ #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@) # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ || _GL_USE_STDLIB_ALLOC) @@ -737,14 +758,20 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " # endif #endif -/* Return maximum number of bytes of a multibyte character. */ +/* Return maximum number of bytes in a multibyte character in the + current locale. */ #if @REPLACE_MB_CUR_MAX@ # if !GNULIB_defined_MB_CUR_MAX -static inline -int gl_MB_CUR_MAX (void) +_GL_STDLIB_INLINE size_t +gl_MB_CUR_MAX (void) { +# if 0 < @REPLACE_MB_CUR_MAX@ + return @REPLACE_MB_CUR_MAX@; +# else /* 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; +# endif } # undef MB_CUR_MAX # define MB_CUR_MAX gl_MB_CUR_MAX () @@ -1166,7 +1193,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)); @@ -1175,7 +1203,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, @@ -1454,16 +1483,31 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " #if @GNULIB_REALLOC_POSIX@ -# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \ - || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@) +# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ +# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2 +# define _GL_INLINE_RPL_REALLOC 1 +# ifdef __cplusplus +extern "C" { +# endif +_GL_REALLOC_INLINE void * +rpl_realloc (void *ptr, size_t size) +{ + return realloc (ptr, size ? size : 1); +} +# ifdef __cplusplus +} +# endif +# endif # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ || _GL_USE_STDLIB_ALLOC) # undef realloc # define realloc rpl_realloc # endif +# if !defined _GL_INLINE_RPL_REALLOC _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size), _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD); +# endif _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); # else # if __GNUC__ >= 11 && !defined __clang__ @@ -1968,6 +2012,20 @@ _GL_CXXALIASWARN (wctomb); #endif +_GL_INLINE_HEADER_END + + +/* Includes that provide only macros that don't need to be overridden. + (Includes that are needed for type definitions and function declarations + have their place above, before the function overrides.) */ + +/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. + glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */ +#if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP) +# include <sys/wait.h> +#endif + + #endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif /* _@GUARD_PREFIX@_STDLIB_H */ #endif |