1 /* Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO C Standard: 4.10 GENERAL UTILITIES <stdlib.h>
27 /* Get size_t, wchar_t and NULL from <stddef.h>. */
29 #ifndef __need_malloc_and_calloc
30 # define __need_wchar_t
37 #ifndef __need_malloc_and_calloc
40 /* Returned by `div'. */
43 int quot
; /* Quotient. */
44 int rem
; /* Remainder. */
47 /* Returned by `ldiv'. */
48 #ifndef __ldiv_t_defined
51 long int quot
; /* Quotient. */
52 long int rem
; /* Remainder. */
54 # define __ldiv_t_defined 1
57 #if defined __USE_ISOC99 && !defined __lldiv_t_defined
58 /* Returned by `lldiv'. */
59 __extension__
typedef struct
61 long long int quot
; /* Quotient. */
62 long long int rem
; /* Remainder. */
64 # define __lldiv_t_defined 1
68 /* The largest number rand will return (same as INT_MAX). */
69 #define RAND_MAX 2147483647
72 /* We define these the same for all machines.
73 Changes from this to the outside world should be done in `_exit'. */
74 #define EXIT_FAILURE 1 /* Failing exit status. */
75 #define EXIT_SUCCESS 0 /* Successful exit status. */
78 /* Maximum length of a multibyte character in the current locale. */
79 #define MB_CUR_MAX (__ctype_get_mb_cur_max ())
80 extern size_t __ctype_get_mb_cur_max (void) __THROW
;
83 /* Convert a string to a floating-point number. */
84 extern double atof (__const
char *__nptr
) __THROW
;
85 /* Convert a string to an integer. */
86 extern int atoi (__const
char *__nptr
) __THROW
;
87 /* Convert a string to a long integer. */
88 extern long int atol (__const
char *__nptr
) __THROW
;
90 #if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_MISC)
91 /* These functions will part of the standard C library in ISO C99. */
92 __extension__
extern long long int atoll (__const
char *__nptr
) __THROW
;
95 /* Convert a string to a floating-point number. */
96 extern double strtod (__const
char *__restrict __nptr
,
97 char **__restrict __endptr
) __THROW
;
100 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
101 extern float strtof (__const
char *__restrict __nptr
,
102 char **__restrict __endptr
) __THROW
;
104 extern long double strtold (__const
char *__restrict __nptr
,
105 char **__restrict __endptr
) __THROW
;
108 /* Convert a string to a long integer. */
109 extern long int strtol (__const
char *__restrict __nptr
,
110 char **__restrict __endptr
, int __base
) __THROW
;
111 /* Convert a string to an unsigned long integer. */
112 extern unsigned long int strtoul (__const
char *__restrict __nptr
,
113 char **__restrict __endptr
, int __base
)
116 #if defined __GNUC__ && defined __USE_BSD
117 /* Convert a string to a quadword integer. */
119 extern long long int strtoq (__const
char *__restrict __nptr
,
120 char **__restrict __endptr
, int __base
) __THROW
;
121 /* Convert a string to an unsigned quadword integer. */
123 extern unsigned long long int strtouq (__const
char *__restrict __nptr
,
124 char **__restrict __endptr
, int __base
)
126 #endif /* GCC and use BSD. */
128 #if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_MISC)
129 /* These functions will part of the standard C library in ISO C99. */
131 /* Convert a string to a quadword integer. */
133 extern long long int strtoll (__const
char *__restrict __nptr
,
134 char **__restrict __endptr
, int __base
) __THROW
;
135 /* Convert a string to an unsigned quadword integer. */
137 extern unsigned long long int strtoull (__const
char *__restrict __nptr
,
138 char **__restrict __endptr
, int __base
)
140 #endif /* ISO C99 or GCC and use MISC. */
144 /* The concept of one static locale per category is not very well
145 thought out. Many applications will need to process its data using
146 information from several different locales. Another application is
147 the implementation of the internationalization handling in the
148 upcoming ISO C++ standard library. To support this another set of
149 the functions using locale data exist which have an additional
152 Attention: all these functions are *not* standardized in any form.
153 This is a proof-of-concept implementation. */
155 /* Structure for reentrant locale using functions. This is an
156 (almost) opaque type for the user level programs. */
157 # include <xlocale.h>
159 /* Special versions of the functions above which take the locale to
160 use as an additional parameter. */
161 extern long int __strtol_l (__const
char *__restrict __nptr
,
162 char **__restrict __endptr
, int __base
,
163 __locale_t __loc
) __THROW
;
165 extern unsigned long int __strtoul_l (__const
char *__restrict __nptr
,
166 char **__restrict __endptr
,
167 int __base
, __locale_t __loc
) __THROW
;
170 extern long long int __strtoll_l (__const
char *__restrict __nptr
,
171 char **__restrict __endptr
, int __base
,
172 __locale_t __loc
) __THROW
;
175 extern unsigned long long int __strtoull_l (__const
char *__restrict __nptr
,
176 char **__restrict __endptr
,
177 int __base
, __locale_t __loc
)
180 extern double __strtod_l (__const
char *__restrict __nptr
,
181 char **__restrict __endptr
, __locale_t __loc
)
184 extern float __strtof_l (__const
char *__restrict __nptr
,
185 char **__restrict __endptr
, __locale_t __loc
) __THROW
;
187 extern long double __strtold_l (__const
char *__restrict __nptr
,
188 char **__restrict __endptr
,
189 __locale_t __loc
) __THROW
;
193 /* The internal entry points for `strtoX' take an extra flag argument
194 saying whether or not to parse locale-dependent number grouping. */
196 extern double __strtod_internal (__const
char *__restrict __nptr
,
197 char **__restrict __endptr
, int __group
)
199 extern float __strtof_internal (__const
char *__restrict __nptr
,
200 char **__restrict __endptr
, int __group
)
202 extern long double __strtold_internal (__const
char *__restrict __nptr
,
203 char **__restrict __endptr
,
204 int __group
) __THROW
;
205 #ifndef __strtol_internal_defined
206 extern long int __strtol_internal (__const
char *__restrict __nptr
,
207 char **__restrict __endptr
,
208 int __base
, int __group
) __THROW
;
209 # define __strtol_internal_defined 1
211 #ifndef __strtoul_internal_defined
212 extern unsigned long int __strtoul_internal (__const
char *__restrict __nptr
,
213 char **__restrict __endptr
,
214 int __base
, int __group
) __THROW
;
215 # define __strtoul_internal_defined 1
217 #if defined __GNUC__ || defined __USE_ISOC99
218 # ifndef __strtoll_internal_defined
220 extern long long int __strtoll_internal (__const
char *__restrict __nptr
,
221 char **__restrict __endptr
,
222 int __base
, int __group
) __THROW
;
223 # define __strtoll_internal_defined 1
225 # ifndef __strtoull_internal_defined
227 extern unsigned long long int __strtoull_internal (__const
char *
229 char **__restrict __endptr
,
230 int __base
, int __group
)
232 # define __strtoull_internal_defined 1
236 #if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
237 && defined __USE_EXTERN_INLINES
238 /* Define inline functions which call the internal entry points. */
240 extern __inline
double
241 strtod (__const
char *__restrict __nptr
, char **__restrict __endptr
) __THROW
243 return __strtod_internal (__nptr
, __endptr
, 0);
245 extern __inline
long int
246 strtol (__const
char *__restrict __nptr
, char **__restrict __endptr
,
249 return __strtol_internal (__nptr
, __endptr
, __base
, 0);
251 extern __inline
unsigned long int
252 strtoul (__const
char *__restrict __nptr
, char **__restrict __endptr
,
255 return __strtoul_internal (__nptr
, __endptr
, __base
, 0);
259 extern __inline
float
260 strtof (__const
char *__restrict __nptr
, char **__restrict __endptr
) __THROW
262 return __strtof_internal (__nptr
, __endptr
, 0);
264 extern __inline
long double
265 strtold (__const
char *__restrict __nptr
, char **__restrict __endptr
) __THROW
267 return __strtold_internal (__nptr
, __endptr
, 0);
272 __extension__
extern __inline
long long int
273 strtoq (__const
char *__restrict __nptr
, char **__restrict __endptr
,
276 return __strtoll_internal (__nptr
, __endptr
, __base
, 0);
278 __extension__
extern __inline
unsigned long long int
279 strtouq (__const
char *__restrict __nptr
, char **__restrict __endptr
,
282 return __strtoull_internal (__nptr
, __endptr
, __base
, 0);
286 # if defined __USE_MISC || defined __USE_ISOC99
287 __extension__
extern __inline
long long int
288 strtoll (__const
char *__restrict __nptr
, char **__restrict __endptr
,
291 return __strtoll_internal (__nptr
, __endptr
, __base
, 0);
293 __extension__
extern __inline
unsigned long long int
294 strtoull (__const
char * __restrict __nptr
, char **__restrict __endptr
,
297 return __strtoull_internal (__nptr
, __endptr
, __base
, 0);
301 extern __inline
double
302 atof (__const
char *__nptr
) __THROW
304 return strtod (__nptr
, (char **) NULL
);
307 atoi (__const
char *__nptr
) __THROW
309 return (int) strtol (__nptr
, (char **) NULL
, 10);
311 extern __inline
long int
312 atol (__const
char *__nptr
) __THROW
314 return strtol (__nptr
, (char **) NULL
, 10);
317 # if defined __USE_MISC || defined __USE_ISOC99
318 __extension__
extern __inline
long long int
319 atoll (__const
char *__nptr
) __THROW
321 return strtoll (__nptr
, (char **) NULL
, 10);
324 #endif /* Optimizing and Inlining. */
327 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
328 /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
329 digit first. Returns a pointer to static storage overwritten by the
331 extern char *l64a (long int __n
) __THROW
;
333 /* Read a number from a string S in base 64 as above. */
334 extern long int a64l (__const
char *__s
) __THROW
;
337 # include <sys/types.h> /* we need int32_t... */
339 /* These are the functions that actually do things. The `random', `srandom',
340 `initstate' and `setstate' functions are those from BSD Unices.
341 The `rand' and `srand' functions are required by the ANSI standard.
342 We provide both interfaces to the same random number generator. */
343 /* Return a random long integer between 0 and RAND_MAX inclusive. */
344 extern int32_t random (void) __THROW
;
346 /* Seed the random number generator with the given number. */
347 extern void srandom (unsigned int __seed
) __THROW
;
349 /* Initialize the random number generator to use state buffer STATEBUF,
350 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
351 32, 64, 128 and 256, the bigger the better; values less than 8 will
352 cause an error and values greater than 256 will be rounded down. */
353 extern void *initstate (unsigned int __seed
, void *__statebuf
,
354 size_t __statelen
) __THROW
;
356 /* Switch the random number generator to state buffer STATEBUF,
357 which should have been previously initialized by `initstate'. */
358 extern void *setstate (void *__statebuf
) __THROW
;
362 /* Reentrant versions of the `random' family of functions.
363 These functions all use the following data structure to contain
364 state, rather than global state variables. */
368 int32_t *fptr
; /* Front pointer. */
369 int32_t *rptr
; /* Rear pointer. */
370 int32_t *state
; /* Array of state values. */
371 int rand_type
; /* Type of random number generator. */
372 int rand_deg
; /* Degree of random number generator. */
373 int rand_sep
; /* Distance between front and rear. */
374 int32_t *end_ptr
; /* Pointer behind state table. */
377 extern int random_r (struct random_data
*__restrict __buf
,
378 int32_t *__restrict __result
) __THROW
;
380 extern int srandom_r (unsigned int __seed
, struct random_data
*__buf
) __THROW
;
382 extern int initstate_r (unsigned int __seed
, void *__restrict __statebuf
,
384 struct random_data
*__restrict __buf
) __THROW
;
386 extern int setstate_r (void *__restrict __statebuf
,
387 struct random_data
*__restrict __buf
) __THROW
;
388 # endif /* Use misc. */
389 #endif /* Use SVID || extended X/Open. */
392 /* Return a random integer between 0 and RAND_MAX inclusive. */
393 extern int rand (void) __THROW
;
394 /* Seed the random number generator with the given number. */
395 extern void srand (unsigned int __seed
) __THROW
;
398 /* Reentrant interface according to POSIX.1. */
399 extern int rand_r (unsigned int *__seed
) __THROW
;
403 #if defined __USE_SVID || defined __USE_XOPEN
404 /* System V style 48-bit random number generator functions. */
406 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
407 extern double drand48 (void) __THROW
;
408 extern double erand48 (unsigned short int __xsubi
[3]) __THROW
;
410 /* Return non-negative, long integer in [0,2^31). */
411 extern long int lrand48 (void) __THROW
;
412 extern long int nrand48 (unsigned short int __xsubi
[3]) __THROW
;
414 /* Return signed, long integers in [-2^31,2^31). */
415 extern long int mrand48 (void) __THROW
;
416 extern long int jrand48 (unsigned short int __xsubi
[3]) __THROW
;
418 /* Seed random number generator. */
419 extern void srand48 (long int __seedval
) __THROW
;
420 extern unsigned short int *seed48 (unsigned short int __seed16v
[3]) __THROW
;
421 extern void lcong48 (unsigned short int __param
[7]) __THROW
;
423 /* Data structure for communication with thread safe versions. */
426 unsigned short int x
[3]; /* Current state. */
427 unsigned short int a
[3]; /* Factor in congruential formula. */
428 unsigned short int c
; /* Additive const. in congruential formula. */
429 unsigned short int old_x
[3]; /* Old state. */
430 int init
; /* Flag for initializing. */
434 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
435 extern int drand48_r (struct drand48_data
*__restrict __buffer
,
436 double *__restrict __result
) __THROW
;
437 extern int erand48_r (unsigned short int __xsubi
[3],
438 struct drand48_data
*__restrict __buffer
,
439 double *__restrict __result
) __THROW
;
441 /* Return non-negative, long integer in [0,2^31). */
442 extern int lrand48_r (struct drand48_data
*__restrict __buffer
,
443 long int *__restrict __result
) __THROW
;
444 extern int nrand48_r (unsigned short int __xsubi
[3],
445 struct drand48_data
*__restrict __buffer
,
446 long int *__restrict __result
) __THROW
;
448 /* Return signed, long integers in [-2^31,2^31). */
449 extern int mrand48_r (struct drand48_data
*__restrict __buffer
,
450 long int *__restrict __result
) __THROW
;
451 extern int jrand48_r (unsigned short int __xsubi
[3],
452 struct drand48_data
*__restrict __buffer
,
453 long int *__restrict __result
) __THROW
;
455 /* Seed random number generator. */
456 extern int srand48_r (long int __seedval
, struct drand48_data
*__buffer
)
459 extern int seed48_r (unsigned short int __seed16v
[3],
460 struct drand48_data
*__buffer
) __THROW
;
462 extern int lcong48_r (unsigned short int __param
[7],
463 struct drand48_data
*__buffer
) __THROW
;
464 # endif /* Use misc. */
465 #endif /* Use SVID or X/Open. */
467 #endif /* don't just need malloc and calloc */
469 #ifndef __malloc_and_calloc_defined
470 #define __malloc_and_calloc_defined
471 /* Allocate SIZE bytes of memory. */
472 extern void *malloc (size_t __size
) __THROW
;
473 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
474 extern void *calloc (size_t __nmemb
, size_t __size
) __THROW
;
477 #ifndef __need_malloc_and_calloc
478 /* Re-allocate the previously allocated block
479 in PTR, making the new block SIZE bytes long. */
480 extern void *realloc (void *__ptr
, size_t __size
) __THROW
;
481 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
482 extern void free (void *__ptr
) __THROW
;
485 /* Free a block. An alias for `free'. (Sun Unices). */
486 extern void cfree (void *__ptr
) __THROW
;
487 #endif /* Use misc. */
489 #if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
491 #endif /* Use GNU, BSD, or misc. */
493 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
494 /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
495 extern void *valloc (size_t __size
) __THROW
;
499 /* Abort execution and generate a core-dump. */
500 extern void abort (void) __THROW
__attribute__ ((__noreturn__
));
503 /* Register a function to be called when `exit' is called. */
504 extern int atexit (void (*__func
) (void)) __THROW
;
507 /* Register a function to be called with the status
508 given to `exit' and the given argument. */
509 extern int __on_exit (void (*__func
) (int __status
, void *__arg
), void *__arg
)
511 extern int on_exit (void (*__func
) (int __status
, void *__arg
), void *__arg
)
515 /* Call all functions registered with `atexit' and `on_exit',
516 in the reverse of the order in which they were registered
517 perform stdio cleanup, and terminate program execution with STATUS. */
518 extern void exit (int __status
) __THROW
__attribute__ ((__noreturn__
));
521 /* Terminate the program with STATUS without calling any of the
522 functions registered with `atexit' or `on_exit'. */
523 extern void _Exit (int __status
) __THROW
__attribute__ ((__noreturn__
));
527 /* Return the value of envariable NAME, or NULL if it doesn't exist. */
528 extern char *getenv (__const
char *__name
) __THROW
;
530 /* This function is similar to the above but returns NULL if the
531 programs is running with SUID or SGID enabled. */
532 extern char *__secure_getenv (__const
char *__name
) __THROW
;
534 #if defined __USE_SVID || defined __USE_XOPEN
535 /* The SVID says this is in <stdio.h>, but this seems a better place. */
536 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
537 If there is no `=', remove NAME from the environment. */
538 extern int putenv (char *__string
) __THROW
;
542 /* Set NAME to VALUE in the environment.
543 If REPLACE is nonzero, overwrite an existing value. */
544 extern int setenv (__const
char *__name
, __const
char *__value
, int __replace
)
547 /* Remove the variable NAME from the environment. */
548 extern void unsetenv (__const
char *__name
) __THROW
;
552 /* The `clearenv' was planned to be added to POSIX.1 but probably
553 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
554 for Fortran 77) requires this function. */
555 extern int clearenv (void) __THROW
;
559 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
560 /* Generate a unique temporary file name from TEMPLATE.
561 The last six characters of TEMPLATE must be "XXXXXX";
562 they are replaced with a string that makes the file name unique.
563 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
564 extern char *mktemp (char *__template
) __THROW
;
566 /* Generate a unique temporary file name from TEMPLATE.
567 The last six characters of TEMPLATE must be "XXXXXX";
568 they are replaced with a string that makes the filename unique.
569 Returns a file descriptor open on the file for reading and writing,
570 or -1 if it cannot create a uniquely-named file. */
571 extern int mkstemp (char *__template
) __THROW
;
575 /* Create a unique temporary directory from TEMPLATE.
576 The last six characters of TEMPLATE must be "XXXXXX";
577 they are replaced with a string that makes the directory name unique.
578 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
579 The directory is created mode 700. */
580 extern char *mkdtemp (char *__template
) __THROW
;
584 /* Execute the given line as a shell command. */
585 extern int system (__const
char *__command
) __THROW
;
589 /* Return a malloc'd string containing the canonical absolute name of the
590 named file. The last file name component need not exist, and may be a
591 symlink to a nonexistent file. */
592 extern char *canonicalize_file_name (__const
char *__name
) __THROW
;
595 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
596 /* Return the canonical absolute name of file NAME. The last file name
597 component need not exist, and may be a symlink to a nonexistent file.
598 If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
599 name is PATH_MAX chars or more, returns null with `errno' set to
600 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
602 extern char *realpath (__const
char *__restrict __name
,
603 char *__restrict __resolved
) __THROW
;
607 /* Shorthand for type of comparison functions. */
608 #ifndef __COMPAR_FN_T
609 # define __COMPAR_FN_T
610 typedef int (*__compar_fn_t
) (__const
void *, __const
void *);
613 typedef __compar_fn_t comparison_fn_t
;
617 /* Do a binary search for KEY in BASE, which consists of NMEMB elements
618 of SIZE bytes each, using COMPAR to perform the comparisons. */
619 extern void *bsearch (__const
void *__key
, __const
void *__base
,
620 size_t __nmemb
, size_t __size
, __compar_fn_t __compar
);
622 /* Sort NMEMB elements of BASE, of SIZE bytes each,
623 using COMPAR to perform the comparisons. */
624 extern void qsort (void *__base
, size_t __nmemb
, size_t __size
,
625 __compar_fn_t __compar
);
628 /* Return the absolute value of X. */
629 extern int abs (int __x
) __THROW
__attribute__ ((__const__
));
630 extern long int labs (long int __x
) __THROW
__attribute__ ((__const__
));
632 __extension__
extern long long int llabs (long long int __x
)
633 __THROW
__attribute__ ((__const__
));
637 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
638 of the value of NUMER over DENOM. */
639 /* GCC may have built-ins for these someday. */
640 extern div_t div (int __numer
, int __denom
)
641 __THROW
__attribute__ ((__const__
));
642 extern ldiv_t ldiv (long int __numer
, long int __denom
)
643 __THROW
__attribute__ ((__const__
));
645 __extension__
extern lldiv_t
lldiv (long long int __numer
,
646 long long int __denom
)
647 __THROW
__attribute__ ((__const__
));
651 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
652 /* Convert floating point numbers to strings. The returned values are
653 valid only until another call to the same function. */
655 /* Convert VALUE to a string with NDIGIT digits and return a pointer to
656 this. Set *DECPT with the position of the decimal character and *SIGN
657 with the sign of the number. */
658 extern char *ecvt (double __value
, int __ndigit
, int *__restrict __decpt
,
659 int *__restrict __sign
) __THROW
;
661 /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
662 with the position of the decimal character and *SIGN with the sign of
664 extern char *fcvt (double __value
, int __ndigit
, int *__restrict __decpt
,
665 int *__restrict __sign
) __THROW
;
667 /* If possible convert VALUE to a string with NDIGIT significant digits.
668 Otherwise use exponential representation. The resulting string will
669 be written to BUF. */
670 extern char *gcvt (double __value
, int __ndigit
, char *__buf
) __THROW
;
672 /* Long double versions of above functions. */
673 extern char *qecvt (long double __value
, int __ndigit
,
674 int *__restrict __decpt
, int *__restrict __sign
) __THROW
;
675 extern char *qfcvt (long double __value
, int __ndigit
,
676 int *__restrict __decpt
, int *__restrict __sign
) __THROW
;
677 extern char *qgcvt (long double __value
, int __ndigit
, char *__buf
) __THROW
;
681 /* Reentrant version of the functions above which provide their own
683 extern int ecvt_r (double __value
, int __ndigit
, int *__restrict __decpt
,
684 int *__restrict __sign
, char *__restrict __buf
,
685 size_t __len
) __THROW
;
686 extern int fcvt_r (double __value
, int __ndigit
, int *__restrict __decpt
,
687 int *__restrict __sign
, char *__restrict __buf
,
688 size_t __len
) __THROW
;
690 extern int qecvt_r (long double __value
, int __ndigit
,
691 int *__restrict __decpt
, int *__restrict __sign
,
692 char *__restrict __buf
, size_t __len
) __THROW
;
693 extern int qfcvt_r (long double __value
, int __ndigit
,
694 int *__restrict __decpt
, int *__restrict __sign
,
695 char *__restrict __buf
, size_t __len
) __THROW
;
697 #endif /* use MISC || use X/Open Unix */
700 /* Return the length of the multibyte character
701 in S, which is no longer than N. */
702 extern int mblen (__const
char *__s
, size_t __n
) __THROW
;
703 /* Return the length of the given multibyte character,
704 putting its `wchar_t' representation in *PWC. */
705 extern int mbtowc (wchar_t *__restrict __pwc
,
706 __const
char *__restrict __s
, size_t __n
) __THROW
;
707 /* Put the multibyte character represented
708 by WCHAR in S, returning its length. */
709 extern int wctomb (char *__s
, wchar_t __wchar
) __THROW
;
712 /* Convert a multibyte string to a wide char string. */
713 extern size_t mbstowcs (wchar_t *__restrict __pwcs
,
714 __const
char *__restrict __s
, size_t __n
) __THROW
;
715 /* Convert a wide char string to multibyte string. */
716 extern size_t wcstombs (char *__restrict __s
,
717 __const
wchar_t *__restrict __pwcs
, size_t __n
)
722 /* Determine whether the string value of RESPONSE matches the affirmation
723 or negative response expression as specified by the LC_MESSAGES category
724 in the program's current locale. Returns 1 if affirmative, 0 if
725 negative, and -1 if not matching. */
726 extern int rpmatch (__const
char *__response
) __THROW
;
730 #ifdef __USE_XOPEN_EXTENDED
731 /* Parse comma separated suboption from *OPTIONP and match against
732 strings in TOKENS. If found return index and set *VALUEP to
733 optional value introduced by an equal sign. If the suboption is
734 not part of TOKENS return in *VALUEP beginning of unknown
735 suboption. On exit *OPTIONP is set to the beginning of the next
736 token or at the terminating NUL character. */
737 extern int getsubopt (char **__restrict __optionp
,
738 char *__const
*__restrict __tokens
,
739 char **__restrict __valuep
) __THROW
;
745 /* Setup DES tables according KEY. */
746 extern void setkey (__const
char *__key
) __THROW
;
748 /* X/Open pseudo terminal handling. */
750 /* The next four functions all take a master pseudo-tty fd and
751 perform an operation on the associated slave: */
753 /* Chown the slave to the calling user. */
754 extern int grantpt (int __fd
) __THROW
;
756 /* Release an internal lock so the slave can be opened.
757 Call after grantpt(). */
758 extern int unlockpt (int __fd
) __THROW
;
760 /* Return the pathname of the pseudo terminal slave assoicated with
761 the master FD is open on, or NULL on errors.
762 The returned storage is good until the next call to this function. */
763 extern char *ptsname (int __fd
) __THROW
;
767 /* Store at most BUFLEN characters of the pathname of the slave pseudo
768 terminal associated with the master FD is open on in BUF.
769 Return 0 on success, otherwise an error number. */
770 extern int ptsname_r (int __fd
, char *__buf
, size_t __buflen
) __THROW
;
772 /* Open a master pseudo terminal and return its file descriptor. */
773 extern int getpt (void) __THROW
;
777 /* Put the 1 minute, 5 minute and 15 minute load averages into the first
778 NELEM elements of LOADAVG. Return the number written (never more than
779 three, but may be less than NELEM), or -1 if an error occurred. */
780 extern int getloadavg (double __loadavg
[], int __nelem
) __THROW
;
783 #endif /* don't just need malloc and calloc */
784 #undef __need_malloc_and_calloc
788 #endif /* stdlib.h */