modernc.org/cc@v1.0.1/v2/headers/linux_386/usr/include/stdlib.h (about) 1 /* Copyright (C) 1991-2018 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <http://www.gnu.org/licenses/>. */ 17 18 /* 19 * ISO C99 Standard: 7.20 General utilities <stdlib.h> 20 */ 21 22 #ifndef _STDLIB_H 23 24 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION 25 #include <bits/libc-header-start.h> 26 27 /* Get size_t, wchar_t and NULL from <stddef.h>. */ 28 #define __need_size_t 29 #define __need_wchar_t 30 #define __need_NULL 31 #include <stddef.h> 32 33 __BEGIN_DECLS 34 #define _STDLIB_H 1 35 #if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H 36 /* XPG requires a few symbols from <sys/wait.h> being defined. */ 37 # include <bits/waitflags.h> 38 # include <bits/waitstatus.h> 39 /* Define the macros <sys/wait.h> also would define this way. */ 40 # define WEXITSTATUS(status) __WEXITSTATUS (status) 41 # define WTERMSIG(status) __WTERMSIG (status) 42 # define WSTOPSIG(status) __WSTOPSIG (status) 43 # define WIFEXITED(status) __WIFEXITED (status) 44 # define WIFSIGNALED(status) __WIFSIGNALED (status) 45 # define WIFSTOPPED(status) __WIFSTOPPED (status) 46 # ifdef __WIFCONTINUED 47 # define WIFCONTINUED(status) __WIFCONTINUED (status) 48 # endif 49 #endif /* X/Open or XPG7 and <sys/wait.h> not included. */ 50 /* _FloatN API tests for enablement. */ 51 #include <bits/floatn.h> 52 /* Returned by `div'. */ 53 typedef struct { 54 int quot; /* Quotient. */ 55 int rem; /* Remainder. */ 56 } div_t; 57 58 /* Returned by `ldiv'. */ 59 #ifndef __ldiv_t_defined 60 typedef struct { 61 long int quot; /* Quotient. */ 62 long int rem; /* Remainder. */ 63 } ldiv_t; 64 # define __ldiv_t_defined 1 65 #endif 66 67 #if defined __USE_ISOC99 && !defined __lldiv_t_defined 68 /* Returned by `lldiv'. */ 69 __extension__ typedef struct { 70 long long int quot; /* Quotient. */ 71 long long int rem; /* Remainder. */ 72 } lldiv_t; 73 # define __lldiv_t_defined 1 74 #endif 75 76 /* The largest number rand will return (same as INT_MAX). */ 77 #define RAND_MAX 2147483647 78 79 /* We define these the same for all machines. 80 Changes from this to the outside world should be done in `_exit'. */ 81 #define EXIT_FAILURE 1 /* Failing exit status. */ 82 #define EXIT_SUCCESS 0 /* Successful exit status. */ 83 84 /* Maximum length of a multibyte character in the current locale. */ 85 #define MB_CUR_MAX (__ctype_get_mb_cur_max ()) 86 extern size_t __ctype_get_mb_cur_max(void) 87 __THROW __wur; 88 89 /* Convert a string to a floating-point number. */ 90 extern double atof(const char *__nptr) 91 __THROW __attribute_pure__ __nonnull((1)) __wur; 92 /* Convert a string to an integer. */ 93 extern int atoi(const char *__nptr) 94 __THROW __attribute_pure__ __nonnull((1)) __wur; 95 /* Convert a string to a long integer. */ 96 extern long int atol(const char *__nptr) 97 __THROW __attribute_pure__ __nonnull((1)) __wur; 98 99 #ifdef __USE_ISOC99 100 /* Convert a string to a long long integer. */ 101 __extension__ extern long long int atoll(const char *__nptr) 102 __THROW __attribute_pure__ __nonnull((1)) __wur; 103 #endif 104 105 /* Convert a string to a floating-point number. */ 106 extern double strtod(const char *__restrict __nptr, char **__restrict __endptr) 107 __THROW __nonnull((1)); 108 109 #ifdef __USE_ISOC99 110 /* Likewise for `float' and `long double' sizes of floating-point numbers. */ 111 extern float strtof(const char *__restrict __nptr, char **__restrict __endptr) 112 __THROW __nonnull((1)); 113 114 extern long double strtold(const char *__restrict __nptr, char **__restrict __endptr) 115 __THROW __nonnull((1)); 116 #endif 117 118 /* Likewise for '_FloatN' and '_FloatNx'. */ 119 120 #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) 121 extern _Float16 strtof16(const char *__restrict __nptr, char **__restrict __endptr) 122 __THROW __nonnull((1)); 123 #endif 124 125 #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) 126 extern _Float32 strtof32(const char *__restrict __nptr, char **__restrict __endptr) 127 __THROW __nonnull((1)); 128 #endif 129 130 #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) 131 extern _Float64 strtof64(const char *__restrict __nptr, char **__restrict __endptr) 132 __THROW __nonnull((1)); 133 #endif 134 135 #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) 136 extern _Float128 strtof128(const char *__restrict __nptr, char **__restrict __endptr) 137 __THROW __nonnull((1)); 138 #endif 139 140 #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) 141 extern _Float32x strtof32x(const char *__restrict __nptr, char **__restrict __endptr) 142 __THROW __nonnull((1)); 143 #endif 144 145 #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) 146 extern _Float64x strtof64x(const char *__restrict __nptr, char **__restrict __endptr) 147 __THROW __nonnull((1)); 148 #endif 149 150 #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) 151 extern _Float128x strtof128x(const char *__restrict __nptr, char **__restrict __endptr) 152 __THROW __nonnull((1)); 153 #endif 154 155 /* Convert a string to a long integer. */ 156 extern long int strtol(const char *__restrict __nptr, char **__restrict __endptr, int __base) 157 __THROW __nonnull((1)); 158 /* Convert a string to an unsigned long integer. */ 159 extern unsigned long int strtoul(const char *__restrict __nptr, char **__restrict __endptr, int __base) 160 __THROW __nonnull((1)); 161 162 #ifdef __USE_MISC 163 /* Convert a string to a quadword integer. */ 164 __extension__ extern long long int strtoq(const char *__restrict __nptr, char **__restrict __endptr, int __base) 165 __THROW __nonnull((1)); 166 /* Convert a string to an unsigned quadword integer. */ 167 __extension__ extern unsigned long long int strtouq(const char *__restrict __nptr, char **__restrict __endptr, int __base) 168 __THROW __nonnull((1)); 169 #endif /* Use misc. */ 170 171 #ifdef __USE_ISOC99 172 /* Convert a string to a quadword integer. */ 173 __extension__ extern long long int strtoll(const char *__restrict __nptr, char **__restrict __endptr, int __base) 174 __THROW __nonnull((1)); 175 /* Convert a string to an unsigned quadword integer. */ 176 __extension__ extern unsigned long long int strtoull(const char *__restrict __nptr, char **__restrict __endptr, int __base) 177 __THROW __nonnull((1)); 178 #endif /* ISO C99 or use MISC. */ 179 180 /* Convert a floating-point number to a string. */ 181 #if __GLIBC_USE (IEC_60559_BFP_EXT) 182 extern int strfromd(char *__dest, size_t __size, const char *__format, double __f) 183 __THROW __nonnull((3)); 184 185 extern int strfromf(char *__dest, size_t __size, const char *__format, float __f) 186 __THROW __nonnull((3)); 187 188 extern int strfroml(char *__dest, size_t __size, const char *__format, long double __f) 189 __THROW __nonnull((3)); 190 #endif 191 192 #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) 193 extern int strfromf16(char *__dest, size_t __size, const char *__format, _Float16 __f) 194 __THROW __nonnull((3)); 195 #endif 196 197 #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) 198 extern int strfromf32(char *__dest, size_t __size, const char *__format, _Float32 __f) 199 __THROW __nonnull((3)); 200 #endif 201 202 #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) 203 extern int strfromf64(char *__dest, size_t __size, const char *__format, _Float64 __f) 204 __THROW __nonnull((3)); 205 #endif 206 207 #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) 208 extern int strfromf128(char *__dest, size_t __size, const char *__format, _Float128 __f) 209 __THROW __nonnull((3)); 210 #endif 211 212 #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) 213 extern int strfromf32x(char *__dest, size_t __size, const char *__format, _Float32x __f) 214 __THROW __nonnull((3)); 215 #endif 216 217 #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) 218 extern int strfromf64x(char *__dest, size_t __size, const char *__format, _Float64x __f) 219 __THROW __nonnull((3)); 220 #endif 221 222 #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) 223 extern int strfromf128x(char *__dest, size_t __size, const char *__format, _Float128x __f) 224 __THROW __nonnull((3)); 225 #endif 226 227 #ifdef __USE_GNU 228 /* Parallel versions of the functions above which take the locale to 229 use as an additional parameter. These are GNU extensions inspired 230 by the POSIX.1-2008 extended locale API. */ 231 # include <bits/types/locale_t.h> 232 233 extern long int strtol_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) 234 __THROW __nonnull((1, 4)); 235 236 extern unsigned long int strtoul_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) 237 __THROW __nonnull((1, 4)); 238 239 __extension__ extern long long int strtoll_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) 240 __THROW __nonnull((1, 4)); 241 242 __extension__ extern unsigned long long int strtoull_l(const char *__restrict __nptr, char **__restrict __endptr, int __base, locale_t __loc) 243 __THROW __nonnull((1, 4)); 244 245 extern double strtod_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 246 __THROW __nonnull((1, 3)); 247 248 extern float strtof_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 249 __THROW __nonnull((1, 3)); 250 251 extern long double strtold_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 252 __THROW __nonnull((1, 3)); 253 254 # if __HAVE_FLOAT16 255 extern _Float16 strtof16_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 256 __THROW __nonnull((1, 3)); 257 # endif 258 259 # if __HAVE_FLOAT32 260 extern _Float32 strtof32_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 261 __THROW __nonnull((1, 3)); 262 # endif 263 264 # if __HAVE_FLOAT64 265 extern _Float64 strtof64_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 266 __THROW __nonnull((1, 3)); 267 # endif 268 269 # if __HAVE_FLOAT128 270 extern _Float128 strtof128_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 271 __THROW __nonnull((1, 3)); 272 # endif 273 274 # if __HAVE_FLOAT32X 275 extern _Float32x strtof32x_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 276 __THROW __nonnull((1, 3)); 277 # endif 278 279 # if __HAVE_FLOAT64X 280 extern _Float64x strtof64x_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 281 __THROW __nonnull((1, 3)); 282 # endif 283 284 # if __HAVE_FLOAT128X 285 extern _Float128x strtof128x_l(const char *__restrict __nptr, char **__restrict __endptr, locale_t __loc) 286 __THROW __nonnull((1, 3)); 287 # endif 288 #endif /* GNU */ 289 290 #ifdef __USE_EXTERN_INLINES 291 __extern_inline int __NTH(atoi(const char *__nptr)) 292 { 293 return (int)strtol(__nptr, (char **)NULL, 10); 294 } 295 296 __extern_inline long int __NTH(atol(const char *__nptr)) 297 { 298 return strtol(__nptr, (char **)NULL, 10); 299 } 300 301 # ifdef __USE_ISOC99 302 __extension__ __extern_inline long long int __NTH(atoll(const char *__nptr)) 303 { 304 return strtoll(__nptr, (char **)NULL, 10); 305 } 306 # endif 307 #endif /* Optimizing and Inlining. */ 308 309 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED 310 /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant 311 digit first. Returns a pointer to static storage overwritten by the 312 next call. */ 313 extern char *l64a(long int __n) 314 __THROW __wur; 315 316 /* Read a number from a string S in base 64 as above. */ 317 extern long int a64l(const char *__s) 318 __THROW __attribute_pure__ __nonnull((1)) __wur; 319 320 #endif /* Use misc || extended X/Open. */ 321 322 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED 323 # include <sys/types.h> /* we need int32_t... */ 324 325 /* These are the functions that actually do things. The `random', `srandom', 326 `initstate' and `setstate' functions are those from BSD Unices. 327 The `rand' and `srand' functions are required by the ANSI standard. 328 We provide both interfaces to the same random number generator. */ 329 /* Return a random long integer between 0 and RAND_MAX inclusive. */ 330 extern long int random(void) __THROW; 331 332 /* Seed the random number generator with the given number. */ 333 extern void srandom(unsigned int __seed) __THROW; 334 335 /* Initialize the random number generator to use state buffer STATEBUF, 336 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16, 337 32, 64, 128 and 256, the bigger the better; values less than 8 will 338 cause an error and values greater than 256 will be rounded down. */ 339 extern char *initstate(unsigned int __seed, char *__statebuf, size_t __statelen) 340 __THROW __nonnull((2)); 341 342 /* Switch the random number generator to state buffer STATEBUF, 343 which should have been previously initialized by `initstate'. */ 344 extern char *setstate(char *__statebuf) 345 __THROW __nonnull((1)); 346 347 # ifdef __USE_MISC 348 /* Reentrant versions of the `random' family of functions. 349 These functions all use the following data structure to contain 350 state, rather than global state variables. */ 351 352 struct random_data { 353 int32_t *fptr; /* Front pointer. */ 354 int32_t *rptr; /* Rear pointer. */ 355 int32_t *state; /* Array of state values. */ 356 int rand_type; /* Type of random number generator. */ 357 int rand_deg; /* Degree of random number generator. */ 358 int rand_sep; /* Distance between front and rear. */ 359 int32_t *end_ptr; /* Pointer behind state table. */ 360 }; 361 362 extern int random_r(struct random_data *__restrict __buf, int32_t * __restrict __result) 363 __THROW __nonnull((1, 2)); 364 365 extern int srandom_r(unsigned int __seed, struct random_data *__buf) 366 __THROW __nonnull((2)); 367 368 extern int initstate_r(unsigned int __seed, char *__restrict __statebuf, size_t __statelen, struct random_data *__restrict __buf) 369 __THROW __nonnull((2, 4)); 370 371 extern int setstate_r(char *__restrict __statebuf, struct random_data *__restrict __buf) 372 __THROW __nonnull((1, 2)); 373 # endif /* Use misc. */ 374 #endif /* Use extended X/Open || misc. */ 375 376 /* Return a random integer between 0 and RAND_MAX inclusive. */ 377 extern int rand(void) __THROW; 378 /* Seed the random number generator with the given number. */ 379 extern void srand(unsigned int __seed) __THROW; 380 381 #ifdef __USE_POSIX199506 382 /* Reentrant interface according to POSIX.1. */ 383 extern int rand_r(unsigned int *__seed) __THROW; 384 #endif 385 386 #if defined __USE_MISC || defined __USE_XOPEN 387 /* System V style 48-bit random number generator functions. */ 388 389 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */ 390 extern double drand48(void) __THROW; 391 extern double erand48(unsigned short int __xsubi[3]) 392 __THROW __nonnull((1)); 393 394 /* Return non-negative, long integer in [0,2^31). */ 395 extern long int lrand48(void) __THROW; 396 extern long int nrand48(unsigned short int __xsubi[3]) 397 __THROW __nonnull((1)); 398 399 /* Return signed, long integers in [-2^31,2^31). */ 400 extern long int mrand48(void) __THROW; 401 extern long int jrand48(unsigned short int __xsubi[3]) 402 __THROW __nonnull((1)); 403 404 /* Seed random number generator. */ 405 extern void srand48(long int __seedval) __THROW; 406 extern unsigned short int *seed48(unsigned short int __seed16v[3]) 407 __THROW __nonnull((1)); 408 extern void lcong48(unsigned short int __param[7]) 409 __THROW __nonnull((1)); 410 411 # ifdef __USE_MISC 412 /* Data structure for communication with thread safe versions. This 413 type is to be regarded as opaque. It's only exported because users 414 have to allocate objects of this type. */ 415 struct drand48_data { 416 unsigned short int __x[3]; /* Current state. */ 417 unsigned short int __old_x[3]; /* Old state. */ 418 unsigned short int __c; /* Additive const. in congruential formula. */ 419 unsigned short int __init; /* Flag for initializing. */ 420 __extension__ unsigned long long int __a; /* Factor in congruential 421 formula. */ 422 }; 423 424 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */ 425 extern int drand48_r(struct drand48_data *__restrict __buffer, double *__restrict __result) 426 __THROW __nonnull((1, 2)); 427 extern int erand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, double *__restrict __result) 428 __THROW __nonnull((1, 2)); 429 430 /* Return non-negative, long integer in [0,2^31). */ 431 extern int lrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result) 432 __THROW __nonnull((1, 2)); 433 extern int nrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result) 434 __THROW __nonnull((1, 2)); 435 436 /* Return signed, long integers in [-2^31,2^31). */ 437 extern int mrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result) 438 __THROW __nonnull((1, 2)); 439 extern int jrand48_r(unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result) 440 __THROW __nonnull((1, 2)); 441 442 /* Seed random number generator. */ 443 extern int srand48_r(long int __seedval, struct drand48_data *__buffer) 444 __THROW __nonnull((2)); 445 446 extern int seed48_r(unsigned short int __seed16v[3], struct drand48_data *__buffer) 447 __THROW __nonnull((1, 2)); 448 449 extern int lcong48_r(unsigned short int __param[7], struct drand48_data *__buffer) 450 __THROW __nonnull((1, 2)); 451 # endif /* Use misc. */ 452 #endif /* Use misc or X/Open. */ 453 454 /* Allocate SIZE bytes of memory. */ 455 extern void *malloc(size_t __size) 456 __THROW __attribute_malloc__ __wur; 457 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ 458 extern void *calloc(size_t __nmemb, size_t __size) 459 __THROW __attribute_malloc__ __wur; 460 461 /* Re-allocate the previously allocated block 462 in PTR, making the new block SIZE bytes long. */ 463 /* __attribute_malloc__ is not used, because if realloc returns 464 the same pointer that was passed to it, aliasing needs to be allowed 465 between objects pointed by the old and new pointers. */ 466 extern void *realloc(void *__ptr, size_t __size) 467 __THROW __attribute_warn_unused_result__; 468 469 #ifdef __USE_GNU 470 /* Re-allocate the previously allocated block in PTR, making the new 471 block large enough for NMEMB elements of SIZE bytes each. */ 472 /* __attribute_malloc__ is not used, because if reallocarray returns 473 the same pointer that was passed to it, aliasing needs to be allowed 474 between objects pointed by the old and new pointers. */ 475 extern void *reallocarray(void *__ptr, size_t __nmemb, size_t __size) 476 __THROW __attribute_warn_unused_result__; 477 #endif 478 479 /* Free a block allocated by `malloc', `realloc' or `calloc'. */ 480 extern void free(void *__ptr) __THROW; 481 482 #ifdef __USE_MISC 483 # include <alloca.h> 484 #endif /* Use misc. */ 485 486 #if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ 487 || defined __USE_MISC 488 /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */ 489 extern void *valloc(size_t __size) 490 __THROW __attribute_malloc__ __wur; 491 #endif 492 493 #ifdef __USE_XOPEN2K 494 /* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */ 495 extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size) 496 __THROW __nonnull((1)) __wur; 497 #endif 498 499 #ifdef __USE_ISOC11 500 /* ISO C variant of aligned allocation. */ 501 extern void *aligned_alloc(size_t __alignment, size_t __size) 502 __THROW __attribute_malloc__ __attribute_alloc_size__((2)) __wur; 503 #endif 504 505 /* Abort execution and generate a core-dump. */ 506 extern void abort(void) 507 __THROW __attribute__ ((__noreturn__)); 508 509 /* Register a function to be called when `exit' is called. */ 510 extern int atexit(void (*__func) (void)) 511 __THROW __nonnull((1)); 512 513 #if defined __USE_ISOC11 || defined __USE_ISOCXX11 514 /* Register a function to be called when `quick_exit' is called. */ 515 # ifdef __cplusplus 516 extern "C++" int at_quick_exit(void (*__func) (void)) 517 __THROW __asm("at_quick_exit") __nonnull((1)); 518 # else 519 extern int at_quick_exit(void (*__func) (void)) 520 __THROW __nonnull((1)); 521 # endif 522 #endif 523 524 #ifdef __USE_MISC 525 /* Register a function to be called with the status 526 given to `exit' and the given argument. */ 527 extern int on_exit(void (*__func) (int __status, void *__arg), void *__arg) 528 __THROW __nonnull((1)); 529 #endif 530 531 /* Call all functions registered with `atexit' and `on_exit', 532 in the reverse of the order in which they were registered, 533 perform stdio cleanup, and terminate program execution with STATUS. */ 534 extern void exit(int __status) 535 __THROW __attribute__ ((__noreturn__)); 536 537 #if defined __USE_ISOC11 || defined __USE_ISOCXX11 538 /* Call all functions registered with `at_quick_exit' in the reverse 539 of the order in which they were registered and terminate program 540 execution with STATUS. */ 541 extern void quick_exit(int __status) 542 __THROW __attribute__ ((__noreturn__)); 543 #endif 544 545 #ifdef __USE_ISOC99 546 /* Terminate the program with STATUS without calling any of the 547 functions registered with `atexit' or `on_exit'. */ 548 extern void _Exit(int __status) 549 __THROW __attribute__ ((__noreturn__)); 550 #endif 551 552 /* Return the value of envariable NAME, or NULL if it doesn't exist. */ 553 extern char *getenv(const char *__name) 554 __THROW __nonnull((1)) __wur; 555 556 #ifdef __USE_GNU 557 /* This function is similar to the above but returns NULL if the 558 programs is running with SUID or SGID enabled. */ 559 extern char *secure_getenv(const char *__name) 560 __THROW __nonnull((1)) __wur; 561 #endif 562 563 #if defined __USE_MISC || defined __USE_XOPEN 564 /* The SVID says this is in <stdio.h>, but this seems a better place. */ 565 /* Put STRING, which is of the form "NAME=VALUE", in the environment. 566 If there is no `=', remove NAME from the environment. */ 567 extern int putenv(char *__string) 568 __THROW __nonnull((1)); 569 #endif 570 571 #ifdef __USE_XOPEN2K 572 /* Set NAME to VALUE in the environment. 573 If REPLACE is nonzero, overwrite an existing value. */ 574 extern int setenv(const char *__name, const char *__value, int __replace) 575 __THROW __nonnull((2)); 576 577 /* Remove the variable NAME from the environment. */ 578 extern int unsetenv(const char *__name) 579 __THROW __nonnull((1)); 580 #endif 581 582 #ifdef __USE_MISC 583 /* The `clearenv' was planned to be added to POSIX.1 but probably 584 never made it. Nevertheless the POSIX.9 standard (POSIX bindings 585 for Fortran 77) requires this function. */ 586 extern int clearenv(void) __THROW; 587 #endif 588 589 #if defined __USE_MISC \ 590 || (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) 591 /* Generate a unique temporary file name from TEMPLATE. 592 The last six characters of TEMPLATE must be "XXXXXX"; 593 they are replaced with a string that makes the file name unique. 594 Always returns TEMPLATE, it's either a temporary file name or a null 595 string if it cannot get a unique file name. */ 596 extern char *mktemp(char *__template) 597 __THROW __nonnull((1)); 598 #endif 599 600 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 601 /* Generate a unique temporary file name from TEMPLATE. 602 The last six characters of TEMPLATE must be "XXXXXX"; 603 they are replaced with a string that makes the filename unique. 604 Returns a file descriptor open on the file for reading and writing, 605 or -1 if it cannot create a uniquely-named file. 606 607 This function is a possible cancellation point and therefore not 608 marked with __THROW. */ 609 # ifndef __USE_FILE_OFFSET64 610 extern int mkstemp(char *__template) __nonnull((1)) __wur; 611 # else 612 # ifdef __REDIRECT 613 extern int __REDIRECT(mkstemp, (char *__template), mkstemp64) __nonnull((1)) __wur; 614 # else 615 # define mkstemp mkstemp64 616 # endif 617 # endif 618 # ifdef __USE_LARGEFILE64 619 extern int mkstemp64(char *__template) __nonnull((1)) __wur; 620 # endif 621 #endif 622 623 #ifdef __USE_MISC 624 /* Similar to mkstemp, but the template can have a suffix after the 625 XXXXXX. The length of the suffix is specified in the second 626 parameter. 627 628 This function is a possible cancellation point and therefore not 629 marked with __THROW. */ 630 # ifndef __USE_FILE_OFFSET64 631 extern int mkstemps(char *__template, int __suffixlen) __nonnull((1)) __wur; 632 # else 633 # ifdef __REDIRECT 634 extern int __REDIRECT(mkstemps, (char *__template, int __suffixlen), mkstemps64) __nonnull((1)) __wur; 635 # else 636 # define mkstemps mkstemps64 637 # endif 638 # endif 639 # ifdef __USE_LARGEFILE64 640 extern int mkstemps64(char *__template, int __suffixlen) __nonnull((1)) __wur; 641 # endif 642 #endif 643 644 #ifdef __USE_XOPEN2K8 645 /* Create a unique temporary directory from TEMPLATE. 646 The last six characters of TEMPLATE must be "XXXXXX"; 647 they are replaced with a string that makes the directory name unique. 648 Returns TEMPLATE, or a null pointer if it cannot get a unique name. 649 The directory is created mode 700. */ 650 extern char *mkdtemp(char *__template) 651 __THROW __nonnull((1)) __wur; 652 #endif 653 654 #ifdef __USE_GNU 655 /* Generate a unique temporary file name from TEMPLATE similar to 656 mkstemp. But allow the caller to pass additional flags which are 657 used in the open call to create the file.. 658 659 This function is a possible cancellation point and therefore not 660 marked with __THROW. */ 661 # ifndef __USE_FILE_OFFSET64 662 extern int mkostemp(char *__template, int __flags) __nonnull((1)) __wur; 663 # else 664 # ifdef __REDIRECT 665 extern int __REDIRECT(mkostemp, (char *__template, int __flags), mkostemp64) __nonnull((1)) __wur; 666 # else 667 # define mkostemp mkostemp64 668 # endif 669 # endif 670 # ifdef __USE_LARGEFILE64 671 extern int mkostemp64(char *__template, int __flags) __nonnull((1)) __wur; 672 # endif 673 674 /* Similar to mkostemp, but the template can have a suffix after the 675 XXXXXX. The length of the suffix is specified in the second 676 parameter. 677 678 This function is a possible cancellation point and therefore not 679 marked with __THROW. */ 680 # ifndef __USE_FILE_OFFSET64 681 extern int mkostemps(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur; 682 # else 683 # ifdef __REDIRECT 684 extern int __REDIRECT(mkostemps, (char *__template, int __suffixlen, int __flags), mkostemps64) __nonnull((1)) __wur; 685 # else 686 # define mkostemps mkostemps64 687 # endif 688 # endif 689 # ifdef __USE_LARGEFILE64 690 extern int mkostemps64(char *__template, int __suffixlen, int __flags) __nonnull((1)) __wur; 691 # endif 692 #endif 693 694 /* Execute the given line as a shell command. 695 696 This function is a cancellation point and therefore not marked with 697 __THROW. */ 698 extern int system(const char *__command) __wur; 699 700 #ifdef __USE_GNU 701 /* Return a malloc'd string containing the canonical absolute name of the 702 existing named file. */ 703 extern char *canonicalize_file_name(const char *__name) 704 __THROW __nonnull((1)) __wur; 705 #endif 706 707 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED 708 /* Return the canonical absolute name of file NAME. If RESOLVED is 709 null, the result is malloc'd; otherwise, if the canonical name is 710 PATH_MAX chars or more, returns null with `errno' set to 711 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, 712 returns the name in RESOLVED. */ 713 extern char *realpath(const char *__restrict __name, char *__restrict __resolved) 714 __THROW __wur; 715 #endif 716 717 /* Shorthand for type of comparison functions. */ 718 #ifndef __COMPAR_FN_T 719 # define __COMPAR_FN_T 720 typedef int (*__compar_fn_t) (const void *, const void *); 721 722 # ifdef __USE_GNU 723 typedef __compar_fn_t comparison_fn_t; 724 # endif 725 #endif 726 #ifdef __USE_GNU 727 typedef int (*__compar_d_fn_t) (const void *, const void *, void *); 728 #endif 729 730 /* Do a binary search for KEY in BASE, which consists of NMEMB elements 731 of SIZE bytes each, using COMPAR to perform the comparisons. */ 732 extern void *bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 2, 5)) __wur; 733 734 #ifdef __USE_EXTERN_INLINES 735 # include <bits/stdlib-bsearch.h> 736 #endif 737 738 /* Sort NMEMB elements of BASE, of SIZE bytes each, 739 using COMPAR to perform the comparisons. */ 740 extern void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __nonnull((1, 4)); 741 #ifdef __USE_GNU 742 extern void qsort_r(void *__base, size_t __nmemb, size_t __size, __compar_d_fn_t __compar, void *__arg) __nonnull((1, 4)); 743 #endif 744 745 /* Return the absolute value of X. */ 746 extern int abs(int __x) 747 __THROW __attribute__ ((__const__)) __wur; 748 extern long int labs(long int __x) 749 __THROW __attribute__ ((__const__)) __wur; 750 751 #ifdef __USE_ISOC99 752 __extension__ extern long long int llabs(long long int __x) 753 __THROW __attribute__ ((__const__)) __wur; 754 #endif 755 756 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation 757 of the value of NUMER over DENOM. */ 758 /* GCC may have built-ins for these someday. */ 759 extern div_t div(int __numer, int __denom) 760 __THROW __attribute__ ((__const__)) __wur; 761 extern ldiv_t ldiv(long int __numer, long int __denom) 762 __THROW __attribute__ ((__const__)) __wur; 763 764 #ifdef __USE_ISOC99 765 __extension__ extern lldiv_t lldiv(long long int __numer, long long int __denom) 766 __THROW __attribute__ ((__const__)) __wur; 767 #endif 768 769 #if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ 770 || defined __USE_MISC 771 /* Convert floating point numbers to strings. The returned values are 772 valid only until another call to the same function. */ 773 774 /* Convert VALUE to a string with NDIGIT digits and return a pointer to 775 this. Set *DECPT with the position of the decimal character and *SIGN 776 with the sign of the number. */ 777 extern char *ecvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) 778 __THROW __nonnull((3, 4)) __wur; 779 780 /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT 781 with the position of the decimal character and *SIGN with the sign of 782 the number. */ 783 extern char *fcvt(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) 784 __THROW __nonnull((3, 4)) __wur; 785 786 /* If possible convert VALUE to a string with NDIGIT significant digits. 787 Otherwise use exponential representation. The resulting string will 788 be written to BUF. */ 789 extern char *gcvt(double __value, int __ndigit, char *__buf) 790 __THROW __nonnull((3)) __wur; 791 #endif 792 793 #ifdef __USE_MISC 794 /* Long double versions of above functions. */ 795 extern char *qecvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) 796 __THROW __nonnull((3, 4)) __wur; 797 extern char *qfcvt(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) 798 __THROW __nonnull((3, 4)) __wur; 799 extern char *qgcvt(long double __value, int __ndigit, char *__buf) 800 __THROW __nonnull((3)) __wur; 801 802 /* Reentrant version of the functions above which provide their own 803 buffers. */ 804 extern int ecvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) 805 __THROW __nonnull((3, 4, 5)); 806 extern int fcvt_r(double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) 807 __THROW __nonnull((3, 4, 5)); 808 809 extern int qecvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) 810 __THROW __nonnull((3, 4, 5)); 811 extern int qfcvt_r(long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) 812 __THROW __nonnull((3, 4, 5)); 813 #endif /* misc */ 814 815 /* Return the length of the multibyte character 816 in S, which is no longer than N. */ 817 extern int mblen(const char *__s, size_t __n) __THROW; 818 /* Return the length of the given multibyte character, 819 putting its `wchar_t' representation in *PWC. */ 820 extern int mbtowc(wchar_t * __restrict __pwc, const char *__restrict __s, size_t __n) __THROW; 821 /* Put the multibyte character represented 822 by WCHAR in S, returning its length. */ 823 extern int wctomb(char *__s, wchar_t __wchar) __THROW; 824 825 /* Convert a multibyte string to a wide char string. */ 826 extern size_t mbstowcs(wchar_t * __restrict __pwcs, const char *__restrict __s, size_t __n) __THROW; 827 /* Convert a wide char string to multibyte string. */ 828 extern size_t wcstombs(char *__restrict __s, const wchar_t * __restrict __pwcs, size_t __n) __THROW; 829 830 #ifdef __USE_MISC 831 /* Determine whether the string value of RESPONSE matches the affirmation 832 or negative response expression as specified by the LC_MESSAGES category 833 in the program's current locale. Returns 1 if affirmative, 0 if 834 negative, and -1 if not matching. */ 835 extern int rpmatch(const char *__response) 836 __THROW __nonnull((1)) __wur; 837 #endif 838 839 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 840 /* Parse comma separated suboption from *OPTIONP and match against 841 strings in TOKENS. If found return index and set *VALUEP to 842 optional value introduced by an equal sign. If the suboption is 843 not part of TOKENS return in *VALUEP beginning of unknown 844 suboption. On exit *OPTIONP is set to the beginning of the next 845 token or at the terminating NUL character. */ 846 extern int getsubopt(char **__restrict __optionp, char *const *__restrict __tokens, char **__restrict __valuep) 847 __THROW __nonnull((1, 2, 3)) __wur; 848 #endif 849 850 #ifdef __USE_XOPEN 851 /* Setup DES tables according KEY. */ 852 extern void setkey(const char *__key) 853 __THROW __nonnull((1)); 854 #endif 855 856 /* X/Open pseudo terminal handling. */ 857 858 #ifdef __USE_XOPEN2KXSI 859 /* Return a master pseudo-terminal handle. */ 860 extern int posix_openpt(int __oflag) __wur; 861 #endif 862 863 #ifdef __USE_XOPEN_EXTENDED 864 /* The next four functions all take a master pseudo-tty fd and 865 perform an operation on the associated slave: */ 866 867 /* Chown the slave to the calling user. */ 868 extern int grantpt(int __fd) __THROW; 869 870 /* Release an internal lock so the slave can be opened. 871 Call after grantpt(). */ 872 extern int unlockpt(int __fd) __THROW; 873 874 /* Return the pathname of the pseudo terminal slave associated with 875 the master FD is open on, or NULL on errors. 876 The returned storage is good until the next call to this function. */ 877 extern char *ptsname(int __fd) 878 __THROW __wur; 879 #endif 880 881 #ifdef __USE_GNU 882 /* Store at most BUFLEN characters of the pathname of the slave pseudo 883 terminal associated with the master FD is open on in BUF. 884 Return 0 on success, otherwise an error number. */ 885 extern int ptsname_r(int __fd, char *__buf, size_t __buflen) 886 __THROW __nonnull((2)); 887 888 /* Open a master pseudo terminal and return its file descriptor. */ 889 extern int getpt(void); 890 #endif 891 892 #ifdef __USE_MISC 893 /* Put the 1 minute, 5 minute and 15 minute load averages into the first 894 NELEM elements of LOADAVG. Return the number written (never more than 895 three, but may be less than NELEM), or -1 if an error occurred. */ 896 extern int getloadavg(double __loadavg[], int __nelem) 897 __THROW __nonnull((1)); 898 #endif 899 900 #if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K 901 /* Return the index into the active-logins file (utmp) for 902 the controlling terminal. */ 903 extern int ttyslot(void) __THROW; 904 #endif 905 906 #include <bits/stdlib-float.h> 907 908 /* Define some macros helping to catch buffer overflows. */ 909 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function 910 # include <bits/stdlib.h> 911 #endif 912 #ifdef __LDBL_COMPAT 913 # include <bits/stdlib-ldbl.h> 914 #endif 915 916 __END_DECLS 917 #endif /* stdlib.h */