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