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