modernc.org/cc@v1.0.1/v2/headers/linux_amd64/usr/include/stdlib.h (about)

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