| 1 |
/* A GNU-like <stdlib.h>. |
| 2 |
|
| 3 |
Copyright (C) 1995, 2001-2004, 2006-2020 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This program is free software: you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation; either version 3 of the License, or |
| 8 |
(at your option) any later version. |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 17 |
|
| 18 |
#if __GNUC__ >= 3 |
| 19 |
@PRAGMA_SYSTEM_HEADER@ |
| 20 |
#endif |
| 21 |
@PRAGMA_COLUMNS@ |
| 22 |
|
| 23 |
#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc |
| 24 |
/* Special invocation conventions inside some gnulib header files, |
| 25 |
and inside some glibc header files, respectively. */ |
| 26 |
|
| 27 |
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ |
| 28 |
|
| 29 |
#else |
| 30 |
/* Normal invocation convention. */ |
| 31 |
|
| 32 |
#ifndef _@GUARD_PREFIX@_STDLIB_H |
| 33 |
|
| 34 |
/* The include_next requires a split double-inclusion guard. */ |
| 35 |
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ |
| 36 |
|
| 37 |
#ifndef _@GUARD_PREFIX@_STDLIB_H |
| 38 |
#define _@GUARD_PREFIX@_STDLIB_H |
| 39 |
|
| 40 |
/* NetBSD 5.0 mis-defines NULL. */ |
| 41 |
#include <stddef.h> |
| 42 |
|
| 43 |
/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */ |
| 44 |
#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS |
| 45 |
# include <sys/wait.h> |
| 46 |
#endif |
| 47 |
|
| 48 |
/* Solaris declares getloadavg() in <sys/loadavg.h>. */ |
| 49 |
#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ |
| 50 |
/* OpenIndiana has a bug: <sys/time.h> must be included before |
| 51 |
<sys/loadavg.h>. */ |
| 52 |
# include <sys/time.h> |
| 53 |
# include <sys/loadavg.h> |
| 54 |
#endif |
| 55 |
|
| 56 |
/* Native Windows platforms declare mktemp() in <io.h>. */ |
| 57 |
#if 0 && (defined _WIN32 && ! defined __CYGWIN__) |
| 58 |
# include <io.h> |
| 59 |
#endif |
| 60 |
|
| 61 |
#if @GNULIB_RANDOM_R@ |
| 62 |
|
| 63 |
/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included |
| 64 |
from <stdlib.h> if _REENTRANT is defined. Include it whenever we need |
| 65 |
'struct random_data'. */ |
| 66 |
# if @HAVE_RANDOM_H@ |
| 67 |
# include <random.h> |
| 68 |
# endif |
| 69 |
|
| 70 |
# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@ |
| 71 |
# include <stdint.h> |
| 72 |
# endif |
| 73 |
|
| 74 |
# if !@HAVE_STRUCT_RANDOM_DATA@ |
| 75 |
/* Define 'struct random_data'. |
| 76 |
But allow multiple gnulib generated <stdlib.h> replacements to coexist. */ |
| 77 |
# if !GNULIB_defined_struct_random_data |
| 78 |
struct random_data |
| 79 |
{ |
| 80 |
int32_t *fptr; /* Front pointer. */ |
| 81 |
int32_t *rptr; /* Rear pointer. */ |
| 82 |
int32_t *state; /* Array of state values. */ |
| 83 |
int rand_type; /* Type of random number generator. */ |
| 84 |
int rand_deg; /* Degree of random number generator. */ |
| 85 |
int rand_sep; /* Distance between front and rear. */ |
| 86 |
int32_t *end_ptr; /* Pointer behind state table. */ |
| 87 |
}; |
| 88 |
# define GNULIB_defined_struct_random_data 1 |
| 89 |
# endif |
| 90 |
# endif |
| 91 |
#endif |
| 92 |
|
| 93 |
#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__) |
| 94 |
/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */ |
| 95 |
/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */ |
| 96 |
/* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */ |
| 97 |
/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ |
| 98 |
/* But avoid namespace pollution on glibc systems and native Windows. */ |
| 99 |
# include <unistd.h> |
| 100 |
#endif |
| 101 |
|
| 102 |
/* The __attribute__ feature is available in gcc versions 2.5 and later. |
| 103 |
The attribute __pure__ was added in gcc 2.96. */ |
| 104 |
#ifndef _GL_ATTRIBUTE_PURE |
| 105 |
# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ |
| 106 |
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
| 107 |
# else |
| 108 |
# define _GL_ATTRIBUTE_PURE /* empty */ |
| 109 |
# endif |
| 110 |
#endif |
| 111 |
|
| 112 |
/* The definition of _Noreturn is copied here. */ |
| 113 |
|
| 114 |
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
| 115 |
|
| 116 |
/* The definition of _GL_ARG_NONNULL is copied here. */ |
| 117 |
|
| 118 |
/* The definition of _GL_WARN_ON_USE is copied here. */ |
| 119 |
|
| 120 |
|
| 121 |
/* Some systems do not define EXIT_*, despite otherwise supporting C89. */ |
| 122 |
#ifndef EXIT_SUCCESS |
| 123 |
# define EXIT_SUCCESS 0 |
| 124 |
#endif |
| 125 |
/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere |
| 126 |
with proper operation of xargs. */ |
| 127 |
#ifndef EXIT_FAILURE |
| 128 |
# define EXIT_FAILURE 1 |
| 129 |
#elif EXIT_FAILURE != 1 |
| 130 |
# undef EXIT_FAILURE |
| 131 |
# define EXIT_FAILURE 1 |
| 132 |
#endif |
| 133 |
|
| 134 |
|
| 135 |
#if @GNULIB__EXIT@ |
| 136 |
/* Terminate the current process with the given return code, without running |
| 137 |
the 'atexit' handlers. */ |
| 138 |
# if !@HAVE__EXIT@ |
| 139 |
_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); |
| 140 |
# endif |
| 141 |
_GL_CXXALIAS_SYS (_Exit, void, (int status)); |
| 142 |
_GL_CXXALIASWARN (_Exit); |
| 143 |
#elif defined GNULIB_POSIXCHECK |
| 144 |
# undef _Exit |
| 145 |
# if HAVE_RAW_DECL__EXIT |
| 146 |
_GL_WARN_ON_USE (_Exit, "_Exit is unportable - " |
| 147 |
"use gnulib module _Exit for portability"); |
| 148 |
# endif |
| 149 |
#endif |
| 150 |
|
| 151 |
|
| 152 |
/* Allocate memory with indefinite extent and specified alignment. */ |
| 153 |
#if @GNULIB_ALIGNED_ALLOC@ |
| 154 |
# if @REPLACE_ALIGNED_ALLOC@ |
| 155 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 156 |
# undef aligned_alloc |
| 157 |
# define aligned_alloc rpl_aligned_alloc |
| 158 |
# endif |
| 159 |
_GL_FUNCDECL_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); |
| 160 |
_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size)); |
| 161 |
# else |
| 162 |
# if @HAVE_ALIGNED_ALLOC@ |
| 163 |
_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size)); |
| 164 |
# endif |
| 165 |
# endif |
| 166 |
# if @HAVE_ALIGNED_ALLOC@ |
| 167 |
_GL_CXXALIASWARN (aligned_alloc); |
| 168 |
# endif |
| 169 |
#elif defined GNULIB_POSIXCHECK |
| 170 |
# undef aligned_alloc |
| 171 |
# if HAVE_RAW_DECL_ALIGNED_ALLOC |
| 172 |
_GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - " |
| 173 |
"use gnulib module aligned_alloc for portability"); |
| 174 |
# endif |
| 175 |
#endif |
| 176 |
|
| 177 |
#if @GNULIB_ATOLL@ |
| 178 |
/* Parse a signed decimal integer. |
| 179 |
Returns the value of the integer. Errors are not detected. */ |
| 180 |
# if !@HAVE_ATOLL@ |
| 181 |
_GL_FUNCDECL_SYS (atoll, long long, (const char *string) |
| 182 |
_GL_ATTRIBUTE_PURE |
| 183 |
_GL_ARG_NONNULL ((1))); |
| 184 |
# endif |
| 185 |
_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); |
| 186 |
_GL_CXXALIASWARN (atoll); |
| 187 |
#elif defined GNULIB_POSIXCHECK |
| 188 |
# undef atoll |
| 189 |
# if HAVE_RAW_DECL_ATOLL |
| 190 |
_GL_WARN_ON_USE (atoll, "atoll is unportable - " |
| 191 |
"use gnulib module atoll for portability"); |
| 192 |
# endif |
| 193 |
#endif |
| 194 |
|
| 195 |
#if @GNULIB_CALLOC_POSIX@ |
| 196 |
# if @REPLACE_CALLOC@ |
| 197 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 198 |
# undef calloc |
| 199 |
# define calloc rpl_calloc |
| 200 |
# endif |
| 201 |
_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size)); |
| 202 |
_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); |
| 203 |
# else |
| 204 |
_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); |
| 205 |
# endif |
| 206 |
# if __GLIBC__ >= 2 |
| 207 |
_GL_CXXALIASWARN (calloc); |
| 208 |
# endif |
| 209 |
#elif defined GNULIB_POSIXCHECK |
| 210 |
# undef calloc |
| 211 |
/* Assume calloc is always declared. */ |
| 212 |
_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " |
| 213 |
"use gnulib module calloc-posix for portability"); |
| 214 |
#endif |
| 215 |
|
| 216 |
#if @GNULIB_CANONICALIZE_FILE_NAME@ |
| 217 |
# if @REPLACE_CANONICALIZE_FILE_NAME@ |
| 218 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 219 |
# define canonicalize_file_name rpl_canonicalize_file_name |
| 220 |
# endif |
| 221 |
_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name) |
| 222 |
_GL_ARG_NONNULL ((1))); |
| 223 |
_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); |
| 224 |
# else |
| 225 |
# if !@HAVE_CANONICALIZE_FILE_NAME@ |
| 226 |
_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) |
| 227 |
_GL_ARG_NONNULL ((1))); |
| 228 |
# endif |
| 229 |
_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); |
| 230 |
# endif |
| 231 |
# ifndef GNULIB_defined_canonicalize_file_name |
| 232 |
# define GNULIB_defined_canonicalize_file_name \ |
| 233 |
(!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@) |
| 234 |
# endif |
| 235 |
_GL_CXXALIASWARN (canonicalize_file_name); |
| 236 |
#elif defined GNULIB_POSIXCHECK |
| 237 |
# undef canonicalize_file_name |
| 238 |
# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME |
| 239 |
_GL_WARN_ON_USE (canonicalize_file_name, |
| 240 |
"canonicalize_file_name is unportable - " |
| 241 |
"use gnulib module canonicalize-lgpl for portability"); |
| 242 |
# endif |
| 243 |
#endif |
| 244 |
|
| 245 |
#if defined _WIN32 && !defined __CYGWIN__ |
| 246 |
# undef ecvt |
| 247 |
# define ecvt _ecvt |
| 248 |
#endif |
| 249 |
|
| 250 |
#if defined _WIN32 && !defined __CYGWIN__ |
| 251 |
# undef fcvt |
| 252 |
# define fcvt _fcvt |
| 253 |
#endif |
| 254 |
|
| 255 |
#if defined _WIN32 && !defined __CYGWIN__ |
| 256 |
# undef gcvt |
| 257 |
# define gcvt _gcvt |
| 258 |
#endif |
| 259 |
|
| 260 |
#if @GNULIB_GETLOADAVG@ |
| 261 |
/* Store max(NELEM,3) load average numbers in LOADAVG[]. |
| 262 |
The three numbers are the load average of the last 1 minute, the last 5 |
| 263 |
minutes, and the last 15 minutes, respectively. |
| 264 |
LOADAVG is an array of NELEM numbers. */ |
| 265 |
# if !@HAVE_DECL_GETLOADAVG@ |
| 266 |
_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) |
| 267 |
_GL_ARG_NONNULL ((1))); |
| 268 |
# endif |
| 269 |
_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); |
| 270 |
_GL_CXXALIASWARN (getloadavg); |
| 271 |
#elif defined GNULIB_POSIXCHECK |
| 272 |
# undef getloadavg |
| 273 |
# if HAVE_RAW_DECL_GETLOADAVG |
| 274 |
_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " |
| 275 |
"use gnulib module getloadavg for portability"); |
| 276 |
# endif |
| 277 |
#endif |
| 278 |
|
| 279 |
#if @GNULIB_GETSUBOPT@ |
| 280 |
/* Assuming *OPTIONP is a comma separated list of elements of the form |
| 281 |
"token" or "token=value", getsubopt parses the first of these elements. |
| 282 |
If the first element refers to a "token" that is member of the given |
| 283 |
NULL-terminated array of tokens: |
| 284 |
- It replaces the comma with a NUL byte, updates *OPTIONP to point past |
| 285 |
the first option and the comma, sets *VALUEP to the value of the |
| 286 |
element (or NULL if it doesn't contain an "=" sign), |
| 287 |
- It returns the index of the "token" in the given array of tokens. |
| 288 |
Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. |
| 289 |
For more details see the POSIX specification. |
| 290 |
https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */ |
| 291 |
# if !@HAVE_GETSUBOPT@ |
| 292 |
_GL_FUNCDECL_SYS (getsubopt, int, |
| 293 |
(char **optionp, char *const *tokens, char **valuep) |
| 294 |
_GL_ARG_NONNULL ((1, 2, 3))); |
| 295 |
# endif |
| 296 |
_GL_CXXALIAS_SYS (getsubopt, int, |
| 297 |
(char **optionp, char *const *tokens, char **valuep)); |
| 298 |
_GL_CXXALIASWARN (getsubopt); |
| 299 |
#elif defined GNULIB_POSIXCHECK |
| 300 |
# undef getsubopt |
| 301 |
# if HAVE_RAW_DECL_GETSUBOPT |
| 302 |
_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " |
| 303 |
"use gnulib module getsubopt for portability"); |
| 304 |
# endif |
| 305 |
#endif |
| 306 |
|
| 307 |
#if @GNULIB_GRANTPT@ |
| 308 |
/* Change the ownership and access permission of the slave side of the |
| 309 |
pseudo-terminal whose master side is specified by FD. */ |
| 310 |
# if !@HAVE_GRANTPT@ |
| 311 |
_GL_FUNCDECL_SYS (grantpt, int, (int fd)); |
| 312 |
# endif |
| 313 |
_GL_CXXALIAS_SYS (grantpt, int, (int fd)); |
| 314 |
_GL_CXXALIASWARN (grantpt); |
| 315 |
#elif defined GNULIB_POSIXCHECK |
| 316 |
# undef grantpt |
| 317 |
# if HAVE_RAW_DECL_GRANTPT |
| 318 |
_GL_WARN_ON_USE (grantpt, "grantpt is not portable - " |
| 319 |
"use gnulib module grantpt for portability"); |
| 320 |
# endif |
| 321 |
#endif |
| 322 |
|
| 323 |
/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not |
| 324 |
rely on GNU or POSIX semantics for malloc and realloc (for example, |
| 325 |
by never specifying a zero size), so it does not need malloc or |
| 326 |
realloc to be redefined. */ |
| 327 |
#if @GNULIB_MALLOC_POSIX@ |
| 328 |
# if @REPLACE_MALLOC@ |
| 329 |
# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ |
| 330 |
|| _GL_USE_STDLIB_ALLOC) |
| 331 |
# undef malloc |
| 332 |
# define malloc rpl_malloc |
| 333 |
# endif |
| 334 |
_GL_FUNCDECL_RPL (malloc, void *, (size_t size)); |
| 335 |
_GL_CXXALIAS_RPL (malloc, void *, (size_t size)); |
| 336 |
# else |
| 337 |
_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); |
| 338 |
# endif |
| 339 |
# if __GLIBC__ >= 2 |
| 340 |
_GL_CXXALIASWARN (malloc); |
| 341 |
# endif |
| 342 |
#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC |
| 343 |
# undef malloc |
| 344 |
/* Assume malloc is always declared. */ |
| 345 |
_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " |
| 346 |
"use gnulib module malloc-posix for portability"); |
| 347 |
#endif |
| 348 |
|
| 349 |
/* Convert a multibyte character to a wide character. */ |
| 350 |
#if @GNULIB_MBTOWC@ |
| 351 |
# if @REPLACE_MBTOWC@ |
| 352 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 353 |
# undef mbtowc |
| 354 |
# define mbtowc rpl_mbtowc |
| 355 |
# endif |
| 356 |
_GL_FUNCDECL_RPL (mbtowc, int, |
| 357 |
(wchar_t *restrict pwc, const char *restrict s, size_t n)); |
| 358 |
_GL_CXXALIAS_RPL (mbtowc, int, |
| 359 |
(wchar_t *restrict pwc, const char *restrict s, size_t n)); |
| 360 |
# else |
| 361 |
# if !@HAVE_MBTOWC@ |
| 362 |
_GL_FUNCDECL_SYS (mbtowc, int, |
| 363 |
(wchar_t *restrict pwc, const char *restrict s, size_t n)); |
| 364 |
# endif |
| 365 |
_GL_CXXALIAS_SYS (mbtowc, int, |
| 366 |
(wchar_t *restrict pwc, const char *restrict s, size_t n)); |
| 367 |
# endif |
| 368 |
# if __GLIBC__ >= 2 |
| 369 |
_GL_CXXALIASWARN (mbtowc); |
| 370 |
# endif |
| 371 |
#elif defined GNULIB_POSIXCHECK |
| 372 |
# undef mbtowc |
| 373 |
# if HAVE_RAW_DECL_MBTOWC |
| 374 |
_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - " |
| 375 |
"use gnulib module mbtowc for portability"); |
| 376 |
# endif |
| 377 |
#endif |
| 378 |
|
| 379 |
#if @GNULIB_MKDTEMP@ |
| 380 |
/* Create a unique temporary directory from TEMPLATE. |
| 381 |
The last six characters of TEMPLATE must be "XXXXXX"; |
| 382 |
they are replaced with a string that makes the directory name unique. |
| 383 |
Returns TEMPLATE, or a null pointer if it cannot get a unique name. |
| 384 |
The directory is created mode 700. */ |
| 385 |
# if !@HAVE_MKDTEMP@ |
| 386 |
_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); |
| 387 |
# endif |
| 388 |
_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); |
| 389 |
_GL_CXXALIASWARN (mkdtemp); |
| 390 |
#elif defined GNULIB_POSIXCHECK |
| 391 |
# undef mkdtemp |
| 392 |
# if HAVE_RAW_DECL_MKDTEMP |
| 393 |
_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " |
| 394 |
"use gnulib module mkdtemp for portability"); |
| 395 |
# endif |
| 396 |
#endif |
| 397 |
|
| 398 |
#if @GNULIB_MKOSTEMP@ |
| 399 |
/* Create a unique temporary file from TEMPLATE. |
| 400 |
The last six characters of TEMPLATE must be "XXXXXX"; |
| 401 |
they are replaced with a string that makes the file name unique. |
| 402 |
The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) |
| 403 |
and O_TEXT, O_BINARY (defined in "binary-io.h"). |
| 404 |
The file is then created, with the specified flags, ensuring it didn't exist |
| 405 |
before. |
| 406 |
The file is created read-write (mask at least 0600 & ~umask), but it may be |
| 407 |
world-readable and world-writable (mask 0666 & ~umask), depending on the |
| 408 |
implementation. |
| 409 |
Returns the open file descriptor if successful, otherwise -1 and errno |
| 410 |
set. */ |
| 411 |
# if !@HAVE_MKOSTEMP@ |
| 412 |
_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) |
| 413 |
_GL_ARG_NONNULL ((1))); |
| 414 |
# endif |
| 415 |
_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); |
| 416 |
_GL_CXXALIASWARN (mkostemp); |
| 417 |
#elif defined GNULIB_POSIXCHECK |
| 418 |
# undef mkostemp |
| 419 |
# if HAVE_RAW_DECL_MKOSTEMP |
| 420 |
_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " |
| 421 |
"use gnulib module mkostemp for portability"); |
| 422 |
# endif |
| 423 |
#endif |
| 424 |
|
| 425 |
#if @GNULIB_MKOSTEMPS@ |
| 426 |
/* Create a unique temporary file from TEMPLATE. |
| 427 |
The last six characters of TEMPLATE before a suffix of length |
| 428 |
SUFFIXLEN must be "XXXXXX"; |
| 429 |
they are replaced with a string that makes the file name unique. |
| 430 |
The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) |
| 431 |
and O_TEXT, O_BINARY (defined in "binary-io.h"). |
| 432 |
The file is then created, with the specified flags, ensuring it didn't exist |
| 433 |
before. |
| 434 |
The file is created read-write (mask at least 0600 & ~umask), but it may be |
| 435 |
world-readable and world-writable (mask 0666 & ~umask), depending on the |
| 436 |
implementation. |
| 437 |
Returns the open file descriptor if successful, otherwise -1 and errno |
| 438 |
set. */ |
| 439 |
# if !@HAVE_MKOSTEMPS@ |
| 440 |
_GL_FUNCDECL_SYS (mkostemps, int, |
| 441 |
(char * /*template*/, int /*suffixlen*/, int /*flags*/) |
| 442 |
_GL_ARG_NONNULL ((1))); |
| 443 |
# endif |
| 444 |
_GL_CXXALIAS_SYS (mkostemps, int, |
| 445 |
(char * /*template*/, int /*suffixlen*/, int /*flags*/)); |
| 446 |
_GL_CXXALIASWARN (mkostemps); |
| 447 |
#elif defined GNULIB_POSIXCHECK |
| 448 |
# undef mkostemps |
| 449 |
# if HAVE_RAW_DECL_MKOSTEMPS |
| 450 |
_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " |
| 451 |
"use gnulib module mkostemps for portability"); |
| 452 |
# endif |
| 453 |
#endif |
| 454 |
|
| 455 |
#if @GNULIB_MKSTEMP@ |
| 456 |
/* Create a unique temporary file from TEMPLATE. |
| 457 |
The last six characters of TEMPLATE must be "XXXXXX"; |
| 458 |
they are replaced with a string that makes the file name unique. |
| 459 |
The file is then created, ensuring it didn't exist before. |
| 460 |
The file is created read-write (mask at least 0600 & ~umask), but it may be |
| 461 |
world-readable and world-writable (mask 0666 & ~umask), depending on the |
| 462 |
implementation. |
| 463 |
Returns the open file descriptor if successful, otherwise -1 and errno |
| 464 |
set. */ |
| 465 |
# if @REPLACE_MKSTEMP@ |
| 466 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 467 |
# define mkstemp rpl_mkstemp |
| 468 |
# endif |
| 469 |
_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); |
| 470 |
_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); |
| 471 |
# else |
| 472 |
# if ! @HAVE_MKSTEMP@ |
| 473 |
_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); |
| 474 |
# endif |
| 475 |
_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); |
| 476 |
# endif |
| 477 |
_GL_CXXALIASWARN (mkstemp); |
| 478 |
#elif defined GNULIB_POSIXCHECK |
| 479 |
# undef mkstemp |
| 480 |
# if HAVE_RAW_DECL_MKSTEMP |
| 481 |
_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " |
| 482 |
"use gnulib module mkstemp for portability"); |
| 483 |
# endif |
| 484 |
#endif |
| 485 |
|
| 486 |
#if @GNULIB_MKSTEMPS@ |
| 487 |
/* Create a unique temporary file from TEMPLATE. |
| 488 |
The last six characters of TEMPLATE prior to a suffix of length |
| 489 |
SUFFIXLEN must be "XXXXXX"; |
| 490 |
they are replaced with a string that makes the file name unique. |
| 491 |
The file is then created, ensuring it didn't exist before. |
| 492 |
The file is created read-write (mask at least 0600 & ~umask), but it may be |
| 493 |
world-readable and world-writable (mask 0666 & ~umask), depending on the |
| 494 |
implementation. |
| 495 |
Returns the open file descriptor if successful, otherwise -1 and errno |
| 496 |
set. */ |
| 497 |
# if !@HAVE_MKSTEMPS@ |
| 498 |
_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) |
| 499 |
_GL_ARG_NONNULL ((1))); |
| 500 |
# endif |
| 501 |
_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); |
| 502 |
_GL_CXXALIASWARN (mkstemps); |
| 503 |
#elif defined GNULIB_POSIXCHECK |
| 504 |
# undef mkstemps |
| 505 |
# if HAVE_RAW_DECL_MKSTEMPS |
| 506 |
_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " |
| 507 |
"use gnulib module mkstemps for portability"); |
| 508 |
# endif |
| 509 |
#endif |
| 510 |
|
| 511 |
#if defined _WIN32 && !defined __CYGWIN__ |
| 512 |
# undef mktemp |
| 513 |
# define mktemp _mktemp |
| 514 |
#endif |
| 515 |
|
| 516 |
/* Allocate memory with indefinite extent and specified alignment. */ |
| 517 |
#if @GNULIB_POSIX_MEMALIGN@ |
| 518 |
# if @REPLACE_POSIX_MEMALIGN@ |
| 519 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 520 |
# undef posix_memalign |
| 521 |
# define posix_memalign rpl_posix_memalign |
| 522 |
# endif |
| 523 |
_GL_FUNCDECL_RPL (posix_memalign, int, |
| 524 |
(void **memptr, size_t alignment, size_t size) |
| 525 |
_GL_ARG_NONNULL ((1))); |
| 526 |
_GL_CXXALIAS_RPL (posix_memalign, int, |
| 527 |
(void **memptr, size_t alignment, size_t size)); |
| 528 |
# else |
| 529 |
# if @HAVE_POSIX_MEMALIGN@ |
| 530 |
_GL_CXXALIAS_SYS (posix_memalign, int, |
| 531 |
(void **memptr, size_t alignment, size_t size)); |
| 532 |
# endif |
| 533 |
# endif |
| 534 |
# if @HAVE_POSIX_MEMALIGN@ |
| 535 |
_GL_CXXALIASWARN (posix_memalign); |
| 536 |
# endif |
| 537 |
#elif defined GNULIB_POSIXCHECK |
| 538 |
# undef posix_memalign |
| 539 |
# if HAVE_RAW_DECL_POSIX_MEMALIGN |
| 540 |
_GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - " |
| 541 |
"use gnulib module posix_memalign for portability"); |
| 542 |
# endif |
| 543 |
#endif |
| 544 |
|
| 545 |
#if @GNULIB_POSIX_OPENPT@ |
| 546 |
/* Return an FD open to the master side of a pseudo-terminal. Flags should |
| 547 |
include O_RDWR, and may also include O_NOCTTY. */ |
| 548 |
# if !@HAVE_POSIX_OPENPT@ |
| 549 |
_GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); |
| 550 |
# endif |
| 551 |
_GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); |
| 552 |
_GL_CXXALIASWARN (posix_openpt); |
| 553 |
#elif defined GNULIB_POSIXCHECK |
| 554 |
# undef posix_openpt |
| 555 |
# if HAVE_RAW_DECL_POSIX_OPENPT |
| 556 |
_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " |
| 557 |
"use gnulib module posix_openpt for portability"); |
| 558 |
# endif |
| 559 |
#endif |
| 560 |
|
| 561 |
#if @GNULIB_PTSNAME@ |
| 562 |
/* Return the pathname of the pseudo-terminal slave associated with |
| 563 |
the master FD is open on, or NULL on errors. */ |
| 564 |
# if @REPLACE_PTSNAME@ |
| 565 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 566 |
# undef ptsname |
| 567 |
# define ptsname rpl_ptsname |
| 568 |
# endif |
| 569 |
_GL_FUNCDECL_RPL (ptsname, char *, (int fd)); |
| 570 |
_GL_CXXALIAS_RPL (ptsname, char *, (int fd)); |
| 571 |
# else |
| 572 |
# if !@HAVE_PTSNAME@ |
| 573 |
_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); |
| 574 |
# endif |
| 575 |
_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); |
| 576 |
# endif |
| 577 |
_GL_CXXALIASWARN (ptsname); |
| 578 |
#elif defined GNULIB_POSIXCHECK |
| 579 |
# undef ptsname |
| 580 |
# if HAVE_RAW_DECL_PTSNAME |
| 581 |
_GL_WARN_ON_USE (ptsname, "ptsname is not portable - " |
| 582 |
"use gnulib module ptsname for portability"); |
| 583 |
# endif |
| 584 |
#endif |
| 585 |
|
| 586 |
#if @GNULIB_PTSNAME_R@ |
| 587 |
/* Set the pathname of the pseudo-terminal slave associated with |
| 588 |
the master FD is open on and return 0, or set errno and return |
| 589 |
non-zero on errors. */ |
| 590 |
# if @REPLACE_PTSNAME_R@ |
| 591 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 592 |
# undef ptsname_r |
| 593 |
# define ptsname_r rpl_ptsname_r |
| 594 |
# endif |
| 595 |
_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); |
| 596 |
_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len)); |
| 597 |
# else |
| 598 |
# if !@HAVE_PTSNAME_R@ |
| 599 |
_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); |
| 600 |
# endif |
| 601 |
_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); |
| 602 |
# endif |
| 603 |
# ifndef GNULIB_defined_ptsname_r |
| 604 |
# define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@) |
| 605 |
# endif |
| 606 |
_GL_CXXALIASWARN (ptsname_r); |
| 607 |
#elif defined GNULIB_POSIXCHECK |
| 608 |
# undef ptsname_r |
| 609 |
# if HAVE_RAW_DECL_PTSNAME_R |
| 610 |
_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - " |
| 611 |
"use gnulib module ptsname_r for portability"); |
| 612 |
# endif |
| 613 |
#endif |
| 614 |
|
| 615 |
#if @GNULIB_PUTENV@ |
| 616 |
# if @REPLACE_PUTENV@ |
| 617 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 618 |
# undef putenv |
| 619 |
# define putenv rpl_putenv |
| 620 |
# endif |
| 621 |
_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); |
| 622 |
_GL_CXXALIAS_RPL (putenv, int, (char *string)); |
| 623 |
# elif defined _WIN32 && !defined __CYGWIN__ |
| 624 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 625 |
# undef putenv |
| 626 |
# define putenv _putenv |
| 627 |
# endif |
| 628 |
_GL_CXXALIAS_MDA (putenv, int, (char *string)); |
| 629 |
# else |
| 630 |
_GL_CXXALIAS_SYS (putenv, int, (char *string)); |
| 631 |
# endif |
| 632 |
_GL_CXXALIASWARN (putenv); |
| 633 |
#elif defined _WIN32 && !defined __CYGWIN__ |
| 634 |
# undef putenv |
| 635 |
# define putenv _putenv |
| 636 |
#endif |
| 637 |
|
| 638 |
#if @GNULIB_QSORT_R@ |
| 639 |
/* Sort an array of NMEMB elements, starting at address BASE, each element |
| 640 |
occupying SIZE bytes, in ascending order according to the comparison |
| 641 |
function COMPARE. */ |
| 642 |
# if @REPLACE_QSORT_R@ |
| 643 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 644 |
# undef qsort_r |
| 645 |
# define qsort_r rpl_qsort_r |
| 646 |
# endif |
| 647 |
_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, |
| 648 |
int (*compare) (void const *, void const *, |
| 649 |
void *), |
| 650 |
void *arg) _GL_ARG_NONNULL ((1, 4))); |
| 651 |
_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size, |
| 652 |
int (*compare) (void const *, void const *, |
| 653 |
void *), |
| 654 |
void *arg)); |
| 655 |
# else |
| 656 |
# if !@HAVE_QSORT_R@ |
| 657 |
_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, |
| 658 |
int (*compare) (void const *, void const *, |
| 659 |
void *), |
| 660 |
void *arg) _GL_ARG_NONNULL ((1, 4))); |
| 661 |
# endif |
| 662 |
_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size, |
| 663 |
int (*compare) (void const *, void const *, |
| 664 |
void *), |
| 665 |
void *arg)); |
| 666 |
# endif |
| 667 |
_GL_CXXALIASWARN (qsort_r); |
| 668 |
#elif defined GNULIB_POSIXCHECK |
| 669 |
# undef qsort_r |
| 670 |
# if HAVE_RAW_DECL_QSORT_R |
| 671 |
_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - " |
| 672 |
"use gnulib module qsort_r for portability"); |
| 673 |
# endif |
| 674 |
#endif |
| 675 |
|
| 676 |
|
| 677 |
#if @GNULIB_RANDOM_R@ |
| 678 |
# if !@HAVE_RANDOM_R@ |
| 679 |
# ifndef RAND_MAX |
| 680 |
# define RAND_MAX 2147483647 |
| 681 |
# endif |
| 682 |
# endif |
| 683 |
#endif |
| 684 |
|
| 685 |
|
| 686 |
#if @GNULIB_RANDOM@ |
| 687 |
# if @REPLACE_RANDOM@ |
| 688 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 689 |
# undef random |
| 690 |
# define random rpl_random |
| 691 |
# endif |
| 692 |
_GL_FUNCDECL_RPL (random, long, (void)); |
| 693 |
_GL_CXXALIAS_RPL (random, long, (void)); |
| 694 |
# else |
| 695 |
# if !@HAVE_RANDOM@ |
| 696 |
_GL_FUNCDECL_SYS (random, long, (void)); |
| 697 |
# endif |
| 698 |
/* Need to cast, because on Haiku, the return type is |
| 699 |
int. */ |
| 700 |
_GL_CXXALIAS_SYS_CAST (random, long, (void)); |
| 701 |
# endif |
| 702 |
_GL_CXXALIASWARN (random); |
| 703 |
#elif defined GNULIB_POSIXCHECK |
| 704 |
# undef random |
| 705 |
# if HAVE_RAW_DECL_RANDOM |
| 706 |
_GL_WARN_ON_USE (random, "random is unportable - " |
| 707 |
"use gnulib module random for portability"); |
| 708 |
# endif |
| 709 |
#endif |
| 710 |
|
| 711 |
#if @GNULIB_RANDOM@ |
| 712 |
# if @REPLACE_RANDOM@ |
| 713 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 714 |
# undef srandom |
| 715 |
# define srandom rpl_srandom |
| 716 |
# endif |
| 717 |
_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed)); |
| 718 |
_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed)); |
| 719 |
# else |
| 720 |
# if !@HAVE_RANDOM@ |
| 721 |
_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); |
| 722 |
# endif |
| 723 |
/* Need to cast, because on FreeBSD, the first parameter is |
| 724 |
unsigned long seed. */ |
| 725 |
_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed)); |
| 726 |
# endif |
| 727 |
_GL_CXXALIASWARN (srandom); |
| 728 |
#elif defined GNULIB_POSIXCHECK |
| 729 |
# undef srandom |
| 730 |
# if HAVE_RAW_DECL_SRANDOM |
| 731 |
_GL_WARN_ON_USE (srandom, "srandom is unportable - " |
| 732 |
"use gnulib module random for portability"); |
| 733 |
# endif |
| 734 |
#endif |
| 735 |
|
| 736 |
#if @GNULIB_RANDOM@ |
| 737 |
# if @REPLACE_INITSTATE@ |
| 738 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 739 |
# undef initstate |
| 740 |
# define initstate rpl_initstate |
| 741 |
# endif |
| 742 |
_GL_FUNCDECL_RPL (initstate, char *, |
| 743 |
(unsigned int seed, char *buf, size_t buf_size) |
| 744 |
_GL_ARG_NONNULL ((2))); |
| 745 |
_GL_CXXALIAS_RPL (initstate, char *, |
| 746 |
(unsigned int seed, char *buf, size_t buf_size)); |
| 747 |
# else |
| 748 |
# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@ |
| 749 |
_GL_FUNCDECL_SYS (initstate, char *, |
| 750 |
(unsigned int seed, char *buf, size_t buf_size) |
| 751 |
_GL_ARG_NONNULL ((2))); |
| 752 |
# endif |
| 753 |
/* Need to cast, because on FreeBSD, the first parameter is |
| 754 |
unsigned long seed. */ |
| 755 |
_GL_CXXALIAS_SYS_CAST (initstate, char *, |
| 756 |
(unsigned int seed, char *buf, size_t buf_size)); |
| 757 |
# endif |
| 758 |
_GL_CXXALIASWARN (initstate); |
| 759 |
#elif defined GNULIB_POSIXCHECK |
| 760 |
# undef initstate |
| 761 |
# if HAVE_RAW_DECL_INITSTATE |
| 762 |
_GL_WARN_ON_USE (initstate, "initstate is unportable - " |
| 763 |
"use gnulib module random for portability"); |
| 764 |
# endif |
| 765 |
#endif |
| 766 |
|
| 767 |
#if @GNULIB_RANDOM@ |
| 768 |
# if @REPLACE_SETSTATE@ |
| 769 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 770 |
# undef setstate |
| 771 |
# define setstate rpl_setstate |
| 772 |
# endif |
| 773 |
_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); |
| 774 |
_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state)); |
| 775 |
# else |
| 776 |
# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@ |
| 777 |
_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); |
| 778 |
# endif |
| 779 |
/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter |
| 780 |
is const char *arg_state. */ |
| 781 |
_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state)); |
| 782 |
# endif |
| 783 |
_GL_CXXALIASWARN (setstate); |
| 784 |
#elif defined GNULIB_POSIXCHECK |
| 785 |
# undef setstate |
| 786 |
# if HAVE_RAW_DECL_SETSTATE |
| 787 |
_GL_WARN_ON_USE (setstate, "setstate is unportable - " |
| 788 |
"use gnulib module random for portability"); |
| 789 |
# endif |
| 790 |
#endif |
| 791 |
|
| 792 |
|
| 793 |
#if @GNULIB_RANDOM_R@ |
| 794 |
# if @REPLACE_RANDOM_R@ |
| 795 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 796 |
# undef random_r |
| 797 |
# define random_r rpl_random_r |
| 798 |
# endif |
| 799 |
_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result) |
| 800 |
_GL_ARG_NONNULL ((1, 2))); |
| 801 |
_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result)); |
| 802 |
# else |
| 803 |
# if !@HAVE_RANDOM_R@ |
| 804 |
_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) |
| 805 |
_GL_ARG_NONNULL ((1, 2))); |
| 806 |
# endif |
| 807 |
_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); |
| 808 |
# endif |
| 809 |
_GL_CXXALIASWARN (random_r); |
| 810 |
#elif defined GNULIB_POSIXCHECK |
| 811 |
# undef random_r |
| 812 |
# if HAVE_RAW_DECL_RANDOM_R |
| 813 |
_GL_WARN_ON_USE (random_r, "random_r is unportable - " |
| 814 |
"use gnulib module random_r for portability"); |
| 815 |
# endif |
| 816 |
#endif |
| 817 |
|
| 818 |
#if @GNULIB_RANDOM_R@ |
| 819 |
# if @REPLACE_RANDOM_R@ |
| 820 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 821 |
# undef srandom_r |
| 822 |
# define srandom_r rpl_srandom_r |
| 823 |
# endif |
| 824 |
_GL_FUNCDECL_RPL (srandom_r, int, |
| 825 |
(unsigned int seed, struct random_data *rand_state) |
| 826 |
_GL_ARG_NONNULL ((2))); |
| 827 |
_GL_CXXALIAS_RPL (srandom_r, int, |
| 828 |
(unsigned int seed, struct random_data *rand_state)); |
| 829 |
# else |
| 830 |
# if !@HAVE_RANDOM_R@ |
| 831 |
_GL_FUNCDECL_SYS (srandom_r, int, |
| 832 |
(unsigned int seed, struct random_data *rand_state) |
| 833 |
_GL_ARG_NONNULL ((2))); |
| 834 |
# endif |
| 835 |
_GL_CXXALIAS_SYS (srandom_r, int, |
| 836 |
(unsigned int seed, struct random_data *rand_state)); |
| 837 |
# endif |
| 838 |
_GL_CXXALIASWARN (srandom_r); |
| 839 |
#elif defined GNULIB_POSIXCHECK |
| 840 |
# undef srandom_r |
| 841 |
# if HAVE_RAW_DECL_SRANDOM_R |
| 842 |
_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " |
| 843 |
"use gnulib module random_r for portability"); |
| 844 |
# endif |
| 845 |
#endif |
| 846 |
|
| 847 |
#if @GNULIB_RANDOM_R@ |
| 848 |
# if @REPLACE_RANDOM_R@ |
| 849 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 850 |
# undef initstate_r |
| 851 |
# define initstate_r rpl_initstate_r |
| 852 |
# endif |
| 853 |
_GL_FUNCDECL_RPL (initstate_r, int, |
| 854 |
(unsigned int seed, char *buf, size_t buf_size, |
| 855 |
struct random_data *rand_state) |
| 856 |
_GL_ARG_NONNULL ((2, 4))); |
| 857 |
_GL_CXXALIAS_RPL (initstate_r, int, |
| 858 |
(unsigned int seed, char *buf, size_t buf_size, |
| 859 |
struct random_data *rand_state)); |
| 860 |
# else |
| 861 |
# if !@HAVE_RANDOM_R@ |
| 862 |
_GL_FUNCDECL_SYS (initstate_r, int, |
| 863 |
(unsigned int seed, char *buf, size_t buf_size, |
| 864 |
struct random_data *rand_state) |
| 865 |
_GL_ARG_NONNULL ((2, 4))); |
| 866 |
# endif |
| 867 |
/* Need to cast, because on Haiku, the third parameter is |
| 868 |
unsigned long buf_size. */ |
| 869 |
_GL_CXXALIAS_SYS_CAST (initstate_r, int, |
| 870 |
(unsigned int seed, char *buf, size_t buf_size, |
| 871 |
struct random_data *rand_state)); |
| 872 |
# endif |
| 873 |
_GL_CXXALIASWARN (initstate_r); |
| 874 |
#elif defined GNULIB_POSIXCHECK |
| 875 |
# undef initstate_r |
| 876 |
# if HAVE_RAW_DECL_INITSTATE_R |
| 877 |
_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " |
| 878 |
"use gnulib module random_r for portability"); |
| 879 |
# endif |
| 880 |
#endif |
| 881 |
|
| 882 |
#if @GNULIB_RANDOM_R@ |
| 883 |
# if @REPLACE_RANDOM_R@ |
| 884 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 885 |
# undef setstate_r |
| 886 |
# define setstate_r rpl_setstate_r |
| 887 |
# endif |
| 888 |
_GL_FUNCDECL_RPL (setstate_r, int, |
| 889 |
(char *arg_state, struct random_data *rand_state) |
| 890 |
_GL_ARG_NONNULL ((1, 2))); |
| 891 |
_GL_CXXALIAS_RPL (setstate_r, int, |
| 892 |
(char *arg_state, struct random_data *rand_state)); |
| 893 |
# else |
| 894 |
# if !@HAVE_RANDOM_R@ |
| 895 |
_GL_FUNCDECL_SYS (setstate_r, int, |
| 896 |
(char *arg_state, struct random_data *rand_state) |
| 897 |
_GL_ARG_NONNULL ((1, 2))); |
| 898 |
# endif |
| 899 |
/* Need to cast, because on Haiku, the first parameter is |
| 900 |
void *arg_state. */ |
| 901 |
_GL_CXXALIAS_SYS_CAST (setstate_r, int, |
| 902 |
(char *arg_state, struct random_data *rand_state)); |
| 903 |
# endif |
| 904 |
_GL_CXXALIASWARN (setstate_r); |
| 905 |
#elif defined GNULIB_POSIXCHECK |
| 906 |
# undef setstate_r |
| 907 |
# if HAVE_RAW_DECL_SETSTATE_R |
| 908 |
_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " |
| 909 |
"use gnulib module random_r for portability"); |
| 910 |
# endif |
| 911 |
#endif |
| 912 |
|
| 913 |
|
| 914 |
#if @GNULIB_REALLOC_POSIX@ |
| 915 |
# if @REPLACE_REALLOC@ |
| 916 |
# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ |
| 917 |
|| _GL_USE_STDLIB_ALLOC) |
| 918 |
# undef realloc |
| 919 |
# define realloc rpl_realloc |
| 920 |
# endif |
| 921 |
_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); |
| 922 |
_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); |
| 923 |
# else |
| 924 |
_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); |
| 925 |
# endif |
| 926 |
# if __GLIBC__ >= 2 |
| 927 |
_GL_CXXALIASWARN (realloc); |
| 928 |
# endif |
| 929 |
#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC |
| 930 |
# undef realloc |
| 931 |
/* Assume realloc is always declared. */ |
| 932 |
_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " |
| 933 |
"use gnulib module realloc-posix for portability"); |
| 934 |
#endif |
| 935 |
|
| 936 |
|
| 937 |
#if @GNULIB_REALLOCARRAY@ |
| 938 |
# if ! @HAVE_REALLOCARRAY@ |
| 939 |
_GL_FUNCDECL_SYS (reallocarray, void *, |
| 940 |
(void *ptr, size_t nmemb, size_t size)); |
| 941 |
# endif |
| 942 |
_GL_CXXALIAS_SYS (reallocarray, void *, |
| 943 |
(void *ptr, size_t nmemb, size_t size)); |
| 944 |
_GL_CXXALIASWARN (reallocarray); |
| 945 |
#elif defined GNULIB_POSIXCHECK |
| 946 |
# undef reallocarray |
| 947 |
# if HAVE_RAW_DECL_REALLOCARRAY |
| 948 |
_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - " |
| 949 |
"use gnulib module reallocarray for portability"); |
| 950 |
# endif |
| 951 |
#endif |
| 952 |
|
| 953 |
#if @GNULIB_REALPATH@ |
| 954 |
# if @REPLACE_REALPATH@ |
| 955 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 956 |
# define realpath rpl_realpath |
| 957 |
# endif |
| 958 |
_GL_FUNCDECL_RPL (realpath, char *, |
| 959 |
(const char *restrict name, char *restrict resolved) |
| 960 |
_GL_ARG_NONNULL ((1))); |
| 961 |
_GL_CXXALIAS_RPL (realpath, char *, |
| 962 |
(const char *restrict name, char *restrict resolved)); |
| 963 |
# else |
| 964 |
# if !@HAVE_REALPATH@ |
| 965 |
_GL_FUNCDECL_SYS (realpath, char *, |
| 966 |
(const char *restrict name, char *restrict resolved) |
| 967 |
_GL_ARG_NONNULL ((1))); |
| 968 |
# endif |
| 969 |
_GL_CXXALIAS_SYS (realpath, char *, |
| 970 |
(const char *restrict name, char *restrict resolved)); |
| 971 |
# endif |
| 972 |
_GL_CXXALIASWARN (realpath); |
| 973 |
#elif defined GNULIB_POSIXCHECK |
| 974 |
# undef realpath |
| 975 |
# if HAVE_RAW_DECL_REALPATH |
| 976 |
_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " |
| 977 |
"canonicalize or canonicalize-lgpl for portability"); |
| 978 |
# endif |
| 979 |
#endif |
| 980 |
|
| 981 |
#if @GNULIB_RPMATCH@ |
| 982 |
/* Test a user response to a question. |
| 983 |
Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ |
| 984 |
# if !@HAVE_RPMATCH@ |
| 985 |
_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); |
| 986 |
# endif |
| 987 |
_GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); |
| 988 |
_GL_CXXALIASWARN (rpmatch); |
| 989 |
#elif defined GNULIB_POSIXCHECK |
| 990 |
# undef rpmatch |
| 991 |
# if HAVE_RAW_DECL_RPMATCH |
| 992 |
_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " |
| 993 |
"use gnulib module rpmatch for portability"); |
| 994 |
# endif |
| 995 |
#endif |
| 996 |
|
| 997 |
#if @GNULIB_SECURE_GETENV@ |
| 998 |
/* Look up NAME in the environment, returning 0 in insecure situations. */ |
| 999 |
# if !@HAVE_SECURE_GETENV@ |
| 1000 |
_GL_FUNCDECL_SYS (secure_getenv, char *, |
| 1001 |
(char const *name) _GL_ARG_NONNULL ((1))); |
| 1002 |
# endif |
| 1003 |
_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name)); |
| 1004 |
_GL_CXXALIASWARN (secure_getenv); |
| 1005 |
#elif defined GNULIB_POSIXCHECK |
| 1006 |
# undef secure_getenv |
| 1007 |
# if HAVE_RAW_DECL_SECURE_GETENV |
| 1008 |
_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - " |
| 1009 |
"use gnulib module secure_getenv for portability"); |
| 1010 |
# endif |
| 1011 |
#endif |
| 1012 |
|
| 1013 |
#if @GNULIB_SETENV@ |
| 1014 |
/* Set NAME to VALUE in the environment. |
| 1015 |
If REPLACE is nonzero, overwrite an existing value. */ |
| 1016 |
# if @REPLACE_SETENV@ |
| 1017 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1018 |
# undef setenv |
| 1019 |
# define setenv rpl_setenv |
| 1020 |
# endif |
| 1021 |
_GL_FUNCDECL_RPL (setenv, int, |
| 1022 |
(const char *name, const char *value, int replace) |
| 1023 |
_GL_ARG_NONNULL ((1))); |
| 1024 |
_GL_CXXALIAS_RPL (setenv, int, |
| 1025 |
(const char *name, const char *value, int replace)); |
| 1026 |
# else |
| 1027 |
# if !@HAVE_DECL_SETENV@ |
| 1028 |
_GL_FUNCDECL_SYS (setenv, int, |
| 1029 |
(const char *name, const char *value, int replace) |
| 1030 |
_GL_ARG_NONNULL ((1))); |
| 1031 |
# endif |
| 1032 |
_GL_CXXALIAS_SYS (setenv, int, |
| 1033 |
(const char *name, const char *value, int replace)); |
| 1034 |
# endif |
| 1035 |
# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@) |
| 1036 |
_GL_CXXALIASWARN (setenv); |
| 1037 |
# endif |
| 1038 |
#elif defined GNULIB_POSIXCHECK |
| 1039 |
# undef setenv |
| 1040 |
# if HAVE_RAW_DECL_SETENV |
| 1041 |
_GL_WARN_ON_USE (setenv, "setenv is unportable - " |
| 1042 |
"use gnulib module setenv for portability"); |
| 1043 |
# endif |
| 1044 |
#endif |
| 1045 |
|
| 1046 |
#if @GNULIB_STRTOD@ |
| 1047 |
/* Parse a double from STRING, updating ENDP if appropriate. */ |
| 1048 |
# if @REPLACE_STRTOD@ |
| 1049 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1050 |
# define strtod rpl_strtod |
| 1051 |
# endif |
| 1052 |
# define GNULIB_defined_strtod_function 1 |
| 1053 |
_GL_FUNCDECL_RPL (strtod, double, |
| 1054 |
(const char *restrict str, char **restrict endp) |
| 1055 |
_GL_ARG_NONNULL ((1))); |
| 1056 |
_GL_CXXALIAS_RPL (strtod, double, |
| 1057 |
(const char *restrict str, char **restrict endp)); |
| 1058 |
# else |
| 1059 |
# if !@HAVE_STRTOD@ |
| 1060 |
_GL_FUNCDECL_SYS (strtod, double, |
| 1061 |
(const char *restrict str, char **restrict endp) |
| 1062 |
_GL_ARG_NONNULL ((1))); |
| 1063 |
# endif |
| 1064 |
_GL_CXXALIAS_SYS (strtod, double, |
| 1065 |
(const char *restrict str, char **restrict endp)); |
| 1066 |
# endif |
| 1067 |
# if __GLIBC__ >= 2 |
| 1068 |
_GL_CXXALIASWARN (strtod); |
| 1069 |
# endif |
| 1070 |
#elif defined GNULIB_POSIXCHECK |
| 1071 |
# undef strtod |
| 1072 |
# if HAVE_RAW_DECL_STRTOD |
| 1073 |
_GL_WARN_ON_USE (strtod, "strtod is unportable - " |
| 1074 |
"use gnulib module strtod for portability"); |
| 1075 |
# endif |
| 1076 |
#endif |
| 1077 |
|
| 1078 |
#if @GNULIB_STRTOLD@ |
| 1079 |
/* Parse a 'long double' from STRING, updating ENDP if appropriate. */ |
| 1080 |
# if @REPLACE_STRTOLD@ |
| 1081 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1082 |
# define strtold rpl_strtold |
| 1083 |
# endif |
| 1084 |
# define GNULIB_defined_strtold_function 1 |
| 1085 |
_GL_FUNCDECL_RPL (strtold, long double, |
| 1086 |
(const char *restrict str, char **restrict endp) |
| 1087 |
_GL_ARG_NONNULL ((1))); |
| 1088 |
_GL_CXXALIAS_RPL (strtold, long double, |
| 1089 |
(const char *restrict str, char **restrict endp)); |
| 1090 |
# else |
| 1091 |
# if !@HAVE_STRTOLD@ |
| 1092 |
_GL_FUNCDECL_SYS (strtold, long double, |
| 1093 |
(const char *restrict str, char **restrict endp) |
| 1094 |
_GL_ARG_NONNULL ((1))); |
| 1095 |
# endif |
| 1096 |
_GL_CXXALIAS_SYS (strtold, long double, |
| 1097 |
(const char *restrict str, char **restrict endp)); |
| 1098 |
# endif |
| 1099 |
_GL_CXXALIASWARN (strtold); |
| 1100 |
#elif defined GNULIB_POSIXCHECK |
| 1101 |
# undef strtold |
| 1102 |
# if HAVE_RAW_DECL_STRTOLD |
| 1103 |
_GL_WARN_ON_USE (strtold, "strtold is unportable - " |
| 1104 |
"use gnulib module strtold for portability"); |
| 1105 |
# endif |
| 1106 |
#endif |
| 1107 |
|
| 1108 |
#if @GNULIB_STRTOLL@ |
| 1109 |
/* Parse a signed integer whose textual representation starts at STRING. |
| 1110 |
The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, |
| 1111 |
it may be decimal or octal (with prefix "0") or hexadecimal (with prefix |
| 1112 |
"0x"). |
| 1113 |
If ENDPTR is not NULL, the address of the first byte after the integer is |
| 1114 |
stored in *ENDPTR. |
| 1115 |
Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set |
| 1116 |
to ERANGE. */ |
| 1117 |
# if !@HAVE_STRTOLL@ |
| 1118 |
_GL_FUNCDECL_SYS (strtoll, long long, |
| 1119 |
(const char *restrict string, char **restrict endptr, |
| 1120 |
int base) |
| 1121 |
_GL_ARG_NONNULL ((1))); |
| 1122 |
# endif |
| 1123 |
_GL_CXXALIAS_SYS (strtoll, long long, |
| 1124 |
(const char *restrict string, char **restrict endptr, |
| 1125 |
int base)); |
| 1126 |
_GL_CXXALIASWARN (strtoll); |
| 1127 |
#elif defined GNULIB_POSIXCHECK |
| 1128 |
# undef strtoll |
| 1129 |
# if HAVE_RAW_DECL_STRTOLL |
| 1130 |
_GL_WARN_ON_USE (strtoll, "strtoll is unportable - " |
| 1131 |
"use gnulib module strtoll for portability"); |
| 1132 |
# endif |
| 1133 |
#endif |
| 1134 |
|
| 1135 |
#if @GNULIB_STRTOULL@ |
| 1136 |
/* Parse an unsigned integer whose textual representation starts at STRING. |
| 1137 |
The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, |
| 1138 |
it may be decimal or octal (with prefix "0") or hexadecimal (with prefix |
| 1139 |
"0x"). |
| 1140 |
If ENDPTR is not NULL, the address of the first byte after the integer is |
| 1141 |
stored in *ENDPTR. |
| 1142 |
Upon overflow, the return value is ULLONG_MAX, and errno is set to |
| 1143 |
ERANGE. */ |
| 1144 |
# if !@HAVE_STRTOULL@ |
| 1145 |
_GL_FUNCDECL_SYS (strtoull, unsigned long long, |
| 1146 |
(const char *restrict string, char **restrict endptr, |
| 1147 |
int base) |
| 1148 |
_GL_ARG_NONNULL ((1))); |
| 1149 |
# endif |
| 1150 |
_GL_CXXALIAS_SYS (strtoull, unsigned long long, |
| 1151 |
(const char *restrict string, char **restrict endptr, |
| 1152 |
int base)); |
| 1153 |
_GL_CXXALIASWARN (strtoull); |
| 1154 |
#elif defined GNULIB_POSIXCHECK |
| 1155 |
# undef strtoull |
| 1156 |
# if HAVE_RAW_DECL_STRTOULL |
| 1157 |
_GL_WARN_ON_USE (strtoull, "strtoull is unportable - " |
| 1158 |
"use gnulib module strtoull for portability"); |
| 1159 |
# endif |
| 1160 |
#endif |
| 1161 |
|
| 1162 |
#if @GNULIB_UNLOCKPT@ |
| 1163 |
/* Unlock the slave side of the pseudo-terminal whose master side is specified |
| 1164 |
by FD, so that it can be opened. */ |
| 1165 |
# if !@HAVE_UNLOCKPT@ |
| 1166 |
_GL_FUNCDECL_SYS (unlockpt, int, (int fd)); |
| 1167 |
# endif |
| 1168 |
_GL_CXXALIAS_SYS (unlockpt, int, (int fd)); |
| 1169 |
_GL_CXXALIASWARN (unlockpt); |
| 1170 |
#elif defined GNULIB_POSIXCHECK |
| 1171 |
# undef unlockpt |
| 1172 |
# if HAVE_RAW_DECL_UNLOCKPT |
| 1173 |
_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " |
| 1174 |
"use gnulib module unlockpt for portability"); |
| 1175 |
# endif |
| 1176 |
#endif |
| 1177 |
|
| 1178 |
#if @GNULIB_UNSETENV@ |
| 1179 |
/* Remove the variable NAME from the environment. */ |
| 1180 |
# if @REPLACE_UNSETENV@ |
| 1181 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1182 |
# undef unsetenv |
| 1183 |
# define unsetenv rpl_unsetenv |
| 1184 |
# endif |
| 1185 |
_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); |
| 1186 |
_GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); |
| 1187 |
# else |
| 1188 |
# if !@HAVE_DECL_UNSETENV@ |
| 1189 |
_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); |
| 1190 |
# endif |
| 1191 |
_GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); |
| 1192 |
# endif |
| 1193 |
# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@) |
| 1194 |
_GL_CXXALIASWARN (unsetenv); |
| 1195 |
# endif |
| 1196 |
#elif defined GNULIB_POSIXCHECK |
| 1197 |
# undef unsetenv |
| 1198 |
# if HAVE_RAW_DECL_UNSETENV |
| 1199 |
_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " |
| 1200 |
"use gnulib module unsetenv for portability"); |
| 1201 |
# endif |
| 1202 |
#endif |
| 1203 |
|
| 1204 |
/* Convert a wide character to a multibyte character. */ |
| 1205 |
#if @GNULIB_WCTOMB@ |
| 1206 |
# if @REPLACE_WCTOMB@ |
| 1207 |
# if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 1208 |
# undef wctomb |
| 1209 |
# define wctomb rpl_wctomb |
| 1210 |
# endif |
| 1211 |
_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc)); |
| 1212 |
_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); |
| 1213 |
# else |
| 1214 |
_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); |
| 1215 |
# endif |
| 1216 |
# if __GLIBC__ >= 2 |
| 1217 |
_GL_CXXALIASWARN (wctomb); |
| 1218 |
# endif |
| 1219 |
#endif |
| 1220 |
|
| 1221 |
|
| 1222 |
#endif /* _@GUARD_PREFIX@_STDLIB_H */ |
| 1223 |
#endif /* _@GUARD_PREFIX@_STDLIB_H */ |
| 1224 |
#endif |