-/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
/* Convert a string to a floating-point number. */
extern double strtod __P ((__const char *__nptr, char **__endptr));
+
+#ifdef __USE_GNU
+/* Likewise for `float' and `long double' sizes of floating-point numbers. */
+extern float strtof __P ((__const char *__nptr, char **__endptr));
+extern __long_double_t strtold __P ((__const char *__nptr, char **__endptr));
+#endif
+
/* Convert a string to a long integer. */
extern long int strtol __P ((__const char *__nptr, char **__endptr,
int __base));
extern unsigned long int strtoul __P ((__const char *__nptr,
char **__endptr, int __base));
+#if defined (__GNUC__) && defined (__USE_BSD)
+/* Convert a string to a quadword integer. */
+extern long long int strtoq __P ((__const char *__nptr, char **__endptr,
+ int __base));
+/* Convert a string to an unsigned quadword integer. */
+extern unsigned long long int strtouq __P ((__const char *__nptr,
+ char **__endptr, int __base));
+#endif /* GCC and use BSD. */
+
+
+/* The internal entry points for `strtoX' take an extra flag argument
+ saying whether or not to parse locale-dependent number grouping. */
+
+extern double __strtod_internal (__const char *__nptr,
+ char **__endptr, int __group);
+extern float __strtof_internal (__const char *__nptr, char **__endptr,
+ int __group);
+extern __long_double_t __strtold_internal (__const char *__nptr,
+ char **__endptr, int __group);
+extern long int __strtol_internal (__const char *__nptr, char **__endptr,
+ int __base, int __group);
+extern unsigned long int __strtoul_internal (__const char *__nptr,
+ char **__endptr, int __base,
+ int __group);
+extern long long int __strtoq_internal (__const char *__nptr, char **__endptr,
+ int __base, int __group);
+extern unsigned long long int __strtouq_internal (__const char *__nptr,
+ char **__endptr, int __base,
+ int __group);
+
#if defined (__OPTIMIZE__) && __GNUC__ >= 2
+/* Define inline functions which call the internal entry points. */
+
+extern __inline double strtod (__const char *__nptr, char **__endptr)
+{ return __strtod_internal (__nptr, __endptr, 0); }
+extern __inline long int strtol (__const char *__nptr,
+ char **__endptr, int __base)
+{ return __strtol_internal (__nptr, __endptr, __base, 0); }
+extern __inline unsigned long int strtoul (__const char *__nptr,
+ char **__endptr, int __base)
+{ return __strtoul_internal (__nptr, __endptr, __base, 0); }
+
+#ifdef __USE_GNU
+extern __inline float strtof (__const char *__nptr, char **__endptr)
+{ return __strtof_internal (__nptr, __endptr, 0); }
+extern __inline __long_double_t strtold (__const char *__nptr, char **__endptr)
+{ return __strtold_internal (__nptr, __endptr, 0); }
+#endif
+
+#ifdef __USE_BSD
+extern __inline long long int strtoq (__const char *__nptr, char **__endptr,
+ int __base)
+{ return __strtoq_internal (__nptr, __endptr, __base, 0); }
+extern __inline unsigned long long int strtouq (__const char *__nptr,
+ char **__endptr, int __base)
+{ return __strtouq_internal (__nptr, __endptr, __base, 0); }
+#endif
+
extern __inline double atof (__const char *__nptr)
-{ return strtod(__nptr, (char **) NULL); }
+{ return strtod (__nptr, (char **) NULL); }
extern __inline int atoi (__const char *__nptr)
{ return (int) strtol (__nptr, (char **) NULL, 10); }
extern __inline long int atol (__const char *__nptr)
#endif /* Optimizing GCC >=2. */
+#ifdef __USE_SVID
+/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
+ digit first. Returns a pointer to static storage overwritten by the
+ next call. */
+extern char *l64a __P ((long int __n));
+
+/* Read a number from a string in base 64 as above. */
+extern long int a64l __P ((const char *));
+#endif
+
+
/* Return a random integer between 0 and RAND_MAX inclusive. */
extern int rand __P ((void));
/* Seed the random number generator with the given number. */
extern void srand __P ((unsigned int __seed));
+#ifdef __USE_BSD
+
+#include <sys/types.h> /* we need int32_t... */
+
/* These are the functions that actually do things. The `random', `srandom',
`initstate' and `setstate' functions are those from BSD Unices.
The `rand' and `srand' functions are required by the ANSI standard.
We provide both interfaces to the same random number generator. */
/* Return a random long integer between 0 and RAND_MAX inclusive. */
-extern long int __random __P ((void));
+extern int32_t __random __P ((void));
/* Seed the random number generator with the given number. */
extern void __srandom __P ((unsigned int __seed));
which should have been previously initialized by `initstate'. */
extern __ptr_t __setstate __P ((__ptr_t __statebuf));
-#ifdef __USE_BSD
extern long int random __P ((void));
extern void srandom __P ((unsigned int __seed));
extern __ptr_t initstate __P ((unsigned int __seed, __ptr_t __statebuf,
extern __inline __ptr_t setstate (__ptr_t __statebuf)
{ return __setstate (__statebuf); }
#endif /* Optimizing GCC >=2. */
-#endif /* Use BSD. */
+
+#ifdef __USE_REENTRANT
+/* Reentrant versions of the `random' family of functions.
+ These functions all use the following data structure to contain
+ state, rather than global state variables. */
+
+struct random_data
+ {
+ int32_t *fptr; /* Front pointer. */
+ int32_t *rptr; /* Rear pointer. */
+ int32_t *state; /* Array of state values. */
+ int rand_type; /* Type of random number generator. */
+ int rand_deg; /* Degree of random number generator. */
+ int rand_sep; /* Distance between front and rear. */
+ int32_t *end_ptr; /* Pointer behind state table. */
+ };
+
+extern int __random_r __P ((struct random_data *__buf, int32_t *__result));
+extern int random_r __P ((struct random_data *__buf, int32_t *__result));
+extern int __srandom_r __P ((unsigned int __seed, struct random_data *__buf));
+extern int __initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
+ size_t __statelen, struct random_data *__buf));
+extern int __setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
+
+extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf));
+extern int initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
+ size_t __statelen, struct random_data *__buf));
+extern int setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
+#endif /* __USE_REENTRANT. */
+#endif /* Use BSD. */
+
+
+#ifdef __USE_SVID
+/* System V style 48-bit random number generator functions. */
+
+/* Data structure for communication with thread safe versions. */
+struct drand48_data
+ {
+ unsigned short int X[3]; /* Current state. */
+ unsigned short int a[3]; /* Factor in congruential formula. */
+ unsigned short int c; /* Additive const. in congruential formula. */
+ unsigned short int old_X[3]; /* Old state. */
+ int init; /* Flag for initializing. */
+ };
+
+/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
+extern double drand48 __P ((void));
+extern int drand48_r __P ((struct drand48_data *__buffer, double *__result));
+extern double erand48 __P ((unsigned short int __xsubi[3]));
+extern int erand48_r __P ((unsigned short int __xsubi[3],
+ struct drand48_data *__buffer, double *__result));
+/* Return non-negative, long integer in [0,2^31). */
+extern long lrand48 __P ((void));
+extern int lrand48_r __P ((struct drand48_data *__buffer, long *__result));
+extern long nrand48 __P ((unsigned short int __xsubi[3]));
+extern int nrand48_r __P ((unsigned short int __xsubi[3],
+ struct drand48_data *__buffer, long *__result));
+/* Return signed, long integers in [-2^31,2^31). */
+extern long mrand48 __P ((void));
+extern int mrand48_r __P ((struct drand48_data *__buffer, long *__result));
+extern long jrand48 __P ((unsigned short int __xsubi[3]));
+extern int jrand48_r __P ((unsigned short int __xsubi[3],
+ struct drand48_data *__buffer, long *__result));
+/* Seed random number generator. */
+extern void srand48 __P ((long __seedval));
+extern int srand48_r __P ((long __seedval, struct drand48_data *__buffer));
+extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
+extern int seed48_r __P ((unsigned short int __seed16v[3],
+ struct drand48_data *__buffer));
+extern void lcong48 __P ((unsigned short int __param[7]));
+extern int lcong48_r __P ((unsigned short int __param[7],
+ struct drand48_data *__buffer));
+
+/* Internal function to compute next state of the generator. */
+extern int __drand48_iterate __P ((unsigned short int __xsubi[3],
+ struct drand48_data *__buffer));
+#endif /* __USE_SVID. */
/* Allocate SIZE bytes of memory. */
/* Abort execution and generate a core-dump. */
-extern __NORETURN void abort __P ((void));
+extern void abort __P ((void)) __attribute__ ((__noreturn__));
/* Register a function to be called when `exit' is called. */
/* Call all functions registered with `atexit' and `on_exit',
in the reverse of the order in which they were registered
perform stdio cleanup, and terminate program execution with STATUS. */
-extern __NORETURN void exit __P ((int __status));
+extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
/* Return the value of envariable NAME, or NULL if it doesn't exist. */
If REPLACE is nonzero, overwrite an existing value. */
extern int setenv __P ((__const char *__name, __const char *__value,
int __replace));
+
+/* Remove the variable NAME from the environment. */
+extern void unsetenv __P ((__const char *__name));
#endif
/* Execute the given line as a shell command. */
/* Shorthand for type of comparison functions. */
+#ifndef __COMPAR_FN_T
+#define __COMPAR_FN_T
typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
+#endif
#ifdef __USE_GNU
typedef __compar_fn_t comparison_fn_t;
__compar_fn_t __compar));
-#ifndef __CONSTVALUE
-#ifdef __GNUC__
-/* The `const' keyword tells GCC that a function's return value is
- based solely on its arguments, and there are no side-effects. */
-#define __CONSTVALUE __const
-#else
-#define __CONSTVALUE
-#endif /* GCC. */
-#endif /* __CONSTVALUE not defined. */
-
/* Return the absolute value of X. */
-extern __CONSTVALUE int abs __P ((int __x));
-extern __CONSTVALUE long int labs __P ((long int __x));
+extern int abs __P ((int __x)) __attribute__ ((__const__));
+extern long int labs __P ((long int __x)) __attribute__ ((__const__));
/* Return the `div_t' or `ldiv_t' representation
of the value of NUMER over DENOM. */
/* GCC may have built-ins for these someday. */
-extern __CONSTVALUE div_t div __P ((int __numer, int __denom));
-extern __CONSTVALUE ldiv_t ldiv __P ((long int __numer, long int __denom));
+extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
+extern ldiv_t ldiv __P ((long int __numer, long int __denom)) __attribute__ ((__const__));
+
+
+#ifdef __USE_SVID
+/* Convert floating point numbers to strings. The returned values are
+ valid only until another call to the same function. */
+
+/* Convert VALUE to a string with NDIGIT digits and return a pointer to
+ this. Set *DECPT with the position of the decimal character and *SIGN
+ with the sign of the number. */
+char *ecvt __P ((double __value, int __ndigit, int *__decpt, int *sign));
+
+/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
+ with the position of the decimal character and *SIGN with the sign of
+ the number. */
+char *fcvt __P ((double __value, int __ndigit, int *__decpt, int *sign));
+
+/* If possible convert VALUE to a string with NDIGIT significant digits.
+ Otherwise use exponential representation. The resulting string will
+ be written to BUF. */
+char *gcvt __P ((double __value, int __ndigit, char *__buf));
+
+/* Reentrant version of the functions above which provide their own
+ buffers. */
+int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
+ char *__buf, size_t __len));
+int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *sign,
+ char *__buf, size_t __len));
+#endif
/* Return the length of the multibyte character
extern size_t wcstombs __P ((char *__s, __const wchar_t * __pwcs, size_t __n));
+#ifdef __USE_SVID
+/* Determine whether the string value of RESPONSE matches the affirmation
+ or negative response expression as specified by the LC_MESSAGES category
+ in the program's current locale. Returns 1 if affirmative, 0 if
+ negative, and -1 if not matching. */
+extern int rpmatch __P ((__const char *__response));
+#endif
+
+
__END_DECLS
#endif /* stdlib.h */