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