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