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.h374
1 files changed, 348 insertions, 26 deletions
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index b79e5f7..e74e7c1 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-2023 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2024 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
@@ -37,6 +37,13 @@
37#ifndef _@GUARD_PREFIX@_STDLIB_H 37#ifndef _@GUARD_PREFIX@_STDLIB_H
38#define _@GUARD_PREFIX@_STDLIB_H 38#define _@GUARD_PREFIX@_STDLIB_H
39 39
40/* This file uses _Noreturn, _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC,
41 _GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PURE, GNULIB_POSIXCHECK,
42 HAVE_RAW_DECL_*. */
43#if !_GL_CONFIG_H_INCLUDED
44 #error "Please include config.h first."
45#endif
46
40/* NetBSD 5.0 mis-defines NULL. */ 47/* NetBSD 5.0 mis-defines NULL. */
41#include <stddef.h> 48#include <stddef.h>
42 49
@@ -67,9 +74,7 @@
67# include <random.h> 74# include <random.h>
68# endif 75# endif
69 76
70# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@ 77# include <stdint.h>
71# include <stdint.h>
72# endif
73 78
74# if !@HAVE_STRUCT_RANDOM_DATA@ 79# if !@HAVE_STRUCT_RANDOM_DATA@
75/* Define 'struct random_data'. 80/* Define 'struct random_data'.
@@ -128,6 +133,28 @@ struct random_data
128# endif 133# endif
129#endif 134#endif
130 135
136/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
137 */
138#ifndef _GL_ATTRIBUTE_NOTHROW
139# if defined __cplusplus
140# if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
141# if __cplusplus >= 201103L
142# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
143# else
144# define _GL_ATTRIBUTE_NOTHROW throw ()
145# endif
146# else
147# define _GL_ATTRIBUTE_NOTHROW
148# endif
149# else
150# if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
151# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
152# else
153# define _GL_ATTRIBUTE_NOTHROW
154# endif
155# endif
156#endif
157
131/* The __attribute__ feature is available in gcc versions 2.5 and later. 158/* The __attribute__ feature is available in gcc versions 2.5 and later.
132 The attribute __pure__ was added in gcc 2.96. */ 159 The attribute __pure__ was added in gcc 2.96. */
133#ifndef _GL_ATTRIBUTE_PURE 160#ifndef _GL_ATTRIBUTE_PURE
@@ -164,11 +191,22 @@ struct random_data
164#if @GNULIB__EXIT@ 191#if @GNULIB__EXIT@
165/* Terminate the current process with the given return code, without running 192/* Terminate the current process with the given return code, without running
166 the 'atexit' handlers. */ 193 the 'atexit' handlers. */
167# if !@HAVE__EXIT@ 194# if @REPLACE__EXIT@
195# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
196# undef _Exit
197# define _Exit rpl__Exit
198# endif
199_GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status));
200_GL_CXXALIAS_RPL (_Exit, void, (int status));
201# else
202# if !@HAVE__EXIT@
168_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); 203_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
169# endif 204# endif
170_GL_CXXALIAS_SYS (_Exit, void, (int status)); 205_GL_CXXALIAS_SYS (_Exit, void, (int status));
206# endif
207# if __GLIBC__ >= 2
171_GL_CXXALIASWARN (_Exit); 208_GL_CXXALIASWARN (_Exit);
209# endif
172#elif defined GNULIB_POSIXCHECK 210#elif defined GNULIB_POSIXCHECK
173# undef _Exit 211# undef _Exit
174# if HAVE_RAW_DECL__EXIT 212# if HAVE_RAW_DECL__EXIT
@@ -185,7 +223,7 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
185# define free rpl_free 223# define free rpl_free
186# endif 224# endif
187# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 225# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
188_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ()); 226_GL_FUNCDECL_RPL (free, void, (void *ptr) _GL_ATTRIBUTE_NOTHROW);
189# else 227# else
190_GL_FUNCDECL_RPL (free, void, (void *ptr)); 228_GL_FUNCDECL_RPL (free, void, (void *ptr));
191# endif 229# endif
@@ -219,9 +257,16 @@ _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
219# if @HAVE_ALIGNED_ALLOC@ 257# if @HAVE_ALIGNED_ALLOC@
220# if __GNUC__ >= 11 258# if __GNUC__ >= 11
221/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ 259/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
260# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
261_GL_FUNCDECL_SYS (aligned_alloc, void *,
262 (size_t alignment, size_t size)
263 _GL_ATTRIBUTE_NOTHROW
264 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
265# else
222_GL_FUNCDECL_SYS (aligned_alloc, void *, 266_GL_FUNCDECL_SYS (aligned_alloc, void *,
223 (size_t alignment, size_t size) 267 (size_t alignment, size_t size)
224 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 268 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
269# endif
225# endif 270# endif
226_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); 271_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
227# endif 272# endif
@@ -232,9 +277,16 @@ _GL_CXXALIASWARN (aligned_alloc);
232#else 277#else
233# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc 278# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc
234/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */ 279/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
280# if __GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2
235_GL_FUNCDECL_SYS (aligned_alloc, void *, 281_GL_FUNCDECL_SYS (aligned_alloc, void *,
236 (size_t alignment, size_t size) 282 (size_t alignment, size_t size)
283 _GL_ATTRIBUTE_NOTHROW
237 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 284 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
285# else
286_GL_FUNCDECL_SYS (aligned_alloc, void *,
287 (size_t alignment, size_t size)
288 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
289# endif
238# endif 290# endif
239# if defined GNULIB_POSIXCHECK 291# if defined GNULIB_POSIXCHECK
240# undef aligned_alloc 292# undef aligned_alloc
@@ -277,9 +329,16 @@ _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
277# else 329# else
278# if __GNUC__ >= 11 330# if __GNUC__ >= 11
279/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ 331/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
332# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
280_GL_FUNCDECL_SYS (calloc, void *, 333_GL_FUNCDECL_SYS (calloc, void *,
281 (size_t nmemb, size_t size) 334 (size_t nmemb, size_t size)
335 _GL_ATTRIBUTE_NOTHROW
282 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 336 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
337# else
338_GL_FUNCDECL_SYS (calloc, void *,
339 (size_t nmemb, size_t size)
340 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
341# endif
283# endif 342# endif
284_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); 343_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
285# endif 344# endif
@@ -289,9 +348,16 @@ _GL_CXXALIASWARN (calloc);
289#else 348#else
290# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc 349# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc
291/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */ 350/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
351# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
352_GL_FUNCDECL_SYS (calloc, void *,
353 (size_t nmemb, size_t size)
354 _GL_ATTRIBUTE_NOTHROW
355 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
356# else
292_GL_FUNCDECL_SYS (calloc, void *, 357_GL_FUNCDECL_SYS (calloc, void *,
293 (size_t nmemb, size_t size) 358 (size_t nmemb, size_t size)
294 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 359 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
360# endif
295# endif 361# endif
296# if defined GNULIB_POSIXCHECK 362# if defined GNULIB_POSIXCHECK
297# undef calloc 363# undef calloc
@@ -313,10 +379,18 @@ _GL_FUNCDECL_RPL (canonicalize_file_name, char *,
313_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); 379_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
314# else 380# else
315# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11 381# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11
382# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
316_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 383_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
317 (const char *name) 384 (const char *name)
385 _GL_ATTRIBUTE_NOTHROW
318 _GL_ARG_NONNULL ((1)) 386 _GL_ARG_NONNULL ((1))
319 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 387 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
388# else
389_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
390 (const char *name)
391 _GL_ARG_NONNULL ((1))
392 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
393# endif
320# endif 394# endif
321_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); 395_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
322# endif 396# endif
@@ -329,10 +403,18 @@ _GL_CXXALIASWARN (canonicalize_file_name);
329# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name 403# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name
330/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or 404/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
331 rpl_free. */ 405 rpl_free. */
406# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
332_GL_FUNCDECL_SYS (canonicalize_file_name, char *, 407_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
333 (const char *name) 408 (const char *name)
409 _GL_ATTRIBUTE_NOTHROW
334 _GL_ARG_NONNULL ((1)) 410 _GL_ARG_NONNULL ((1))
335 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 411 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
412# else
413_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
414 (const char *name)
415 _GL_ARG_NONNULL ((1))
416 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
417# endif
336# endif 418# endif
337# if defined GNULIB_POSIXCHECK 419# if defined GNULIB_POSIXCHECK
338# undef canonicalize_file_name 420# undef canonicalize_file_name
@@ -416,12 +498,24 @@ _GL_CXXALIASWARN (gcvt);
416 The three numbers are the load average of the last 1 minute, the last 5 498 The three numbers are the load average of the last 1 minute, the last 5
417 minutes, and the last 15 minutes, respectively. 499 minutes, and the last 15 minutes, respectively.
418 LOADAVG is an array of NELEM numbers. */ 500 LOADAVG is an array of NELEM numbers. */
419# if !@HAVE_DECL_GETLOADAVG@ 501# if @REPLACE_GETLOADAVG@
502# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
503# undef getloadavg
504# define getloadavg rpl_getloadavg
505# endif
506_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem)
507 _GL_ARG_NONNULL ((1)));
508_GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem));
509# else
510# if !@HAVE_DECL_GETLOADAVG@
420_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) 511_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
421 _GL_ARG_NONNULL ((1))); 512 _GL_ARG_NONNULL ((1)));
422# endif 513# endif
423_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); 514_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
515# endif
516# if __GLIBC__ >= 2
424_GL_CXXALIASWARN (getloadavg); 517_GL_CXXALIASWARN (getloadavg);
518# endif
425#elif defined GNULIB_POSIXCHECK 519#elif defined GNULIB_POSIXCHECK
426# undef getloadavg 520# undef getloadavg
427# if HAVE_RAW_DECL_GETLOADAVG 521# if HAVE_RAW_DECL_GETLOADAVG
@@ -430,6 +524,41 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
430# endif 524# endif
431#endif 525#endif
432 526
527#if @GNULIB_GETPROGNAME@
528/* Return the base name of the executing program.
529 On native Windows this will usually end in ".exe" or ".EXE". */
530# if @REPLACE_GETPROGNAME@
531# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
532# undef getprogname
533# define getprogname rpl_getprogname
534# endif
535# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
536_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
537# else
538_GL_FUNCDECL_RPL (getprogname, const char *, (void));
539# endif
540_GL_CXXALIAS_RPL (getprogname, const char *, (void));
541# else
542# if !@HAVE_GETPROGNAME@
543# if @HAVE_DECL_PROGRAM_INVOCATION_NAME@
544_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
545# else
546_GL_FUNCDECL_SYS (getprogname, const char *, (void));
547# endif
548# endif
549_GL_CXXALIAS_SYS (getprogname, const char *, (void));
550# endif
551# if __GLIBC__ >= 2
552_GL_CXXALIASWARN (getprogname);
553# endif
554#elif defined GNULIB_POSIXCHECK
555# undef getprogname
556# if HAVE_RAW_DECL_GETPROGNAME
557_GL_WARN_ON_USE (getprogname, "getprogname is unportable - "
558 "use gnulib module getprogname for portability");
559# endif
560#endif
561
433#if @GNULIB_GETSUBOPT@ 562#if @GNULIB_GETSUBOPT@
434/* Assuming *OPTIONP is a comma separated list of elements of the form 563/* Assuming *OPTIONP is a comma separated list of elements of the form
435 "token" or "token=value", getsubopt parses the first of these elements. 564 "token" or "token=value", getsubopt parses the first of these elements.
@@ -442,14 +571,28 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
442 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. 571 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
443 For more details see the POSIX specification. 572 For more details see the POSIX specification.
444 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */ 573 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
445# if !@HAVE_GETSUBOPT@ 574# if @REPLACE_GETSUBOPT@
575# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
576# undef getsubopt
577# define getsubopt rpl_getsubopt
578# endif
579_GL_FUNCDECL_RPL (getsubopt, int,
580 (char **optionp, char *const *tokens, char **valuep)
581 _GL_ARG_NONNULL ((1, 2, 3)));
582_GL_CXXALIAS_RPL (getsubopt, int,
583 (char **optionp, char *const *tokens, char **valuep));
584# else
585# if !@HAVE_GETSUBOPT@
446_GL_FUNCDECL_SYS (getsubopt, int, 586_GL_FUNCDECL_SYS (getsubopt, int,
447 (char **optionp, char *const *tokens, char **valuep) 587 (char **optionp, char *const *tokens, char **valuep)
448 _GL_ARG_NONNULL ((1, 2, 3))); 588 _GL_ARG_NONNULL ((1, 2, 3)));
449# endif 589# endif
450_GL_CXXALIAS_SYS (getsubopt, int, 590_GL_CXXALIAS_SYS (getsubopt, int,
451 (char **optionp, char *const *tokens, char **valuep)); 591 (char **optionp, char *const *tokens, char **valuep));
592# endif
593# if __GLIBC__ >= 2
452_GL_CXXALIASWARN (getsubopt); 594_GL_CXXALIASWARN (getsubopt);
595# endif
453#elif defined GNULIB_POSIXCHECK 596#elif defined GNULIB_POSIXCHECK
454# undef getsubopt 597# undef getsubopt
455# if HAVE_RAW_DECL_GETSUBOPT 598# if HAVE_RAW_DECL_GETSUBOPT
@@ -493,9 +636,16 @@ _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
493# else 636# else
494# if __GNUC__ >= 11 637# if __GNUC__ >= 11
495/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ 638/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
639# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
496_GL_FUNCDECL_SYS (malloc, void *, 640_GL_FUNCDECL_SYS (malloc, void *,
497 (size_t size) 641 (size_t size)
642 _GL_ATTRIBUTE_NOTHROW
498 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 643 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
644# else
645_GL_FUNCDECL_SYS (malloc, void *,
646 (size_t size)
647 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
648# endif
499# endif 649# endif
500_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); 650_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
501# endif 651# endif
@@ -505,9 +655,16 @@ _GL_CXXALIASWARN (malloc);
505#else 655#else
506# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc 656# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc
507/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */ 657/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
658# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
659_GL_FUNCDECL_SYS (malloc, void *,
660 (size_t size)
661 _GL_ATTRIBUTE_NOTHROW
662 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
663# else
508_GL_FUNCDECL_SYS (malloc, void *, 664_GL_FUNCDECL_SYS (malloc, void *,
509 (size_t size) 665 (size_t size)
510 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 666 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
667# endif
511# endif 668# endif
512# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 669# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
513# undef malloc 670# undef malloc
@@ -517,6 +674,51 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
517# endif 674# endif
518#endif 675#endif
519 676
677/* Return maximum number of bytes of a multibyte character. */
678#if @REPLACE_MB_CUR_MAX@
679# if !GNULIB_defined_MB_CUR_MAX
680static inline
681int gl_MB_CUR_MAX (void)
682{
683 /* Turn the value 3 to the value 4, as needed for the UTF-8 encoding. */
684 return MB_CUR_MAX + (MB_CUR_MAX == 3);
685}
686# undef MB_CUR_MAX
687# define MB_CUR_MAX gl_MB_CUR_MAX ()
688# define GNULIB_defined_MB_CUR_MAX 1
689# endif
690#endif
691
692/* Convert a string to a wide string. */
693#if @GNULIB_MBSTOWCS@
694# if @REPLACE_MBSTOWCS@
695# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
696# undef mbstowcs
697# define mbstowcs rpl_mbstowcs
698# endif
699_GL_FUNCDECL_RPL (mbstowcs, size_t,
700 (wchar_t *restrict dest, const char *restrict src,
701 size_t len)
702 _GL_ARG_NONNULL ((2)));
703_GL_CXXALIAS_RPL (mbstowcs, size_t,
704 (wchar_t *restrict dest, const char *restrict src,
705 size_t len));
706# else
707_GL_CXXALIAS_SYS (mbstowcs, size_t,
708 (wchar_t *restrict dest, const char *restrict src,
709 size_t len));
710# endif
711# if __GLIBC__ >= 2
712_GL_CXXALIASWARN (mbstowcs);
713# endif
714#elif defined GNULIB_POSIXCHECK
715# undef mbstowcs
716# if HAVE_RAW_DECL_MBSTOWCS
717_GL_WARN_ON_USE (mbstowcs, "mbstowcs is unportable - "
718 "use gnulib module mbstowcs for portability");
719# endif
720#endif
721
520/* Convert a multibyte character to a wide character. */ 722/* Convert a multibyte character to a wide character. */
521#if @GNULIB_MBTOWC@ 723#if @GNULIB_MBTOWC@
522# if @REPLACE_MBTOWC@ 724# if @REPLACE_MBTOWC@
@@ -579,12 +781,24 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
579 implementation. 781 implementation.
580 Returns the open file descriptor if successful, otherwise -1 and errno 782 Returns the open file descriptor if successful, otherwise -1 and errno
581 set. */ 783 set. */
582# if !@HAVE_MKOSTEMP@ 784# if @REPLACE_MKOSTEMP@
785# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
786# undef mkostemp
787# define mkostemp rpl_mkostemp
788# endif
789_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/)
790 _GL_ARG_NONNULL ((1)));
791_GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/));
792# else
793# if !@HAVE_MKOSTEMP@
583_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) 794_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
584 _GL_ARG_NONNULL ((1))); 795 _GL_ARG_NONNULL ((1)));
585# endif 796# endif
586_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); 797_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
798# endif
799# if __GLIBC__ >= 2
587_GL_CXXALIASWARN (mkostemp); 800_GL_CXXALIASWARN (mkostemp);
801# endif
588#elif defined GNULIB_POSIXCHECK 802#elif defined GNULIB_POSIXCHECK
589# undef mkostemp 803# undef mkostemp
590# if HAVE_RAW_DECL_MKOSTEMP 804# if HAVE_RAW_DECL_MKOSTEMP
@@ -607,14 +821,28 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
607 implementation. 821 implementation.
608 Returns the open file descriptor if successful, otherwise -1 and errno 822 Returns the open file descriptor if successful, otherwise -1 and errno
609 set. */ 823 set. */
610# if !@HAVE_MKOSTEMPS@ 824# if @REPLACE_MKOSTEMPS@
825# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
826# undef mkostemps
827# define mkostemps rpl_mkostemps
828# endif
829_GL_FUNCDECL_RPL (mkostemps, int,
830 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
831 _GL_ARG_NONNULL ((1)));
832_GL_CXXALIAS_RPL (mkostemps, int,
833 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
834# else
835# if !@HAVE_MKOSTEMPS@
611_GL_FUNCDECL_SYS (mkostemps, int, 836_GL_FUNCDECL_SYS (mkostemps, int,
612 (char * /*template*/, int /*suffixlen*/, int /*flags*/) 837 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
613 _GL_ARG_NONNULL ((1))); 838 _GL_ARG_NONNULL ((1)));
614# endif 839# endif
615_GL_CXXALIAS_SYS (mkostemps, int, 840_GL_CXXALIAS_SYS (mkostemps, int,
616 (char * /*template*/, int /*suffixlen*/, int /*flags*/)); 841 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
842# endif
843# if __GLIBC__ >= 2
617_GL_CXXALIASWARN (mkostemps); 844_GL_CXXALIASWARN (mkostemps);
845# endif
618#elif defined GNULIB_POSIXCHECK 846#elif defined GNULIB_POSIXCHECK
619# undef mkostemps 847# undef mkostemps
620# if HAVE_RAW_DECL_MKOSTEMPS 848# if HAVE_RAW_DECL_MKOSTEMPS
@@ -713,7 +941,7 @@ _GL_CXXALIAS_SYS (posix_memalign, int,
713 (void **memptr, size_t alignment, size_t size)); 941 (void **memptr, size_t alignment, size_t size));
714# endif 942# endif
715# endif 943# endif
716# if @HAVE_POSIX_MEMALIGN@ 944# if __GLIBC__ >= 2 && @HAVE_POSIX_MEMALIGN@
717_GL_CXXALIASWARN (posix_memalign); 945_GL_CXXALIASWARN (posix_memalign);
718# endif 946# endif
719#elif defined GNULIB_POSIXCHECK 947#elif defined GNULIB_POSIXCHECK
@@ -727,11 +955,22 @@ _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
727#if @GNULIB_POSIX_OPENPT@ 955#if @GNULIB_POSIX_OPENPT@
728/* Return an FD open to the master side of a pseudo-terminal. Flags should 956/* Return an FD open to the master side of a pseudo-terminal. Flags should
729 include O_RDWR, and may also include O_NOCTTY. */ 957 include O_RDWR, and may also include O_NOCTTY. */
730# if !@HAVE_POSIX_OPENPT@ 958# if @REPLACE_POSIX_OPENPT@
959# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
960# undef posix_openpt
961# define posix_openpt rpl_posix_openpt
962# endif
963_GL_FUNCDECL_RPL (posix_openpt, int, (int flags));
964_GL_CXXALIAS_RPL (posix_openpt, int, (int flags));
965# else
966# if !@HAVE_POSIX_OPENPT@
731_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); 967_GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
732# endif 968# endif
733_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); 969_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
970# endif
971# if __GLIBC__ >= 2
734_GL_CXXALIASWARN (posix_openpt); 972_GL_CXXALIASWARN (posix_openpt);
973# endif
735#elif defined GNULIB_POSIXCHECK 974#elif defined GNULIB_POSIXCHECK
736# undef posix_openpt 975# undef posix_openpt
737# if HAVE_RAW_DECL_POSIX_OPENPT 976# if HAVE_RAW_DECL_POSIX_OPENPT
@@ -808,6 +1047,10 @@ _GL_CXXALIAS_RPL (putenv, int, (char *string));
808# define putenv _putenv 1047# define putenv _putenv
809# endif 1048# endif
810_GL_CXXALIAS_MDA (putenv, int, (char *string)); 1049_GL_CXXALIAS_MDA (putenv, int, (char *string));
1050# elif defined __KLIBC__
1051/* Need to cast, because on OS/2 kLIBC, the first parameter is
1052 const char *string. */
1053_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string));
811# else 1054# else
812_GL_CXXALIAS_SYS (putenv, int, (char *string)); 1055_GL_CXXALIAS_SYS (putenv, int, (char *string));
813# endif 1056# endif
@@ -824,6 +1067,10 @@ _GL_CXXALIASWARN (putenv);
824/* Need to cast, because on mingw, the parameter is either 1067/* Need to cast, because on mingw, the parameter is either
825 'const char *string' or 'char *string'. */ 1068 'const char *string' or 'char *string'. */
826_GL_CXXALIAS_MDA_CAST (putenv, int, (char *string)); 1069_GL_CXXALIAS_MDA_CAST (putenv, int, (char *string));
1070# elif defined __KLIBC__
1071/* Need to cast, because on OS/2 kLIBC, the first parameter is
1072 const char *string. */
1073_GL_CXXALIAS_SYS_CAST (putenv, int, (char *string));
827# else 1074# else
828_GL_CXXALIAS_SYS (putenv, int, (char *string)); 1075_GL_CXXALIAS_SYS (putenv, int, (char *string));
829# endif 1076# endif
@@ -865,7 +1112,9 @@ _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
865 _gl_qsort_r_compar_fn compare, 1112 _gl_qsort_r_compar_fn compare,
866 void *arg)); 1113 void *arg));
867# endif 1114# endif
1115# if __GLIBC__ >= 2
868_GL_CXXALIASWARN (qsort_r); 1116_GL_CXXALIASWARN (qsort_r);
1117# endif
869#elif defined GNULIB_POSIXCHECK 1118#elif defined GNULIB_POSIXCHECK
870# undef qsort_r 1119# undef qsort_r
871# if HAVE_RAW_DECL_QSORT_R 1120# if HAVE_RAW_DECL_QSORT_R
@@ -875,11 +1124,26 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
875#endif 1124#endif
876 1125
877 1126
878#if @GNULIB_RANDOM_R@ 1127#if @GNULIB_RAND@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@)
879# if !@HAVE_RANDOM_R@ 1128# ifndef RAND_MAX
880# ifndef RAND_MAX 1129# define RAND_MAX 2147483647
881# define RAND_MAX 2147483647 1130# endif
1131#endif
1132
1133
1134#if @GNULIB_RAND@
1135# if @REPLACE_RAND@
1136# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1137# undef rand
1138# define rand rpl_rand
882# endif 1139# endif
1140_GL_FUNCDECL_RPL (rand, int, (void));
1141_GL_CXXALIAS_RPL (rand, int, (void));
1142# else
1143_GL_CXXALIAS_SYS (rand, int, (void));
1144# endif
1145# if __GLIBC__ >= 2
1146_GL_CXXALIASWARN (rand);
883# endif 1147# endif
884#endif 1148#endif
885 1149
@@ -900,7 +1164,9 @@ _GL_FUNCDECL_SYS (random, long, (void));
900 int. */ 1164 int. */
901_GL_CXXALIAS_SYS_CAST (random, long, (void)); 1165_GL_CXXALIAS_SYS_CAST (random, long, (void));
902# endif 1166# endif
1167# if __GLIBC__ >= 2
903_GL_CXXALIASWARN (random); 1168_GL_CXXALIASWARN (random);
1169# endif
904#elif defined GNULIB_POSIXCHECK 1170#elif defined GNULIB_POSIXCHECK
905# undef random 1171# undef random
906# if HAVE_RAW_DECL_RANDOM 1172# if HAVE_RAW_DECL_RANDOM
@@ -925,7 +1191,9 @@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
925 unsigned long seed. */ 1191 unsigned long seed. */
926_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); 1192_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
927# endif 1193# endif
1194# if __GLIBC__ >= 2
928_GL_CXXALIASWARN (srandom); 1195_GL_CXXALIASWARN (srandom);
1196# endif
929#elif defined GNULIB_POSIXCHECK 1197#elif defined GNULIB_POSIXCHECK
930# undef srandom 1198# undef srandom
931# if HAVE_RAW_DECL_SRANDOM 1199# if HAVE_RAW_DECL_SRANDOM
@@ -956,7 +1224,9 @@ _GL_FUNCDECL_SYS (initstate, char *,
956_GL_CXXALIAS_SYS_CAST (initstate, char *, 1224_GL_CXXALIAS_SYS_CAST (initstate, char *,
957 (unsigned int seed, char *buf, size_t buf_size)); 1225 (unsigned int seed, char *buf, size_t buf_size));
958# endif 1226# endif
1227# if __GLIBC__ >= 2
959_GL_CXXALIASWARN (initstate); 1228_GL_CXXALIASWARN (initstate);
1229# endif
960#elif defined GNULIB_POSIXCHECK 1230#elif defined GNULIB_POSIXCHECK
961# undef initstate 1231# undef initstate
962# if HAVE_RAW_DECL_INITSTATE 1232# if HAVE_RAW_DECL_INITSTATE
@@ -981,7 +1251,9 @@ _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
981 is const char *arg_state. */ 1251 is const char *arg_state. */
982_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state)); 1252_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
983# endif 1253# endif
1254# if __GLIBC__ >= 2
984_GL_CXXALIASWARN (setstate); 1255_GL_CXXALIASWARN (setstate);
1256# endif
985#elif defined GNULIB_POSIXCHECK 1257#elif defined GNULIB_POSIXCHECK
986# undef setstate 1258# undef setstate
987# if HAVE_RAW_DECL_SETSTATE 1259# if HAVE_RAW_DECL_SETSTATE
@@ -1126,8 +1398,16 @@ _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
1126# else 1398# else
1127# if __GNUC__ >= 11 1399# if __GNUC__ >= 11
1128/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ 1400/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1129_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size) 1401# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1130 _GL_ATTRIBUTE_DEALLOC_FREE); 1402_GL_FUNCDECL_SYS (realloc, void *,
1403 (void *ptr, size_t size)
1404 _GL_ATTRIBUTE_NOTHROW
1405 _GL_ATTRIBUTE_DEALLOC_FREE);
1406# else
1407_GL_FUNCDECL_SYS (realloc, void *,
1408 (void *ptr, size_t size)
1409 _GL_ATTRIBUTE_DEALLOC_FREE);
1410# endif
1131# endif 1411# endif
1132_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); 1412_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
1133# endif 1413# endif
@@ -1137,8 +1417,16 @@ _GL_CXXALIASWARN (realloc);
1137#else 1417#else
1138# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc 1418# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc
1139/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */ 1419/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1140_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size) 1420# if __GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2
1141 _GL_ATTRIBUTE_DEALLOC_FREE); 1421_GL_FUNCDECL_SYS (realloc, void *,
1422 (void *ptr, size_t size)
1423 _GL_ATTRIBUTE_NOTHROW
1424 _GL_ATTRIBUTE_DEALLOC_FREE);
1425# else
1426_GL_FUNCDECL_SYS (realloc, void *,
1427 (void *ptr, size_t size)
1428 _GL_ATTRIBUTE_DEALLOC_FREE);
1429# endif
1142# endif 1430# endif
1143# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 1431# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1144# undef realloc 1432# undef realloc
@@ -1167,7 +1455,9 @@ _GL_FUNCDECL_SYS (reallocarray, void *,
1167_GL_CXXALIAS_SYS (reallocarray, void *, 1455_GL_CXXALIAS_SYS (reallocarray, void *,
1168 (void *ptr, size_t nmemb, size_t size)); 1456 (void *ptr, size_t nmemb, size_t size));
1169# endif 1457# endif
1458# if __GLIBC__ >= 2
1170_GL_CXXALIASWARN (reallocarray); 1459_GL_CXXALIASWARN (reallocarray);
1460# endif
1171#elif defined GNULIB_POSIXCHECK 1461#elif defined GNULIB_POSIXCHECK
1172# undef reallocarray 1462# undef reallocarray
1173# if HAVE_RAW_DECL_REALLOCARRAY 1463# if HAVE_RAW_DECL_REALLOCARRAY
@@ -1301,6 +1591,38 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
1301# endif 1591# endif
1302#endif 1592#endif
1303 1593
1594#if @GNULIB_STRTOF@
1595 /* Parse a float from STRING, updating ENDP if appropriate. */
1596# if @REPLACE_STRTOF@
1597# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1598# define strtof rpl_strtof
1599# endif
1600# define GNULIB_defined_strtof_function 1
1601_GL_FUNCDECL_RPL (strtof, float,
1602 (const char *restrict str, char **restrict endp)
1603 _GL_ARG_NONNULL ((1)));
1604_GL_CXXALIAS_RPL (strtof, float,
1605 (const char *restrict str, char **restrict endp));
1606# else
1607# if !@HAVE_STRTOF@
1608_GL_FUNCDECL_SYS (strtof, float,
1609 (const char *restrict str, char **restrict endp)
1610 _GL_ARG_NONNULL ((1)));
1611# endif
1612_GL_CXXALIAS_SYS (strtof, float,
1613 (const char *restrict str, char **restrict endp));
1614# endif
1615# if __GLIBC__ >= 2
1616_GL_CXXALIASWARN (strtof);
1617# endif
1618#elif defined GNULIB_POSIXCHECK
1619# undef strtof
1620# if HAVE_RAW_DECL_STRTOF
1621_GL_WARN_ON_USE (strtof, "strtof is unportable - "
1622 "use gnulib module strtof for portability");
1623# endif
1624#endif
1625
1304#if @GNULIB_STRTOLD@ 1626#if @GNULIB_STRTOLD@
1305 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */ 1627 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
1306# if @REPLACE_STRTOLD@ 1628# if @REPLACE_STRTOLD@