summaryrefslogtreecommitdiffstats
path: root/gl/stdlib.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/stdlib.in.h')
-rw-r--r--gl/stdlib.in.h497
1 files changed, 322 insertions, 175 deletions
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index e74e7c18..1342db48 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2024 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2025 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -20,12 +20,27 @@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc 23#if ((defined __need_system_stdlib_h && !defined _GLIBCXX_STDLIB_H) \
24 || defined __need_malloc_and_calloc) \
25 && !defined __SUNPRO_CC
24/* Special invocation conventions inside some gnulib header files, 26/* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */ 27 and inside some glibc header files, respectively.
28 Do not recognize this special invocation convention when GCC's
29 c++/11/stdlib.h is being included or has been included. This is needed
30 to support the use of clang+llvm binaries on Ubuntu 22.04 with
31 CXX="$clangdir/bin/clang++ -I/usr/include/c++/11 \
32 -I/usr/include/x86_64-linux-gnu/c++/11
33 -L/usr/lib/gcc/x86_64-linux-gnu/11
34 -Wl,-rpath,$clangdir/lib"
35 because in this case /usr/include/c++/11/stdlib.h (which does not support
36 the convention) is seen before the gnulib-generated stdlib.h. */
26 37
27#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ 38#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
28 39
40/* Make sure that the macros that indicate the special invocation convention
41 get undefined. This is needed at least on CentOS 7. */
42#undef __need_malloc_and_calloc
43
29#else 44#else
30/* Normal invocation convention. */ 45/* Normal invocation convention. */
31 46
@@ -38,8 +53,8 @@
38#define _@GUARD_PREFIX@_STDLIB_H 53#define _@GUARD_PREFIX@_STDLIB_H
39 54
40/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC, 55/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
41 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK, 56 _GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE,
42 HAVE_RAW_DECL_*. */ 57 _GL_INLINE_HEADER_BEGIN, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
43#if !_GL_CONFIG_H_INCLUDED 58#if !_GL_CONFIG_H_INCLUDED
44 #error "Please include config.h first." 59 #error "Please include config.h first."
45#endif 60#endif
@@ -47,8 +62,9 @@
47/* NetBSD 5.0 mis-defines NULL. */ 62/* NetBSD 5.0 mis-defines NULL. */
48#include <stddef.h> 63#include <stddef.h>
49 64
50/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */ 65/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>.
51#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS 66 glibc 2.41 defines WCOREDUMP in <sys/wait.h>, not in <stdlib.h>. */
67#if @GNULIB_SYSTEM_POSIX@ && !(defined WEXITSTATUS && defined WCOREDUMP)
52# include <sys/wait.h> 68# include <sys/wait.h>
53#endif 69#endif
54 70
@@ -104,11 +120,30 @@ struct random_data
104# include <unistd.h> 120# include <unistd.h>
105#endif 121#endif
106 122
123#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)
124/* When strtol, strtoll, strtoul, or strtoull is going to be defined as a macro
125 below, this may cause compilation errors later in the libstdc++ header files
126 (that are part of GCC), such as:
127 error: 'rpl_strtol' is not a member of 'std'
128 To avoid this, include the relevant header files here, before these symbols
129 get defined as macros. But do so only on Solaris 11 and AIX (where it is
130 needed), not on mingw (where it would cause other compilation errors). */
131# include <string>
132#endif
133
134_GL_INLINE_HEADER_BEGIN
135#ifndef _GL_STDLIB_INLINE
136# define _GL_STDLIB_INLINE _GL_INLINE
137#endif
138#ifndef _GL_REALLOC_INLINE
139# define _GL_REALLOC_INLINE _GL_INLINE
140#endif
141
107/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 142/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
108 that can be freed by passing them as the Ith argument to the 143 that can be freed by passing them as the Ith argument to the
109 function F. */ 144 function F. */
110#ifndef _GL_ATTRIBUTE_DEALLOC 145#ifndef _GL_ATTRIBUTE_DEALLOC
111# if __GNUC__ >= 11 146# if __GNUC__ >= 11 && !defined __clang__
112# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 147# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
113# else 148# else
114# define _GL_ATTRIBUTE_DEALLOC(f, i) 149# define _GL_ATTRIBUTE_DEALLOC(f, i)
@@ -133,11 +168,23 @@ struct random_data
133# endif 168# endif
134#endif 169#endif
135 170
171/* _GL_ATTRIBUTE_NONNULL_IF_NONZERO (NP, NI) declares that the argument NP
172 (a pointer) must not be NULL if the argument NI (an integer) is != 0. */
173/* Applies to: functions. */
174#ifndef _GL_ATTRIBUTE_NONNULL_IF_NONZERO
175# if __GNUC__ >= 15 && !defined __clang__
176# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni) \
177 __attribute__ ((__nonnull_if_nonzero__ (np, ni)))
178# else
179# define _GL_ATTRIBUTE_NONNULL_IF_NONZERO(np, ni)
180# endif
181#endif
182
136/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. 183/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
137 */ 184 */
138#ifndef _GL_ATTRIBUTE_NOTHROW 185#ifndef _GL_ATTRIBUTE_NOTHROW
139# if defined __cplusplus 186# if defined __cplusplus
140# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4 187# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
141# if __cplusplus >= 201103L 188# if __cplusplus >= 201103L
142# define _GL_ATTRIBUTE_NOTHROW noexcept (true) 189# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
143# else 190# else
@@ -188,6 +235,18 @@ struct random_data
188#endif 235#endif
189 236
190 237
238/* Declarations for ISO C N3322. */
239#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
240_GL_EXTERN_C void *bsearch (const void *__key,
241 const void *__base, size_t __nmemb, size_t __size,
242 int (*__compare) (const void *, const void *))
243 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3) _GL_ARG_NONNULL ((5));
244_GL_EXTERN_C void qsort (void *__base, size_t __nmemb, size_t __size,
245 int (*__compare) (const void *, const void *))
246 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2) _GL_ARG_NONNULL ((4));
247#endif
248
249
191#if @GNULIB__EXIT@ 250#if @GNULIB__EXIT@
192/* Terminate the current process with the given return code, without running 251/* Terminate the current process with the given return code, without running
193 the 'atexit' handlers. */ 252 the 'atexit' handlers. */
@@ -196,11 +255,11 @@ struct random_data
196# undef _Exit 255# undef _Exit
197# define _Exit rpl__Exit 256# define _Exit rpl__Exit
198# endif 257# endif
199_GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status)); 258_GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status), );
200_GL_CXXALIAS_RPL (_Exit, void, (int status)); 259_GL_CXXALIAS_RPL (_Exit, void, (int status));
201# else 260# else
202# if !@HAVE__EXIT@ 261# if !@HAVE__EXIT@
203_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); 262_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status), );
204# endif 263# endif
205_GL_CXXALIAS_SYS (_Exit, void, (int status)); 264_GL_CXXALIAS_SYS (_Exit, void, (int status));
206# endif 265# endif
@@ -216,6 +275,26 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
216#endif 275#endif
217 276
218 277
278#if @GNULIB_ABORT_DEBUG@
279/* Terminates the current process with signal SIGABRT.
280 Note: While the original abort() function is safe to call in signal handlers,
281 the overridden abort() function is not. */
282# if @REPLACE_ABORT@
283# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
284# undef abort
285# define abort rpl_abort
286# endif
287_GL_FUNCDECL_RPL (abort, _Noreturn void, (void), );
288_GL_CXXALIAS_RPL (abort, void, (void));
289# else
290_GL_CXXALIAS_SYS (abort, void, (void));
291# endif
292# if __GLIBC__ >= 2
293_GL_CXXALIASWARN (abort);
294# endif
295#endif
296
297
219#if @GNULIB_FREE_POSIX@ 298#if @GNULIB_FREE_POSIX@
220# if @REPLACE_FREE@ 299# if @REPLACE_FREE@
221# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 300# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -223,9 +302,9 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
223# define free rpl_free 302# define free rpl_free
224# endif 303# endif
225# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 304# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
226_GL_FUNCDECL_RPL (free, void, (void *ptr) _GL_ATTRIBUTE_NOTHROW); 305_GL_FUNCDECL_RPL (free, void, (void *ptr), ) _GL_ATTRIBUTE_NOTHROW;
227# else 306# else
228_GL_FUNCDECL_RPL (free, void, (void *ptr)); 307_GL_FUNCDECL_RPL (free, void, (void *ptr), );
229# endif 308# endif
230_GL_CXXALIAS_RPL (free, void, (void *ptr)); 309_GL_CXXALIAS_RPL (free, void, (void *ptr));
231# else 310# else
@@ -237,8 +316,8 @@ _GL_CXXALIASWARN (free);
237#elif defined GNULIB_POSIXCHECK 316#elif defined GNULIB_POSIXCHECK
238# undef free 317# undef free
239/* Assume free is always declared. */ 318/* Assume free is always declared. */
240_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - " 319_GL_WARN_ON_USE (free, "free is not POSIX:2024 compliant everywhere - "
241 "use gnulib module free for portability"); 320 "use gnulib module free-posix for portability");
242#endif 321#endif
243 322
244 323
@@ -250,22 +329,25 @@ _GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - "
250# define aligned_alloc rpl_aligned_alloc 329# define aligned_alloc rpl_aligned_alloc
251# endif 330# endif
252_GL_FUNCDECL_RPL (aligned_alloc, void *, 331_GL_FUNCDECL_RPL (aligned_alloc, void *,
253 (size_t alignment, size_t size) 332 (size_t alignment, size_t size),
254 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 333 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
334 _GL_ATTRIBUTE_NODISCARD);
255_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); 335_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
256# else 336# else
257# if @HAVE_ALIGNED_ALLOC@ 337# if @HAVE_ALIGNED_ALLOC@
258# if __GNUC__ >= 11 338# if __GNUC__ >= 11 && !defined __clang__
259/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ 339/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
260# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 340# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
261_GL_FUNCDECL_SYS (aligned_alloc, void *, 341_GL_FUNCDECL_SYS (aligned_alloc, void *,
262 (size_t alignment, size_t size) 342 (size_t alignment, size_t size),
263 _GL_ATTRIBUTE_NOTHROW 343 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
264 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 344 _GL_ATTRIBUTE_NODISCARD)
345 _GL_ATTRIBUTE_NOTHROW;
265# else 346# else
266_GL_FUNCDECL_SYS (aligned_alloc, void *, 347_GL_FUNCDECL_SYS (aligned_alloc, void *,
267 (size_t alignment, size_t size) 348 (size_t alignment, size_t size),
268 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 349 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
350 _GL_ATTRIBUTE_NODISCARD);
269# endif 351# endif
270# endif 352# endif
271_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); 353_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
@@ -275,16 +357,17 @@ _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
275_GL_CXXALIASWARN (aligned_alloc); 357_GL_CXXALIASWARN (aligned_alloc);
276# endif 358# endif
277#else 359#else
278# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc 360# if @GNULIB_FREE_POSIX@ \
361 && (__GNUC__ >= 11 && !defined __clang__) && !defined aligned_alloc
279/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ 362/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
280# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2 363# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
281_GL_FUNCDECL_SYS (aligned_alloc, void *, 364_GL_FUNCDECL_SYS (aligned_alloc, void *,
282 (size_t alignment, size_t size) 365 (size_t alignment, size_t size),
283 _GL_ATTRIBUTE_NOTHROW 366 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
284 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 367 _GL_ATTRIBUTE_NOTHROW;
285# else 368# else
286_GL_FUNCDECL_SYS (aligned_alloc, void *, 369_GL_FUNCDECL_SYS (aligned_alloc, void *,
287 (size_t alignment, size_t size) 370 (size_t alignment, size_t size),
288 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 371 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
289# endif 372# endif
290# endif 373# endif
@@ -301,9 +384,10 @@ _GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
301/* Parse a signed decimal integer. 384/* Parse a signed decimal integer.
302 Returns the value of the integer. Errors are not detected. */ 385 Returns the value of the integer. Errors are not detected. */
303# if !@HAVE_ATOLL@ 386# if !@HAVE_ATOLL@
304_GL_FUNCDECL_SYS (atoll, long long, (const char *string) 387_GL_FUNCDECL_SYS (atoll, long long,
305 _GL_ATTRIBUTE_PURE 388 (const char *string),
306 _GL_ARG_NONNULL ((1))); 389 _GL_ATTRIBUTE_PURE
390 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
307# endif 391# endif
308_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); 392_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
309_GL_CXXALIASWARN (atoll); 393_GL_CXXALIASWARN (atoll);
@@ -316,28 +400,32 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
316#endif 400#endif
317 401
318#if @GNULIB_CALLOC_POSIX@ 402#if @GNULIB_CALLOC_POSIX@
319# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \ 403# if @REPLACE_CALLOC_FOR_CALLOC_POSIX@ \
320 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@) 404 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
321# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 405# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
406 || _GL_USE_STDLIB_ALLOC)
322# undef calloc 407# undef calloc
323# define calloc rpl_calloc 408# define calloc rpl_calloc
324# endif 409# endif
325_GL_FUNCDECL_RPL (calloc, void *, 410_GL_FUNCDECL_RPL (calloc, void *,
326 (size_t nmemb, size_t size) 411 (size_t nmemb, size_t size),
327 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 412 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
413 _GL_ATTRIBUTE_NODISCARD);
328_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); 414_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
329# else 415# else
330# if __GNUC__ >= 11 416# if __GNUC__ >= 11 && !defined __clang__
331/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ 417/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
332# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 418# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
333_GL_FUNCDECL_SYS (calloc, void *, 419_GL_FUNCDECL_SYS (calloc, void *,
334 (size_t nmemb, size_t size) 420 (size_t nmemb, size_t size),
335 _GL_ATTRIBUTE_NOTHROW 421 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
336 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 422 _GL_ATTRIBUTE_NODISCARD)
423 _GL_ATTRIBUTE_NOTHROW;
337# else 424# else
338_GL_FUNCDECL_SYS (calloc, void *, 425_GL_FUNCDECL_SYS (calloc, void *,
339 (size_t nmemb, size_t size) 426 (size_t nmemb, size_t size),
340 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 427 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
428 _GL_ATTRIBUTE_NODISCARD);
341# endif 429# endif
342# endif 430# endif
343_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); 431_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
@@ -346,16 +434,17 @@ _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
346_GL_CXXALIASWARN (calloc); 434_GL_CXXALIASWARN (calloc);
347# endif 435# endif
348#else 436#else
349# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc 437# if @GNULIB_FREE_POSIX@ \
438 && (__GNUC__ >= 11 && !defined __clang__) && !defined calloc
350/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ 439/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
351# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 440# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
352_GL_FUNCDECL_SYS (calloc, void *, 441_GL_FUNCDECL_SYS (calloc, void *,
353 (size_t nmemb, size_t size) 442 (size_t nmemb, size_t size),
354 _GL_ATTRIBUTE_NOTHROW 443 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
355 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 444 _GL_ATTRIBUTE_NOTHROW;
356# else 445# else
357_GL_FUNCDECL_SYS (calloc, void *, 446_GL_FUNCDECL_SYS (calloc, void *,
358 (size_t nmemb, size_t size) 447 (size_t nmemb, size_t size),
359 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 448 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
360# endif 449# endif
361# endif 450# endif
@@ -373,23 +462,26 @@ _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
373# define canonicalize_file_name rpl_canonicalize_file_name 462# define canonicalize_file_name rpl_canonicalize_file_name
374# endif 463# endif
375_GL_FUNCDECL_RPL (canonicalize_file_name, char *, 464_GL_FUNCDECL_RPL (canonicalize_file_name, char *,
376 (const char *name) 465 (const char *name),
377 _GL_ARG_NONNULL ((1)) 466 _GL_ARG_NONNULL ((1))
378 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 467 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
468 _GL_ATTRIBUTE_NODISCARD);
379_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); 469_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
380# else 470# else
381# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11 471# if !@HAVE_CANONICALIZE_FILE_NAME@ || (__GNUC__ >= 11 && !defined __clang__)
382# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 472# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
383_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 473_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
384 (const char *name) 474 (const char *name),
385 _GL_ATTRIBUTE_NOTHROW
386 _GL_ARG_NONNULL ((1)) 475 _GL_ARG_NONNULL ((1))
387 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 476 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
477 _GL_ATTRIBUTE_NODISCARD)
478 _GL_ATTRIBUTE_NOTHROW;
388# else 479# else
389_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 480_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
390 (const char *name) 481 (const char *name),
391 _GL_ARG_NONNULL ((1)) 482 _GL_ARG_NONNULL ((1))
392 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 483 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
484 _GL_ATTRIBUTE_NODISCARD);
393# endif 485# endif
394# endif 486# endif
395_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); 487_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
@@ -400,18 +492,19 @@ _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
400# endif 492# endif
401_GL_CXXALIASWARN (canonicalize_file_name); 493_GL_CXXALIASWARN (canonicalize_file_name);
402#else 494#else
403# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name 495# if @GNULIB_FREE_POSIX@ \
496 && (__GNUC__ >= 11 && !defined __clang__) && !defined canonicalize_file_name
404/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or 497/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
405 rpl_free. */ 498 rpl_free. */
406# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 499# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
407_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 500_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
408 (const char *name) 501 (const char *name),
409 _GL_ATTRIBUTE_NOTHROW
410 _GL_ARG_NONNULL ((1)) 502 _GL_ARG_NONNULL ((1))
411 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 503 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
504 _GL_ATTRIBUTE_NOTHROW;
412# else 505# else
413_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 506_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
414 (const char *name) 507 (const char *name),
415 _GL_ARG_NONNULL ((1)) 508 _GL_ARG_NONNULL ((1))
416 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 509 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
417# endif 510# endif
@@ -503,12 +596,12 @@ _GL_CXXALIASWARN (gcvt);
503# undef getloadavg 596# undef getloadavg
504# define getloadavg rpl_getloadavg 597# define getloadavg rpl_getloadavg
505# endif 598# endif
506_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem) 599_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem),
507 _GL_ARG_NONNULL ((1))); 600 _GL_ARG_NONNULL ((1)));
508_GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem)); 601_GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem));
509# else 602# else
510# if !@HAVE_DECL_GETLOADAVG@ 603# if !@HAVE_DECL_GETLOADAVG@
511_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) 604_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem),
512 _GL_ARG_NONNULL ((1))); 605 _GL_ARG_NONNULL ((1)));
513# endif 606# endif
514_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); 607_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
@@ -533,17 +626,17 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
533# define getprogname rpl_getprogname 626# define getprogname rpl_getprogname
534# endif 627# endif
535# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ 628# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
536_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); 629_GL_FUNCDECL_RPL (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE);
537# else 630# else
538_GL_FUNCDECL_RPL (getprogname, const char *, (void)); 631_GL_FUNCDECL_RPL (getprogname, const char *, (void), );
539# endif 632# endif
540_GL_CXXALIAS_RPL (getprogname, const char *, (void)); 633_GL_CXXALIAS_RPL (getprogname, const char *, (void));
541# else 634# else
542# if !@HAVE_GETPROGNAME@ 635# if !@HAVE_GETPROGNAME@
543# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@ 636# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
544_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE); 637_GL_FUNCDECL_SYS (getprogname, const char *, (void), _GL_ATTRIBUTE_PURE);
545# else 638# else
546_GL_FUNCDECL_SYS (getprogname, const char *, (void)); 639_GL_FUNCDECL_SYS (getprogname, const char *, (void), );
547# endif 640# endif
548# endif 641# endif
549_GL_CXXALIAS_SYS (getprogname, const char *, (void)); 642_GL_CXXALIAS_SYS (getprogname, const char *, (void));
@@ -577,15 +670,15 @@ _GL_WARN_ON_USE (getprogname, "getprogname is unportable - "
577# define getsubopt rpl_getsubopt 670# define getsubopt rpl_getsubopt
578# endif 671# endif
579_GL_FUNCDECL_RPL (getsubopt, int, 672_GL_FUNCDECL_RPL (getsubopt, int,
580 (char **optionp, char *const *tokens, char **valuep) 673 (char **optionp, char *const *tokens, char **valuep),
581 _GL_ARG_NONNULL ((1, 2, 3))); 674 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
582_GL_CXXALIAS_RPL (getsubopt, int, 675_GL_CXXALIAS_RPL (getsubopt, int,
583 (char **optionp, char *const *tokens, char **valuep)); 676 (char **optionp, char *const *tokens, char **valuep));
584# else 677# else
585# if !@HAVE_GETSUBOPT@ 678# if !@HAVE_GETSUBOPT@
586_GL_FUNCDECL_SYS (getsubopt, int, 679_GL_FUNCDECL_SYS (getsubopt, int,
587 (char **optionp, char *const *tokens, char **valuep) 680 (char **optionp, char *const *tokens, char **valuep),
588 _GL_ARG_NONNULL ((1, 2, 3))); 681 _GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
589# endif 682# endif
590_GL_CXXALIAS_SYS (getsubopt, int, 683_GL_CXXALIAS_SYS (getsubopt, int,
591 (char **optionp, char *const *tokens, char **valuep)); 684 (char **optionp, char *const *tokens, char **valuep));
@@ -605,7 +698,7 @@ _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
605/* Change the ownership and access permission of the slave side of the 698/* Change the ownership and access permission of the slave side of the
606 pseudo-terminal whose master side is specified by FD. */ 699 pseudo-terminal whose master side is specified by FD. */
607# if !@HAVE_GRANTPT@ 700# if !@HAVE_GRANTPT@
608_GL_FUNCDECL_SYS (grantpt, int, (int fd)); 701_GL_FUNCDECL_SYS (grantpt, int, (int fd), );
609# endif 702# endif
610_GL_CXXALIAS_SYS (grantpt, int, (int fd)); 703_GL_CXXALIAS_SYS (grantpt, int, (int fd));
611_GL_CXXALIASWARN (grantpt); 704_GL_CXXALIASWARN (grantpt);
@@ -622,7 +715,7 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
622 by never specifying a zero size), so it does not need malloc or 715 by never specifying a zero size), so it does not need malloc or
623 realloc to be redefined. */ 716 realloc to be redefined. */
624#if @GNULIB_MALLOC_POSIX@ 717#if @GNULIB_MALLOC_POSIX@
625# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \ 718# if @REPLACE_MALLOC_FOR_MALLOC_POSIX@ \
626 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@) 719 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
627# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 720# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
628 || _GL_USE_STDLIB_ALLOC) 721 || _GL_USE_STDLIB_ALLOC)
@@ -630,21 +723,24 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
630# define malloc rpl_malloc 723# define malloc rpl_malloc
631# endif 724# endif
632_GL_FUNCDECL_RPL (malloc, void *, 725_GL_FUNCDECL_RPL (malloc, void *,
633 (size_t size) 726 (size_t size),
634 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 727 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
728 _GL_ATTRIBUTE_NODISCARD);
635_GL_CXXALIAS_RPL (malloc, void *, (size_t size)); 729_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
636# else 730# else
637# if __GNUC__ >= 11 731# if __GNUC__ >= 11 && !defined __clang__
638/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ 732/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
639# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 733# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
640_GL_FUNCDECL_SYS (malloc, void *, 734_GL_FUNCDECL_SYS (malloc, void *,
641 (size_t size) 735 (size_t size),
642 _GL_ATTRIBUTE_NOTHROW 736 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
643 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 737 _GL_ATTRIBUTE_NODISCARD)
738 _GL_ATTRIBUTE_NOTHROW;
644# else 739# else
645_GL_FUNCDECL_SYS (malloc, void *, 740_GL_FUNCDECL_SYS (malloc, void *,
646 (size_t size) 741 (size_t size),
647 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 742 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
743 _GL_ATTRIBUTE_NODISCARD);
648# endif 744# endif
649# endif 745# endif
650_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); 746_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
@@ -653,16 +749,17 @@ _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
653_GL_CXXALIASWARN (malloc); 749_GL_CXXALIASWARN (malloc);
654# endif 750# endif
655#else 751#else
656# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc 752# if @GNULIB_FREE_POSIX@ \
753 && (__GNUC__ >= 11 && !defined __clang__) && !defined malloc
657/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ 754/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
658# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 755# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
659_GL_FUNCDECL_SYS (malloc, void *, 756_GL_FUNCDECL_SYS (malloc, void *,
660 (size_t size) 757 (size_t size),
661 _GL_ATTRIBUTE_NOTHROW 758 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE)
662 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 759 _GL_ATTRIBUTE_NOTHROW;
663# else 760# else
664_GL_FUNCDECL_SYS (malloc, void *, 761_GL_FUNCDECL_SYS (malloc, void *,
665 (size_t size) 762 (size_t size),
666 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 763 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
667# endif 764# endif
668# endif 765# endif
@@ -674,14 +771,20 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
674# endif 771# endif
675#endif 772#endif
676 773
677/* Return maximum number of bytes of a multibyte character. */ 774/* Return maximum number of bytes in a multibyte character in the
775 current locale. */
678#if @REPLACE_MB_CUR_MAX@ 776#if @REPLACE_MB_CUR_MAX@
679# if !GNULIB_defined_MB_CUR_MAX 777# if !GNULIB_defined_MB_CUR_MAX
680static inline 778_GL_STDLIB_INLINE size_t
681int gl_MB_CUR_MAX (void) 779gl_MB_CUR_MAX (void)
682{ 780{
781# if 0 < @REPLACE_MB_CUR_MAX@
782 return @REPLACE_MB_CUR_MAX@;
783# else
683 /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */ 784 /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */
684 return MB_CUR_MAX + (MB_CUR_MAX == 3); 785 int gl_mb_cur_max = MB_CUR_MAX;
786 return gl_mb_cur_max == 3 ? 4 : gl_mb_cur_max;
787# endif
685} 788}
686# undef MB_CUR_MAX 789# undef MB_CUR_MAX
687# define MB_CUR_MAX gl_MB_CUR_MAX () 790# define MB_CUR_MAX gl_MB_CUR_MAX ()
@@ -698,7 +801,7 @@ int gl_MB_CUR_MAX (void)
698# endif 801# endif
699_GL_FUNCDECL_RPL (mbstowcs, size_t, 802_GL_FUNCDECL_RPL (mbstowcs, size_t,
700 (wchar_t *restrict dest, const char *restrict src, 803 (wchar_t *restrict dest, const char *restrict src,
701 size_t len) 804 size_t len),
702 _GL_ARG_NONNULL ((2))); 805 _GL_ARG_NONNULL ((2)));
703_GL_CXXALIAS_RPL (mbstowcs, size_t, 806_GL_CXXALIAS_RPL (mbstowcs, size_t,
704 (wchar_t *restrict dest, const char *restrict src, 807 (wchar_t *restrict dest, const char *restrict src,
@@ -727,13 +830,13 @@ _GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - "
727# define mbtowc rpl_mbtowc 830# define mbtowc rpl_mbtowc
728# endif 831# endif
729_GL_FUNCDECL_RPL (mbtowc, int, 832_GL_FUNCDECL_RPL (mbtowc, int,
730 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 833 (wchar_t *restrict pwc, const char *restrict s, size_t n), );
731_GL_CXXALIAS_RPL (mbtowc, int, 834_GL_CXXALIAS_RPL (mbtowc, int,
732 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 835 (wchar_t *restrict pwc, const char *restrict s, size_t n));
733# else 836# else
734# if !@HAVE_MBTOWC@ 837# if !@HAVE_MBTOWC@
735_GL_FUNCDECL_SYS (mbtowc, int, 838_GL_FUNCDECL_SYS (mbtowc, int,
736 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 839 (wchar_t *restrict pwc, const char *restrict s, size_t n), );
737# endif 840# endif
738_GL_CXXALIAS_SYS (mbtowc, int, 841_GL_CXXALIAS_SYS (mbtowc, int,
739 (wchar_t *restrict pwc, const char *restrict s, size_t n)); 842 (wchar_t *restrict pwc, const char *restrict s, size_t n));
@@ -756,7 +859,9 @@ _GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
756 Returns TEMPLATE, or a null pointer if it cannot get a unique name. 859 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
757 The directory is created mode 700. */ 860 The directory is created mode 700. */
758# if !@HAVE_MKDTEMP@ 861# if !@HAVE_MKDTEMP@
759_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); 862_GL_FUNCDECL_SYS (mkdtemp, char *,
863 (char * /*template*/),
864 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
760# endif 865# endif
761_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); 866_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
762_GL_CXXALIASWARN (mkdtemp); 867_GL_CXXALIASWARN (mkdtemp);
@@ -786,13 +891,13 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
786# undef mkostemp 891# undef mkostemp
787# define mkostemp rpl_mkostemp 892# define mkostemp rpl_mkostemp
788# endif 893# endif
789_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/) 894_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/),
790 _GL_ARG_NONNULL ((1))); 895 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
791_GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/)); 896_GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/));
792# else 897# else
793# if !@HAVE_MKOSTEMP@ 898# if !@HAVE_MKOSTEMP@
794_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) 899_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/),
795 _GL_ARG_NONNULL ((1))); 900 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
796# endif 901# endif
797_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); 902_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
798# endif 903# endif
@@ -827,15 +932,15 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
827# define mkostemps rpl_mkostemps 932# define mkostemps rpl_mkostemps
828# endif 933# endif
829_GL_FUNCDECL_RPL (mkostemps, int, 934_GL_FUNCDECL_RPL (mkostemps, int,
830 (char * /*template*/, int /*suffixlen*/, int /*flags*/) 935 (char * /*template*/, int /*suffixlen*/, int /*flags*/),
831 _GL_ARG_NONNULL ((1))); 936 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
832_GL_CXXALIAS_RPL (mkostemps, int, 937_GL_CXXALIAS_RPL (mkostemps, int,
833 (char * /*template*/, int /*suffixlen*/, int /*flags*/)); 938 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
834# else 939# else
835# if !@HAVE_MKOSTEMPS@ 940# if !@HAVE_MKOSTEMPS@
836_GL_FUNCDECL_SYS (mkostemps, int, 941_GL_FUNCDECL_SYS (mkostemps, int,
837 (char * /*template*/, int /*suffixlen*/, int /*flags*/) 942 (char * /*template*/, int /*suffixlen*/, int /*flags*/),
838 _GL_ARG_NONNULL ((1))); 943 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
839# endif 944# endif
840_GL_CXXALIAS_SYS (mkostemps, int, 945_GL_CXXALIAS_SYS (mkostemps, int,
841 (char * /*template*/, int /*suffixlen*/, int /*flags*/)); 946 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
@@ -865,11 +970,13 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
865# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 970# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
866# define mkstemp rpl_mkstemp 971# define mkstemp rpl_mkstemp
867# endif 972# endif
868_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); 973_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/),
974 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
869_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); 975_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
870# else 976# else
871# if ! @HAVE_MKSTEMP@ 977# if ! @HAVE_MKSTEMP@
872_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); 978_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/),
979 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
873# endif 980# endif
874_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); 981_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
875# endif 982# endif
@@ -894,8 +1001,8 @@ _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
894 Returns the open file descriptor if successful, otherwise -1 and errno 1001 Returns the open file descriptor if successful, otherwise -1 and errno
895 set. */ 1002 set. */
896# if !@HAVE_MKSTEMPS@ 1003# if !@HAVE_MKSTEMPS@
897_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) 1004_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/),
898 _GL_ARG_NONNULL ((1))); 1005 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
899# endif 1006# endif
900_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); 1007_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
901_GL_CXXALIASWARN (mkstemps); 1008_GL_CXXALIASWARN (mkstemps);
@@ -931,8 +1038,8 @@ _GL_CXXALIASWARN (mktemp);
931# define posix_memalign rpl_posix_memalign 1038# define posix_memalign rpl_posix_memalign
932# endif 1039# endif
933_GL_FUNCDECL_RPL (posix_memalign, int, 1040_GL_FUNCDECL_RPL (posix_memalign, int,
934 (void **memptr, size_t alignment, size_t size) 1041 (void **memptr, size_t alignment, size_t size),
935 _GL_ARG_NONNULL ((1))); 1042 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
936_GL_CXXALIAS_RPL (posix_memalign, int, 1043_GL_CXXALIAS_RPL (posix_memalign, int,
937 (void **memptr, size_t alignment, size_t size)); 1044 (void **memptr, size_t alignment, size_t size));
938# else 1045# else
@@ -960,11 +1067,11 @@ _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
960# undef posix_openpt 1067# undef posix_openpt
961# define posix_openpt rpl_posix_openpt 1068# define posix_openpt rpl_posix_openpt
962# endif 1069# endif
963_GL_FUNCDECL_RPL (posix_openpt, int, (int flags)); 1070_GL_FUNCDECL_RPL (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
964_GL_CXXALIAS_RPL (posix_openpt, int, (int flags)); 1071_GL_CXXALIAS_RPL (posix_openpt, int, (int flags));
965# else 1072# else
966# if !@HAVE_POSIX_OPENPT@ 1073# if !@HAVE_POSIX_OPENPT@
967_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); 1074_GL_FUNCDECL_SYS (posix_openpt, int, (int flags), _GL_ATTRIBUTE_NODISCARD);
968# endif 1075# endif
969_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); 1076_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
970# endif 1077# endif
@@ -987,11 +1094,11 @@ _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
987# undef ptsname 1094# undef ptsname
988# define ptsname rpl_ptsname 1095# define ptsname rpl_ptsname
989# endif 1096# endif
990_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); 1097_GL_FUNCDECL_RPL (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD);
991_GL_CXXALIAS_RPL (ptsname, char *, (int fd)); 1098_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
992# else 1099# else
993# if !@HAVE_PTSNAME@ 1100# if !@HAVE_PTSNAME@
994_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); 1101_GL_FUNCDECL_SYS (ptsname, char *, (int fd), _GL_ATTRIBUTE_NODISCARD);
995# endif 1102# endif
996_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); 1103_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
997# endif 1104# endif
@@ -1013,11 +1120,11 @@ _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
1013# undef ptsname_r 1120# undef ptsname_r
1014# define ptsname_r rpl_ptsname_r 1121# define ptsname_r rpl_ptsname_r
1015# endif 1122# endif
1016_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); 1123_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len), );
1017_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); 1124_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
1018# else 1125# else
1019# if !@HAVE_PTSNAME_R@ 1126# if !@HAVE_PTSNAME_R@
1020_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); 1127_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len), );
1021# endif 1128# endif
1022_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); 1129_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
1023# endif 1130# endif
@@ -1039,7 +1146,7 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
1039# undef putenv 1146# undef putenv
1040# define putenv rpl_putenv 1147# define putenv rpl_putenv
1041# endif 1148# endif
1042_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); 1149_GL_FUNCDECL_RPL (putenv, int, (char *string), _GL_ARG_NONNULL ((1)));
1043_GL_CXXALIAS_RPL (putenv, int, (char *string)); 1150_GL_CXXALIAS_RPL (putenv, int, (char *string));
1044# elif defined _WIN32 && !defined __CYGWIN__ 1151# elif defined _WIN32 && !defined __CYGWIN__
1045# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1152# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1098,7 +1205,9 @@ typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *);
1098# endif 1205# endif
1099_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, 1206_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
1100 _gl_qsort_r_compar_fn compare, 1207 _gl_qsort_r_compar_fn compare,
1101 void *arg) _GL_ARG_NONNULL ((1, 4))); 1208 void *arg),
1209 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
1210 _GL_ARG_NONNULL ((4)));
1102_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, 1211_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
1103 _gl_qsort_r_compar_fn compare, 1212 _gl_qsort_r_compar_fn compare,
1104 void *arg)); 1213 void *arg));
@@ -1106,7 +1215,9 @@ _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
1106# if !@HAVE_QSORT_R@ 1215# if !@HAVE_QSORT_R@
1107_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, 1216_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
1108 _gl_qsort_r_compar_fn compare, 1217 _gl_qsort_r_compar_fn compare,
1109 void *arg) _GL_ARG_NONNULL ((1, 4))); 1218 void *arg),
1219 _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)
1220 _GL_ARG_NONNULL ((4)));
1110# endif 1221# endif
1111_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, 1222_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
1112 _gl_qsort_r_compar_fn compare, 1223 _gl_qsort_r_compar_fn compare,
@@ -1137,7 +1248,7 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
1137# undef rand 1248# undef rand
1138# define rand rpl_rand 1249# define rand rpl_rand
1139# endif 1250# endif
1140_GL_FUNCDECL_RPL (rand, int, (void)); 1251_GL_FUNCDECL_RPL (rand, int, (void), );
1141_GL_CXXALIAS_RPL (rand, int, (void)); 1252_GL_CXXALIAS_RPL (rand, int, (void));
1142# else 1253# else
1143_GL_CXXALIAS_SYS (rand, int, (void)); 1254_GL_CXXALIAS_SYS (rand, int, (void));
@@ -1154,11 +1265,11 @@ _GL_CXXALIASWARN (rand);
1154# undef random 1265# undef random
1155# define random rpl_random 1266# define random rpl_random
1156# endif 1267# endif
1157_GL_FUNCDECL_RPL (random, long, (void)); 1268_GL_FUNCDECL_RPL (random, long, (void), );
1158_GL_CXXALIAS_RPL (random, long, (void)); 1269_GL_CXXALIAS_RPL (random, long, (void));
1159# else 1270# else
1160# if !@HAVE_RANDOM@ 1271# if !@HAVE_RANDOM@
1161_GL_FUNCDECL_SYS (random, long, (void)); 1272_GL_FUNCDECL_SYS (random, long, (void), );
1162# endif 1273# endif
1163/* Need to cast, because on Haiku, the return type is 1274/* Need to cast, because on Haiku, the return type is
1164 int. */ 1275 int. */
@@ -1181,11 +1292,11 @@ _GL_WARN_ON_USE (random, "random is unportable - "
1181# undef srandom 1292# undef srandom
1182# define srandom rpl_srandom 1293# define srandom rpl_srandom
1183# endif 1294# endif
1184_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed)); 1295_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed), );
1185_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed)); 1296_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
1186# else 1297# else
1187# if !@HAVE_RANDOM@ 1298# if !@HAVE_RANDOM@
1188_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); 1299_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed), );
1189# endif 1300# endif
1190/* Need to cast, because on FreeBSD, the first parameter is 1301/* Need to cast, because on FreeBSD, the first parameter is
1191 unsigned long seed. */ 1302 unsigned long seed. */
@@ -1209,14 +1320,14 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - "
1209# define initstate rpl_initstate 1320# define initstate rpl_initstate
1210# endif 1321# endif
1211_GL_FUNCDECL_RPL (initstate, char *, 1322_GL_FUNCDECL_RPL (initstate, char *,
1212 (unsigned int seed, char *buf, size_t buf_size) 1323 (unsigned int seed, char *buf, size_t buf_size),
1213 _GL_ARG_NONNULL ((2))); 1324 _GL_ARG_NONNULL ((2)));
1214_GL_CXXALIAS_RPL (initstate, char *, 1325_GL_CXXALIAS_RPL (initstate, char *,
1215 (unsigned int seed, char *buf, size_t buf_size)); 1326 (unsigned int seed, char *buf, size_t buf_size));
1216# else 1327# else
1217# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@ 1328# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
1218_GL_FUNCDECL_SYS (initstate, char *, 1329_GL_FUNCDECL_SYS (initstate, char *,
1219 (unsigned int seed, char *buf, size_t buf_size) 1330 (unsigned int seed, char *buf, size_t buf_size),
1220 _GL_ARG_NONNULL ((2))); 1331 _GL_ARG_NONNULL ((2)));
1221# endif 1332# endif
1222/* Need to cast, because on FreeBSD, the first parameter is 1333/* Need to cast, because on FreeBSD, the first parameter is
@@ -1241,11 +1352,11 @@ _GL_WARN_ON_USE (initstate, "initstate is unportable - "
1241# undef setstate 1352# undef setstate
1242# define setstate rpl_setstate 1353# define setstate rpl_setstate
1243# endif 1354# endif
1244_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); 1355_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1)));
1245_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state)); 1356_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
1246# else 1357# else
1247# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@ 1358# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
1248_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); 1359_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state), _GL_ARG_NONNULL ((1)));
1249# endif 1360# endif
1250/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter 1361/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
1251 is const char *arg_state. */ 1362 is const char *arg_state. */
@@ -1269,12 +1380,12 @@ _GL_WARN_ON_USE (setstate, "setstate is unportable - "
1269# undef random_r 1380# undef random_r
1270# define random_r rpl_random_r 1381# define random_r rpl_random_r
1271# endif 1382# endif
1272_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result) 1383_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result),
1273 _GL_ARG_NONNULL ((1, 2))); 1384 _GL_ARG_NONNULL ((1, 2)));
1274_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result)); 1385_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
1275# else 1386# else
1276# if !@HAVE_RANDOM_R@ 1387# if !@HAVE_RANDOM_R@
1277_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) 1388_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result),
1278 _GL_ARG_NONNULL ((1, 2))); 1389 _GL_ARG_NONNULL ((1, 2)));
1279# endif 1390# endif
1280_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); 1391_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
@@ -1295,14 +1406,14 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - "
1295# define srandom_r rpl_srandom_r 1406# define srandom_r rpl_srandom_r
1296# endif 1407# endif
1297_GL_FUNCDECL_RPL (srandom_r, int, 1408_GL_FUNCDECL_RPL (srandom_r, int,
1298 (unsigned int seed, struct random_data *rand_state) 1409 (unsigned int seed, struct random_data *rand_state),
1299 _GL_ARG_NONNULL ((2))); 1410 _GL_ARG_NONNULL ((2)));
1300_GL_CXXALIAS_RPL (srandom_r, int, 1411_GL_CXXALIAS_RPL (srandom_r, int,
1301 (unsigned int seed, struct random_data *rand_state)); 1412 (unsigned int seed, struct random_data *rand_state));
1302# else 1413# else
1303# if !@HAVE_RANDOM_R@ 1414# if !@HAVE_RANDOM_R@
1304_GL_FUNCDECL_SYS (srandom_r, int, 1415_GL_FUNCDECL_SYS (srandom_r, int,
1305 (unsigned int seed, struct random_data *rand_state) 1416 (unsigned int seed, struct random_data *rand_state),
1306 _GL_ARG_NONNULL ((2))); 1417 _GL_ARG_NONNULL ((2)));
1307# endif 1418# endif
1308_GL_CXXALIAS_SYS (srandom_r, int, 1419_GL_CXXALIAS_SYS (srandom_r, int,
@@ -1325,7 +1436,7 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
1325# endif 1436# endif
1326_GL_FUNCDECL_RPL (initstate_r, int, 1437_GL_FUNCDECL_RPL (initstate_r, int,
1327 (unsigned int seed, char *buf, size_t buf_size, 1438 (unsigned int seed, char *buf, size_t buf_size,
1328 struct random_data *rand_state) 1439 struct random_data *rand_state),
1329 _GL_ARG_NONNULL ((2, 4))); 1440 _GL_ARG_NONNULL ((2, 4)));
1330_GL_CXXALIAS_RPL (initstate_r, int, 1441_GL_CXXALIAS_RPL (initstate_r, int,
1331 (unsigned int seed, char *buf, size_t buf_size, 1442 (unsigned int seed, char *buf, size_t buf_size,
@@ -1334,7 +1445,7 @@ _GL_CXXALIAS_RPL (initstate_r, int,
1334# if !@HAVE_RANDOM_R@ 1445# if !@HAVE_RANDOM_R@
1335_GL_FUNCDECL_SYS (initstate_r, int, 1446_GL_FUNCDECL_SYS (initstate_r, int,
1336 (unsigned int seed, char *buf, size_t buf_size, 1447 (unsigned int seed, char *buf, size_t buf_size,
1337 struct random_data *rand_state) 1448 struct random_data *rand_state),
1338 _GL_ARG_NONNULL ((2, 4))); 1449 _GL_ARG_NONNULL ((2, 4)));
1339# endif 1450# endif
1340/* Need to cast, because on Haiku, the third parameter is 1451/* Need to cast, because on Haiku, the third parameter is
@@ -1359,14 +1470,14 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
1359# define setstate_r rpl_setstate_r 1470# define setstate_r rpl_setstate_r
1360# endif 1471# endif
1361_GL_FUNCDECL_RPL (setstate_r, int, 1472_GL_FUNCDECL_RPL (setstate_r, int,
1362 (char *arg_state, struct random_data *rand_state) 1473 (char *arg_state, struct random_data *rand_state),
1363 _GL_ARG_NONNULL ((1, 2))); 1474 _GL_ARG_NONNULL ((1, 2)));
1364_GL_CXXALIAS_RPL (setstate_r, int, 1475_GL_CXXALIAS_RPL (setstate_r, int,
1365 (char *arg_state, struct random_data *rand_state)); 1476 (char *arg_state, struct random_data *rand_state));
1366# else 1477# else
1367# if !@HAVE_RANDOM_R@ 1478# if !@HAVE_RANDOM_R@
1368_GL_FUNCDECL_SYS (setstate_r, int, 1479_GL_FUNCDECL_SYS (setstate_r, int,
1369 (char *arg_state, struct random_data *rand_state) 1480 (char *arg_state, struct random_data *rand_state),
1370 _GL_ARG_NONNULL ((1, 2))); 1481 _GL_ARG_NONNULL ((1, 2)));
1371# endif 1482# endif
1372/* Need to cast, because on Haiku, the first parameter is 1483/* Need to cast, because on Haiku, the first parameter is
@@ -1385,28 +1496,44 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
1385 1496
1386 1497
1387#if @GNULIB_REALLOC_POSIX@ 1498#if @GNULIB_REALLOC_POSIX@
1388# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \ 1499# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@
1389 || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@) 1500# if @REPLACE_REALLOC_FOR_REALLOC_POSIX@ == 2
1501# define _GL_INLINE_RPL_REALLOC 1
1502# ifdef __cplusplus
1503extern "C" {
1504# endif
1505_GL_REALLOC_INLINE void *
1506rpl_realloc (void *ptr, size_t size)
1507{
1508 return realloc (ptr, size ? size : 1);
1509}
1510# ifdef __cplusplus
1511}
1512# endif
1513# endif
1390# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 1514# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
1391 || _GL_USE_STDLIB_ALLOC) 1515 || _GL_USE_STDLIB_ALLOC)
1392# undef realloc 1516# undef realloc
1393# define realloc rpl_realloc 1517# define realloc rpl_realloc
1394# endif 1518# endif
1395_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size) 1519# if !defined _GL_INLINE_RPL_REALLOC
1396 _GL_ATTRIBUTE_DEALLOC_FREE); 1520_GL_FUNCDECL_RPL (realloc, void *,
1521 (void *ptr, size_t size),
1522 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD);
1523# endif
1397_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); 1524_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
1398# else 1525# else
1399# if __GNUC__ >= 11 1526# if __GNUC__ >= 11 && !defined __clang__
1400/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ 1527/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1401# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 1528# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1402_GL_FUNCDECL_SYS (realloc, void *, 1529_GL_FUNCDECL_SYS (realloc, void *,
1403 (void *ptr, size_t size) 1530 (void *ptr, size_t size),
1404 _GL_ATTRIBUTE_NOTHROW 1531 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD)
1405 _GL_ATTRIBUTE_DEALLOC_FREE); 1532 _GL_ATTRIBUTE_NOTHROW;
1406# else 1533# else
1407_GL_FUNCDECL_SYS (realloc, void *, 1534_GL_FUNCDECL_SYS (realloc, void *,
1408 (void *ptr, size_t size) 1535 (void *ptr, size_t size),
1409 _GL_ATTRIBUTE_DEALLOC_FREE); 1536 _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_NODISCARD);
1410# endif 1537# endif
1411# endif 1538# endif
1412_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); 1539_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
@@ -1415,16 +1542,17 @@ _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
1415_GL_CXXALIASWARN (realloc); 1542_GL_CXXALIASWARN (realloc);
1416# endif 1543# endif
1417#else 1544#else
1418# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc 1545# if @GNULIB_FREE_POSIX@ \
1546 && (__GNUC__ >= 11 && !defined __clang__) && !defined realloc
1419/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ 1547/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1420# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2 1548# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1421_GL_FUNCDECL_SYS (realloc, void *, 1549_GL_FUNCDECL_SYS (realloc, void *,
1422 (void *ptr, size_t size) 1550 (void *ptr, size_t size),
1423 _GL_ATTRIBUTE_NOTHROW 1551 _GL_ATTRIBUTE_DEALLOC_FREE)
1424 _GL_ATTRIBUTE_DEALLOC_FREE); 1552 _GL_ATTRIBUTE_NOTHROW;
1425# else 1553# else
1426_GL_FUNCDECL_SYS (realloc, void *, 1554_GL_FUNCDECL_SYS (realloc, void *,
1427 (void *ptr, size_t size) 1555 (void *ptr, size_t size),
1428 _GL_ATTRIBUTE_DEALLOC_FREE); 1556 _GL_ATTRIBUTE_DEALLOC_FREE);
1429# endif 1557# endif
1430# endif 1558# endif
@@ -1444,13 +1572,15 @@ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
1444# define reallocarray rpl_reallocarray 1572# define reallocarray rpl_reallocarray
1445# endif 1573# endif
1446_GL_FUNCDECL_RPL (reallocarray, void *, 1574_GL_FUNCDECL_RPL (reallocarray, void *,
1447 (void *ptr, size_t nmemb, size_t size)); 1575 (void *ptr, size_t nmemb, size_t size),
1576 _GL_ATTRIBUTE_NODISCARD);
1448_GL_CXXALIAS_RPL (reallocarray, void *, 1577_GL_CXXALIAS_RPL (reallocarray, void *,
1449 (void *ptr, size_t nmemb, size_t size)); 1578 (void *ptr, size_t nmemb, size_t size));
1450# else 1579# else
1451# if ! @HAVE_REALLOCARRAY@ 1580# if ! @HAVE_REALLOCARRAY@
1452_GL_FUNCDECL_SYS (reallocarray, void *, 1581_GL_FUNCDECL_SYS (reallocarray, void *,
1453 (void *ptr, size_t nmemb, size_t size)); 1582 (void *ptr, size_t nmemb, size_t size),
1583 _GL_ATTRIBUTE_NODISCARD);
1454# endif 1584# endif
1455_GL_CXXALIAS_SYS (reallocarray, void *, 1585_GL_CXXALIAS_SYS (reallocarray, void *,
1456 (void *ptr, size_t nmemb, size_t size)); 1586 (void *ptr, size_t nmemb, size_t size));
@@ -1472,15 +1602,15 @@ _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
1472# define realpath rpl_realpath 1602# define realpath rpl_realpath
1473# endif 1603# endif
1474_GL_FUNCDECL_RPL (realpath, char *, 1604_GL_FUNCDECL_RPL (realpath, char *,
1475 (const char *restrict name, char *restrict resolved) 1605 (const char *restrict name, char *restrict resolved),
1476 _GL_ARG_NONNULL ((1))); 1606 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1477_GL_CXXALIAS_RPL (realpath, char *, 1607_GL_CXXALIAS_RPL (realpath, char *,
1478 (const char *restrict name, char *restrict resolved)); 1608 (const char *restrict name, char *restrict resolved));
1479# else 1609# else
1480# if !@HAVE_REALPATH@ 1610# if !@HAVE_REALPATH@
1481_GL_FUNCDECL_SYS (realpath, char *, 1611_GL_FUNCDECL_SYS (realpath, char *,
1482 (const char *restrict name, char *restrict resolved) 1612 (const char *restrict name, char *restrict resolved),
1483 _GL_ARG_NONNULL ((1))); 1613 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1484# endif 1614# endif
1485_GL_CXXALIAS_SYS (realpath, char *, 1615_GL_CXXALIAS_SYS (realpath, char *,
1486 (const char *restrict name, char *restrict resolved)); 1616 (const char *restrict name, char *restrict resolved));
@@ -1498,7 +1628,8 @@ _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
1498/* Test a user response to a question. 1628/* Test a user response to a question.
1499 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ 1629 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
1500# if !@HAVE_RPMATCH@ 1630# if !@HAVE_RPMATCH@
1501_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); 1631_GL_FUNCDECL_SYS (rpmatch, int, (const char *response),
1632 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1502# endif 1633# endif
1503_GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); 1634_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
1504_GL_CXXALIASWARN (rpmatch); 1635_GL_CXXALIASWARN (rpmatch);
@@ -1514,7 +1645,8 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
1514/* Look up NAME in the environment, returning 0 in insecure situations. */ 1645/* Look up NAME in the environment, returning 0 in insecure situations. */
1515# if !@HAVE_SECURE_GETENV@ 1646# if !@HAVE_SECURE_GETENV@
1516_GL_FUNCDECL_SYS (secure_getenv, char *, 1647_GL_FUNCDECL_SYS (secure_getenv, char *,
1517 (char const *name) _GL_ARG_NONNULL ((1))); 1648 (char const *name),
1649 _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NODISCARD);
1518# endif 1650# endif
1519_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name)); 1651_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
1520_GL_CXXALIASWARN (secure_getenv); 1652_GL_CXXALIASWARN (secure_getenv);
@@ -1535,14 +1667,14 @@ _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
1535# define setenv rpl_setenv 1667# define setenv rpl_setenv
1536# endif 1668# endif
1537_GL_FUNCDECL_RPL (setenv, int, 1669_GL_FUNCDECL_RPL (setenv, int,
1538 (const char *name, const char *value, int replace) 1670 (const char *name, const char *value, int replace),
1539 _GL_ARG_NONNULL ((1))); 1671 _GL_ARG_NONNULL ((1)));
1540_GL_CXXALIAS_RPL (setenv, int, 1672_GL_CXXALIAS_RPL (setenv, int,
1541 (const char *name, const char *value, int replace)); 1673 (const char *name, const char *value, int replace));
1542# else 1674# else
1543# if !@HAVE_DECL_SETENV@ 1675# if !@HAVE_DECL_SETENV@
1544_GL_FUNCDECL_SYS (setenv, int, 1676_GL_FUNCDECL_SYS (setenv, int,
1545 (const char *name, const char *value, int replace) 1677 (const char *name, const char *value, int replace),
1546 _GL_ARG_NONNULL ((1))); 1678 _GL_ARG_NONNULL ((1)));
1547# endif 1679# endif
1548_GL_CXXALIAS_SYS (setenv, int, 1680_GL_CXXALIAS_SYS (setenv, int,
@@ -1559,6 +1691,19 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - "
1559# endif 1691# endif
1560#endif 1692#endif
1561 1693
1694#if @GNULIB_STACK_TRACE@
1695/* Prints a stack trace of the current thread to standard error,
1696 if possible. */
1697# if @CAN_PRINT_STACK_TRACE@
1698_GL_EXTERN_C void print_stack_trace (void);
1699# else
1700# if !GNULIB_defined_print_stack_trace
1701# define print_stack_trace() /* nothing */
1702# define GNULIB_defined_print_stack_trace 1
1703# endif
1704# endif
1705#endif
1706
1562#if @GNULIB_STRTOD@ 1707#if @GNULIB_STRTOD@
1563 /* Parse a double from STRING, updating ENDP if appropriate. */ 1708 /* Parse a double from STRING, updating ENDP if appropriate. */
1564# if @REPLACE_STRTOD@ 1709# if @REPLACE_STRTOD@
@@ -1567,14 +1712,14 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - "
1567# endif 1712# endif
1568# define GNULIB_defined_strtod_function 1 1713# define GNULIB_defined_strtod_function 1
1569_GL_FUNCDECL_RPL (strtod, double, 1714_GL_FUNCDECL_RPL (strtod, double,
1570 (const char *restrict str, char **restrict endp) 1715 (const char *restrict str, char **restrict endp),
1571 _GL_ARG_NONNULL ((1))); 1716 _GL_ARG_NONNULL ((1)));
1572_GL_CXXALIAS_RPL (strtod, double, 1717_GL_CXXALIAS_RPL (strtod, double,
1573 (const char *restrict str, char **restrict endp)); 1718 (const char *restrict str, char **restrict endp));
1574# else 1719# else
1575# if !@HAVE_STRTOD@ 1720# if !@HAVE_STRTOD@
1576_GL_FUNCDECL_SYS (strtod, double, 1721_GL_FUNCDECL_SYS (strtod, double,
1577 (const char *restrict str, char **restrict endp) 1722 (const char *restrict str, char **restrict endp),
1578 _GL_ARG_NONNULL ((1))); 1723 _GL_ARG_NONNULL ((1)));
1579# endif 1724# endif
1580_GL_CXXALIAS_SYS (strtod, double, 1725_GL_CXXALIAS_SYS (strtod, double,
@@ -1599,14 +1744,14 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
1599# endif 1744# endif
1600# define GNULIB_defined_strtof_function 1 1745# define GNULIB_defined_strtof_function 1
1601_GL_FUNCDECL_RPL (strtof, float, 1746_GL_FUNCDECL_RPL (strtof, float,
1602 (const char *restrict str, char **restrict endp) 1747 (const char *restrict str, char **restrict endp),
1603 _GL_ARG_NONNULL ((1))); 1748 _GL_ARG_NONNULL ((1)));
1604_GL_CXXALIAS_RPL (strtof, float, 1749_GL_CXXALIAS_RPL (strtof, float,
1605 (const char *restrict str, char **restrict endp)); 1750 (const char *restrict str, char **restrict endp));
1606# else 1751# else
1607# if !@HAVE_STRTOF@ 1752# if !@HAVE_STRTOF@
1608_GL_FUNCDECL_SYS (strtof, float, 1753_GL_FUNCDECL_SYS (strtof, float,
1609 (const char *restrict str, char **restrict endp) 1754 (const char *restrict str, char **restrict endp),
1610 _GL_ARG_NONNULL ((1))); 1755 _GL_ARG_NONNULL ((1)));
1611# endif 1756# endif
1612_GL_CXXALIAS_SYS (strtof, float, 1757_GL_CXXALIAS_SYS (strtof, float,
@@ -1631,14 +1776,14 @@ _GL_WARN_ON_USE (strtof, "strtof is unportable - "
1631# endif 1776# endif
1632# define GNULIB_defined_strtold_function 1 1777# define GNULIB_defined_strtold_function 1
1633_GL_FUNCDECL_RPL (strtold, long double, 1778_GL_FUNCDECL_RPL (strtold, long double,
1634 (const char *restrict str, char **restrict endp) 1779 (const char *restrict str, char **restrict endp),
1635 _GL_ARG_NONNULL ((1))); 1780 _GL_ARG_NONNULL ((1)));
1636_GL_CXXALIAS_RPL (strtold, long double, 1781_GL_CXXALIAS_RPL (strtold, long double,
1637 (const char *restrict str, char **restrict endp)); 1782 (const char *restrict str, char **restrict endp));
1638# else 1783# else
1639# if !@HAVE_STRTOLD@ 1784# if !@HAVE_STRTOLD@
1640_GL_FUNCDECL_SYS (strtold, long double, 1785_GL_FUNCDECL_SYS (strtold, long double,
1641 (const char *restrict str, char **restrict endp) 1786 (const char *restrict str, char **restrict endp),
1642 _GL_ARG_NONNULL ((1))); 1787 _GL_ARG_NONNULL ((1)));
1643# endif 1788# endif
1644_GL_CXXALIAS_SYS (strtold, long double, 1789_GL_CXXALIAS_SYS (strtold, long double,
@@ -1669,7 +1814,7 @@ _GL_WARN_ON_USE (strtold, "strtold is unportable - "
1669# define GNULIB_defined_strtol_function 1 1814# define GNULIB_defined_strtol_function 1
1670_GL_FUNCDECL_RPL (strtol, long, 1815_GL_FUNCDECL_RPL (strtol, long,
1671 (const char *restrict string, char **restrict endptr, 1816 (const char *restrict string, char **restrict endptr,
1672 int base) 1817 int base),
1673 _GL_ARG_NONNULL ((1))); 1818 _GL_ARG_NONNULL ((1)));
1674_GL_CXXALIAS_RPL (strtol, long, 1819_GL_CXXALIAS_RPL (strtol, long,
1675 (const char *restrict string, char **restrict endptr, 1820 (const char *restrict string, char **restrict endptr,
@@ -1678,7 +1823,7 @@ _GL_CXXALIAS_RPL (strtol, long,
1678# if !@HAVE_STRTOL@ 1823# if !@HAVE_STRTOL@
1679_GL_FUNCDECL_SYS (strtol, long, 1824_GL_FUNCDECL_SYS (strtol, long,
1680 (const char *restrict string, char **restrict endptr, 1825 (const char *restrict string, char **restrict endptr,
1681 int base) 1826 int base),
1682 _GL_ARG_NONNULL ((1))); 1827 _GL_ARG_NONNULL ((1)));
1683# endif 1828# endif
1684_GL_CXXALIAS_SYS (strtol, long, 1829_GL_CXXALIAS_SYS (strtol, long,
@@ -1712,7 +1857,7 @@ _GL_WARN_ON_USE (strtol, "strtol is unportable - "
1712# define GNULIB_defined_strtoll_function 1 1857# define GNULIB_defined_strtoll_function 1
1713_GL_FUNCDECL_RPL (strtoll, long long, 1858_GL_FUNCDECL_RPL (strtoll, long long,
1714 (const char *restrict string, char **restrict endptr, 1859 (const char *restrict string, char **restrict endptr,
1715 int base) 1860 int base),
1716 _GL_ARG_NONNULL ((1))); 1861 _GL_ARG_NONNULL ((1)));
1717_GL_CXXALIAS_RPL (strtoll, long long, 1862_GL_CXXALIAS_RPL (strtoll, long long,
1718 (const char *restrict string, char **restrict endptr, 1863 (const char *restrict string, char **restrict endptr,
@@ -1721,7 +1866,7 @@ _GL_CXXALIAS_RPL (strtoll, long long,
1721# if !@HAVE_STRTOLL@ 1866# if !@HAVE_STRTOLL@
1722_GL_FUNCDECL_SYS (strtoll, long long, 1867_GL_FUNCDECL_SYS (strtoll, long long,
1723 (const char *restrict string, char **restrict endptr, 1868 (const char *restrict string, char **restrict endptr,
1724 int base) 1869 int base),
1725 _GL_ARG_NONNULL ((1))); 1870 _GL_ARG_NONNULL ((1)));
1726# endif 1871# endif
1727_GL_CXXALIAS_SYS (strtoll, long long, 1872_GL_CXXALIAS_SYS (strtoll, long long,
@@ -1752,7 +1897,7 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
1752# define GNULIB_defined_strtoul_function 1 1897# define GNULIB_defined_strtoul_function 1
1753_GL_FUNCDECL_RPL (strtoul, unsigned long, 1898_GL_FUNCDECL_RPL (strtoul, unsigned long,
1754 (const char *restrict string, char **restrict endptr, 1899 (const char *restrict string, char **restrict endptr,
1755 int base) 1900 int base),
1756 _GL_ARG_NONNULL ((1))); 1901 _GL_ARG_NONNULL ((1)));
1757_GL_CXXALIAS_RPL (strtoul, unsigned long, 1902_GL_CXXALIAS_RPL (strtoul, unsigned long,
1758 (const char *restrict string, char **restrict endptr, 1903 (const char *restrict string, char **restrict endptr,
@@ -1761,7 +1906,7 @@ _GL_CXXALIAS_RPL (strtoul, unsigned long,
1761# if !@HAVE_STRTOUL@ 1906# if !@HAVE_STRTOUL@
1762_GL_FUNCDECL_SYS (strtoul, unsigned long, 1907_GL_FUNCDECL_SYS (strtoul, unsigned long,
1763 (const char *restrict string, char **restrict endptr, 1908 (const char *restrict string, char **restrict endptr,
1764 int base) 1909 int base),
1765 _GL_ARG_NONNULL ((1))); 1910 _GL_ARG_NONNULL ((1)));
1766# endif 1911# endif
1767_GL_CXXALIAS_SYS (strtoul, unsigned long, 1912_GL_CXXALIAS_SYS (strtoul, unsigned long,
@@ -1795,7 +1940,7 @@ _GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
1795# define GNULIB_defined_strtoull_function 1 1940# define GNULIB_defined_strtoull_function 1
1796_GL_FUNCDECL_RPL (strtoull, unsigned long long, 1941_GL_FUNCDECL_RPL (strtoull, unsigned long long,
1797 (const char *restrict string, char **restrict endptr, 1942 (const char *restrict string, char **restrict endptr,
1798 int base) 1943 int base),
1799 _GL_ARG_NONNULL ((1))); 1944 _GL_ARG_NONNULL ((1)));
1800_GL_CXXALIAS_RPL (strtoull, unsigned long long, 1945_GL_CXXALIAS_RPL (strtoull, unsigned long long,
1801 (const char *restrict string, char **restrict endptr, 1946 (const char *restrict string, char **restrict endptr,
@@ -1804,7 +1949,7 @@ _GL_CXXALIAS_RPL (strtoull, unsigned long long,
1804# if !@HAVE_STRTOULL@ 1949# if !@HAVE_STRTOULL@
1805_GL_FUNCDECL_SYS (strtoull, unsigned long long, 1950_GL_FUNCDECL_SYS (strtoull, unsigned long long,
1806 (const char *restrict string, char **restrict endptr, 1951 (const char *restrict string, char **restrict endptr,
1807 int base) 1952 int base),
1808 _GL_ARG_NONNULL ((1))); 1953 _GL_ARG_NONNULL ((1)));
1809# endif 1954# endif
1810_GL_CXXALIAS_SYS (strtoull, unsigned long long, 1955_GL_CXXALIAS_SYS (strtoull, unsigned long long,
@@ -1824,7 +1969,7 @@ _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
1824/* Unlock the slave side of the pseudo-terminal whose master side is specified 1969/* Unlock the slave side of the pseudo-terminal whose master side is specified
1825 by FD, so that it can be opened. */ 1970 by FD, so that it can be opened. */
1826# if !@HAVE_UNLOCKPT@ 1971# if !@HAVE_UNLOCKPT@
1827_GL_FUNCDECL_SYS (unlockpt, int, (int fd)); 1972_GL_FUNCDECL_SYS (unlockpt, int, (int fd), );
1828# endif 1973# endif
1829_GL_CXXALIAS_SYS (unlockpt, int, (int fd)); 1974_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
1830_GL_CXXALIASWARN (unlockpt); 1975_GL_CXXALIASWARN (unlockpt);
@@ -1843,11 +1988,11 @@ _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
1843# undef unsetenv 1988# undef unsetenv
1844# define unsetenv rpl_unsetenv 1989# define unsetenv rpl_unsetenv
1845# endif 1990# endif
1846_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 1991_GL_FUNCDECL_RPL (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1)));
1847_GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); 1992_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
1848# else 1993# else
1849# if !@HAVE_DECL_UNSETENV@ 1994# if !@HAVE_DECL_UNSETENV@
1850_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 1995_GL_FUNCDECL_SYS (unsetenv, int, (const char *name), _GL_ARG_NONNULL ((1)));
1851# endif 1996# endif
1852_GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); 1997_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
1853# endif 1998# endif
@@ -1869,7 +2014,7 @@ _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
1869# undef wctomb 2014# undef wctomb
1870# define wctomb rpl_wctomb 2015# define wctomb rpl_wctomb
1871# endif 2016# endif
1872_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc)); 2017_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc), );
1873_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); 2018_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
1874# else 2019# else
1875_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); 2020_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
@@ -1880,6 +2025,8 @@ _GL_CXXALIASWARN (wctomb);
1880#endif 2025#endif
1881 2026
1882 2027
2028_GL_INLINE_HEADER_END
2029
1883#endif /* _@GUARD_PREFIX@_STDLIB_H */ 2030#endif /* _@GUARD_PREFIX@_STDLIB_H */
1884#endif /* _@GUARD_PREFIX@_STDLIB_H */ 2031#endif /* _@GUARD_PREFIX@_STDLIB_H */
1885#endif 2032#endif