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