Update.
[glibc.git] / stdlib / stdlib.h
blob8a47b81ed9d28fbb08d416446311f450888645cd
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>
23 #ifndef _STDLIB_H
25 #include <features.h>
27 /* Get size_t, wchar_t and NULL from <stddef.h>. */
28 #define __need_size_t
29 #ifndef __need_malloc_and_calloc
30 # define __need_wchar_t
31 # define __need_NULL
32 #endif
33 #include <stddef.h>
35 __BEGIN_DECLS
37 #ifndef __need_malloc_and_calloc
38 #define _STDLIB_H 1
40 /* Returned by `div'. */
41 typedef struct
43 int quot; /* Quotient. */
44 int rem; /* Remainder. */
45 } div_t;
47 /* Returned by `ldiv'. */
48 #ifndef __ldiv_t_defined
49 typedef struct
51 long int quot; /* Quotient. */
52 long int rem; /* Remainder. */
53 } ldiv_t;
54 # define __ldiv_t_defined 1
55 #endif
57 #if defined __USE_ISOC9X && !defined __lldiv_t_defined
58 /* Returned by `lldiv'. */
59 __extension__ typedef struct
61 long long int quot; /* Quotient. */
62 long long int rem; /* Remainder. */
63 } lldiv_t;
64 # define __lldiv_t_defined 1
65 #endif
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 __P ((void));
83 /* Convert a string to a floating-point number. */
84 extern double atof __P ((__const char *__nptr));
85 /* Convert a string to an integer. */
86 extern int atoi __P ((__const char *__nptr));
87 /* Convert a string to a long integer. */
88 extern long int atol __P ((__const char *__nptr));
90 #if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
91 /* These functions will part of the standard C library in ISO C 9X. */
92 __extension__ extern long long int atoll __P ((__const char *__nptr));
93 #endif
95 /* Convert a string to a floating-point number. */
96 extern double strtod __P ((__const char *__restrict __nptr,
97 char **__restrict __endptr));
99 #ifdef __USE_ISOC9X
100 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
101 extern float strtof __P ((__const char *__restrict __nptr,
102 char **__restrict __endptr));
104 extern __long_double_t strtold __P ((__const char *__restrict __nptr,
105 char **__restrict __endptr));
106 #endif
108 /* Convert a string to a long integer. */
109 extern long int strtol __P ((__const char *__restrict __nptr,
110 char **__restrict __endptr, int __base));
111 /* Convert a string to an unsigned long integer. */
112 extern unsigned long int strtoul __P ((__const char *__restrict __nptr,
113 char **__restrict __endptr,
114 int __base));
116 #if defined __GNUC__ && defined __USE_BSD
117 /* Convert a string to a quadword integer. */
118 __extension__
119 extern long long int strtoq __P ((__const char *__restrict __nptr,
120 char **__restrict __endptr, int __base));
121 /* Convert a string to an unsigned quadword integer. */
122 __extension__
123 extern unsigned long long int strtouq __P ((__const char *__restrict __nptr,
124 char **__restrict __endptr,
125 int __base));
126 #endif /* GCC and use BSD. */
128 #if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
129 /* These functions will part of the standard C library in ISO C 9X. */
131 /* Convert a string to a quadword integer. */
132 __extension__
133 extern long long int strtoll __P ((__const char *__restrict __nptr,
134 char **__restrict __endptr, int __base));
135 /* Convert a string to an unsigned quadword integer. */
136 __extension__
137 extern unsigned long long int strtoull __P ((__const char *__restrict __nptr,
138 char **__restrict __endptr,
139 int __base));
140 #endif /* ISO C 9X or GCC and use MISC. */
143 #ifdef __USE_GNU
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
150 argument.
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 __P ((__const char *__restrict __nptr,
162 char **__restrict __endptr, int __base,
163 __locale_t __loc));
165 extern unsigned long int __strtoul_l __P ((__const char *__restrict __nptr,
166 char **__restrict __endptr,
167 int __base, __locale_t __loc));
169 __extension__
170 extern long long int __strtoll_l __P ((__const char *__restrict __nptr,
171 char **__restrict __endptr, int __base,
172 __locale_t __loc));
174 __extension__
175 extern unsigned long long int __strtoull_l __P ((__const char *__restrict
176 __nptr,
177 char **__restrict __endptr,
178 int __base,
179 __locale_t __loc));
181 extern double __strtod_l __P ((__const char *__restrict __nptr,
182 char **__restrict __endptr, __locale_t __loc));
184 extern float __strtof_l __P ((__const char *__restrict __nptr,
185 char **__restrict __endptr, __locale_t __loc));
187 extern __long_double_t __strtold_l __P ((__const char *__restrict __nptr,
188 char **__restrict __endptr,
189 __locale_t __loc));
190 #endif /* GNU */
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 __P ((__const char *__restrict __nptr,
197 char **__restrict __endptr,
198 int __group));
199 extern float __strtof_internal __P ((__const char *__restrict __nptr,
200 char **__restrict __endptr, int __group));
201 extern __long_double_t __strtold_internal __P ((__const char *
202 __restrict __nptr,
203 char **__restrict __endptr,
204 int __group));
205 #ifndef __strtol_internal_defined
206 extern long int __strtol_internal __P ((__const char *__restrict __nptr,
207 char **__restrict __endptr,
208 int __base, int __group));
209 # define __strtol_internal_defined 1
210 #endif
211 #ifndef __strtoul_internal_defined
212 extern unsigned long int __strtoul_internal __P ((__const char *
213 __restrict __nptr,
214 char **__restrict __endptr,
215 int __base, int __group));
216 # define __strtoul_internal_defined 1
217 #endif
218 #if defined __GNUC__ || defined __USE_ISOC9X
219 # ifndef __strtoll_internal_defined
220 __extension__
221 extern long long int __strtoll_internal __P ((__const char *__restrict __nptr,
222 char **__restrict __endptr,
223 int __base, int __group));
224 # define __strtoll_internal_defined 1
225 # endif
226 # ifndef __strtoull_internal_defined
227 __extension__
228 extern unsigned long long int __strtoull_internal __P ((__const char *
229 __restrict __nptr,
230 char **
231 __restrict __endptr,
232 int __base,
233 int __group));
234 # define __strtoull_internal_defined 1
235 # endif
236 #endif /* GCC */
238 #if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
239 && defined __USE_EXTERN_INLINES
240 /* Define inline functions which call the internal entry points. */
242 extern __inline double
243 strtod (__const char *__restrict __nptr, char **__restrict __endptr) __THROW
245 return __strtod_internal (__nptr, __endptr, 0);
247 extern __inline long int
248 strtol (__const char *__restrict __nptr, char **__restrict __endptr,
249 int __base) __THROW
251 return __strtol_internal (__nptr, __endptr, __base, 0);
253 extern __inline unsigned long int
254 strtoul (__const char *__restrict __nptr, char **__restrict __endptr,
255 int __base) __THROW
257 return __strtoul_internal (__nptr, __endptr, __base, 0);
260 # ifdef __USE_ISOC9X
261 extern __inline float
262 strtof (__const char *__restrict __nptr, char **__restrict __endptr) __THROW
264 return __strtof_internal (__nptr, __endptr, 0);
266 extern __inline __long_double_t
267 strtold (__const char *__restrict __nptr, char **__restrict __endptr) __THROW
269 return __strtold_internal (__nptr, __endptr, 0);
271 # endif
273 # ifdef __USE_BSD
274 __extension__ extern __inline long long int
275 strtoq (__const char *__restrict __nptr, char **__restrict __endptr,
276 int __base) __THROW
278 return __strtoll_internal (__nptr, __endptr, __base, 0);
280 __extension__ extern __inline unsigned long long int
281 strtouq (__const char *__restrict __nptr, char **__restrict __endptr,
282 int __base) __THROW
284 return __strtoull_internal (__nptr, __endptr, __base, 0);
286 # endif
288 # if defined __USE_MISC || defined __USE_ISOC9X
289 __extension__ extern __inline long long int
290 strtoll (__const char *__restrict __nptr, char **__restrict __endptr,
291 int __base) __THROW
293 return __strtoll_internal (__nptr, __endptr, __base, 0);
295 __extension__ extern __inline unsigned long long int
296 strtoull (__const char * __restrict __nptr, char **__restrict __endptr,
297 int __base) __THROW
299 return __strtoull_internal (__nptr, __endptr, __base, 0);
301 # endif
303 extern __inline double
304 atof (__const char *__nptr) __THROW
306 return strtod (__nptr, (char **) NULL);
308 extern __inline int
309 atoi (__const char *__nptr) __THROW
311 return (int) strtol (__nptr, (char **) NULL, 10);
313 extern __inline long int
314 atol (__const char *__nptr) __THROW
316 return strtol (__nptr, (char **) NULL, 10);
319 # if defined __USE_MISC || defined __USE_ISOC9X
320 __extension__ extern __inline long long int
321 atoll (__const char *__nptr) __THROW
323 return strtoll (__nptr, (char **) NULL, 10);
325 # endif
326 #endif /* Optimizing and Inlining. */
329 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
330 /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
331 digit first. Returns a pointer to static storage overwritten by the
332 next call. */
333 extern char *l64a __P ((long int __n));
335 /* Read a number from a string S in base 64 as above. */
336 extern long int a64l __P ((__const char *__s));
339 # include <sys/types.h> /* we need int32_t... */
341 /* These are the functions that actually do things. The `random', `srandom',
342 `initstate' and `setstate' functions are those from BSD Unices.
343 The `rand' and `srand' functions are required by the ANSI standard.
344 We provide both interfaces to the same random number generator. */
345 /* Return a random long integer between 0 and RAND_MAX inclusive. */
346 extern int32_t random __P ((void));
348 /* Seed the random number generator with the given number. */
349 extern void srandom __P ((unsigned int __seed));
351 /* Initialize the random number generator to use state buffer STATEBUF,
352 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
353 32, 64, 128 and 256, the bigger the better; values less than 8 will
354 cause an error and values greater than 256 will be rounded down. */
355 extern __ptr_t initstate __P ((unsigned int __seed, __ptr_t __statebuf,
356 size_t __statelen));
358 /* Switch the random number generator to state buffer STATEBUF,
359 which should have been previously initialized by `initstate'. */
360 extern __ptr_t setstate __P ((__ptr_t __statebuf));
363 # ifdef __USE_MISC
364 /* Reentrant versions of the `random' family of functions.
365 These functions all use the following data structure to contain
366 state, rather than global state variables. */
368 struct random_data
370 int32_t *fptr; /* Front pointer. */
371 int32_t *rptr; /* Rear pointer. */
372 int32_t *state; /* Array of state values. */
373 int rand_type; /* Type of random number generator. */
374 int rand_deg; /* Degree of random number generator. */
375 int rand_sep; /* Distance between front and rear. */
376 int32_t *end_ptr; /* Pointer behind state table. */
379 extern int random_r __P ((struct random_data *__restrict __buf,
380 int32_t *__restrict __result));
382 extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf));
384 extern int initstate_r __P ((unsigned int __seed,
385 __ptr_t __restrict __statebuf,
386 size_t __statelen,
387 struct random_data *__restrict __buf));
389 extern int setstate_r __P ((__ptr_t __restrict __statebuf,
390 struct random_data *__restrict __buf));
391 # endif /* Use misc. */
392 #endif /* Use SVID || extended X/Open. */
395 /* Return a random integer between 0 and RAND_MAX inclusive. */
396 extern int rand __P ((void));
397 /* Seed the random number generator with the given number. */
398 extern void srand __P ((unsigned int __seed));
400 #ifdef __USE_POSIX
401 /* Reentrant interface according to POSIX.1. */
402 extern int rand_r __P ((unsigned int *__seed));
403 #endif
406 #if defined __USE_SVID || defined __USE_XOPEN
407 /* System V style 48-bit random number generator functions. */
409 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
410 extern double drand48 __P ((void));
411 extern double erand48 __P ((unsigned short int __xsubi[3]));
413 /* Return non-negative, long integer in [0,2^31). */
414 extern long int lrand48 __P ((void));
415 extern long int nrand48 __P ((unsigned short int __xsubi[3]));
417 /* Return signed, long integers in [-2^31,2^31). */
418 extern long int mrand48 __P ((void));
419 extern long int jrand48 __P ((unsigned short int __xsubi[3]));
421 /* Seed random number generator. */
422 extern void srand48 __P ((long int __seedval));
423 extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
424 extern void lcong48 __P ((unsigned short int __param[7]));
426 /* Data structure for communication with thread safe versions. */
427 struct drand48_data
429 unsigned short int x[3]; /* Current state. */
430 unsigned short int a[3]; /* Factor in congruential formula. */
431 unsigned short int c; /* Additive const. in congruential formula. */
432 unsigned short int old_x[3]; /* Old state. */
433 int init; /* Flag for initializing. */
436 # ifdef __USE_MISC
437 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
438 extern int drand48_r __P ((struct drand48_data *__restrict __buffer,
439 double *__restrict __result));
440 extern int erand48_r __P ((unsigned short int __xsubi[3],
441 struct drand48_data *__restrict __buffer,
442 double *__restrict __result));
444 /* Return non-negative, long integer in [0,2^31). */
445 extern int lrand48_r __P ((struct drand48_data *__restrict __buffer,
446 long int *__restrict __result));
447 extern int nrand48_r __P ((unsigned short int __xsubi[3],
448 struct drand48_data *__restrict __buffer,
449 long int *__restrict __result));
451 /* Return signed, long integers in [-2^31,2^31). */
452 extern int mrand48_r __P ((struct drand48_data *__restrict __buffer,
453 long int *__restrict __result));
454 extern int jrand48_r __P ((unsigned short int __xsubi[3],
455 struct drand48_data *__restrict __buffer,
456 long int *__restrict __result));
458 /* Seed random number generator. */
459 extern int srand48_r __P ((long int __seedval, struct drand48_data *__buffer));
461 extern int seed48_r __P ((unsigned short int __seed16v[3],
462 struct drand48_data *__buffer));
464 extern int lcong48_r __P ((unsigned short int __param[7],
465 struct drand48_data *__buffer));
466 # endif /* Use misc. */
467 #endif /* Use SVID or X/Open. */
469 #endif /* don't just need malloc and calloc */
471 #ifndef __malloc_and_calloc_defined
472 #define __malloc_and_calloc_defined
473 /* Allocate SIZE bytes of memory. */
474 extern __ptr_t malloc __P ((size_t __size));
475 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
476 extern __ptr_t calloc __P ((size_t __nmemb, size_t __size));
477 #endif
479 #ifndef __need_malloc_and_calloc
480 /* Re-allocate the previously allocated block
481 in __ptr_t, making the new block SIZE bytes long. */
482 extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size));
483 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
484 extern void free __P ((__ptr_t __ptr));
486 #ifdef __USE_MISC
487 /* Free a block. An alias for `free'. (Sun Unices). */
488 extern void cfree __P ((__ptr_t __ptr));
489 #endif /* Use misc. */
491 #if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
492 # include <alloca.h>
493 #endif /* Use GNU, BSD, or misc. */
495 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
496 /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
497 extern __ptr_t valloc __P ((size_t __size));
498 #endif
501 /* Abort execution and generate a core-dump. */
502 extern void abort __P ((void)) __attribute__ ((__noreturn__));
505 /* Register a function to be called when `exit' is called. */
506 extern int atexit __P ((void (*__func) (void)));
508 #ifdef __USE_MISC
509 /* Register a function to be called with the status
510 given to `exit' and the given argument. */
511 extern int __on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
512 __ptr_t __arg));
513 extern int on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
514 __ptr_t __arg));
515 #endif
517 /* Call all functions registered with `atexit' and `on_exit',
518 in the reverse of the order in which they were registered
519 perform stdio cleanup, and terminate program execution with STATUS. */
520 extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
522 #ifdef __USE_ISOC9X
523 /* Terminate the program with STATUS without calling any of the
524 functions registered with `atexit' or `on_exit'. */
525 extern void _Exit __P ((int __status)) __attribute__ ((__noreturn__));
526 #endif
529 /* Return the value of envariable NAME, or NULL if it doesn't exist. */
530 extern char *getenv __P ((__const char *__name));
532 /* This function is similar to the above but returns NULL if the
533 programs is running with SUID or SGID enabled. */
534 extern char *__secure_getenv __P ((__const char *__name));
536 #if defined __USE_SVID || defined __USE_XOPEN
537 /* The SVID says this is in <stdio.h>, but this seems a better place. */
538 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
539 If there is no `=', remove NAME from the environment. */
540 extern int putenv __P ((__const char *__string));
541 #endif
543 #ifdef __USE_BSD
544 /* Set NAME to VALUE in the environment.
545 If REPLACE is nonzero, overwrite an existing value. */
546 extern int setenv __P ((__const char *__name, __const char *__value,
547 int __replace));
549 /* Remove the variable NAME from the environment. */
550 extern void unsetenv __P ((__const char *__name));
551 #endif
553 #ifdef __USE_MISC
554 /* The `clearenv' was planned to be added to POSIX.1 but probably
555 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
556 for Fortran 77) requires this function. */
557 extern int clearenv __P ((void));
558 #endif
561 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
562 /* Generate a unique temporary file name from TEMPLATE.
563 The last six characters of TEMPLATE must be "XXXXXX";
564 they are replaced with a string that makes the file name unique.
565 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
566 extern char *mktemp __P ((char *__template));
568 /* Generate a unique temporary file name from TEMPLATE.
569 The last six characters of TEMPLATE must be "XXXXXX";
570 they are replaced with a string that makes the filename unique.
571 Returns a file descriptor open on the file for reading and writing,
572 or -1 if it cannot create a uniquely-named file. */
573 extern int mkstemp __P ((char *__template));
574 #endif
577 /* Execute the given line as a shell command. */
578 extern int system __P ((__const char *__command));
581 #ifdef __USE_GNU
582 /* Return a malloc'd string containing the canonical absolute name of the
583 named file. The last file name component need not exist, and may be a
584 symlink to a nonexistent file. */
585 extern char *canonicalize_file_name __P ((__const char *__name));
586 #endif
588 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
589 /* Return the canonical absolute name of file NAME. The last file name
590 component need not exist, and may be a symlink to a nonexistent file.
591 If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
592 name is PATH_MAX chars or more, returns null with `errno' set to
593 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
594 name in RESOLVED. */
595 extern char *realpath __P ((__const char *__restrict __name,
596 char *__restrict __resolved));
597 #endif
600 /* Shorthand for type of comparison functions. */
601 #ifndef __COMPAR_FN_T
602 # define __COMPAR_FN_T
603 typedef int (*__compar_fn_t) __PMT ((__const __ptr_t, __const __ptr_t));
605 # ifdef __USE_GNU
606 typedef __compar_fn_t comparison_fn_t;
607 # endif
608 #endif
610 /* Do a binary search for KEY in BASE, which consists of NMEMB elements
611 of SIZE bytes each, using COMPAR to perform the comparisons. */
612 extern __ptr_t bsearch __PMT ((__const __ptr_t __key, __const __ptr_t __base,
613 size_t __nmemb, size_t __size,
614 __compar_fn_t __compar));
616 /* Sort NMEMB elements of BASE, of SIZE bytes each,
617 using COMPAR to perform the comparisons. */
618 extern void qsort __PMT ((__ptr_t __base, size_t __nmemb, size_t __size,
619 __compar_fn_t __compar));
622 /* Return the absolute value of X. */
623 extern int abs __P ((int __x)) __attribute__ ((__const__));
624 extern long int labs __P ((long int __x)) __attribute__ ((__const__));
625 #ifdef __USE_ISOC9X
626 __extension__ extern long long int llabs __P ((long long int __x))
627 __attribute__ ((__const__));
628 #endif
631 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
632 of the value of NUMER over DENOM. */
633 /* GCC may have built-ins for these someday. */
634 extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
635 extern ldiv_t ldiv __P ((long int __numer, long int __denom))
636 __attribute__ ((__const__));
637 #ifdef __USE_ISOC9X
638 __extension__ extern lldiv_t lldiv __P ((long long int __numer,
639 long long int __denom))
640 __attribute__ ((__const__));
641 #endif
644 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
645 /* Convert floating point numbers to strings. The returned values are
646 valid only until another call to the same function. */
648 /* Convert VALUE to a string with NDIGIT digits and return a pointer to
649 this. Set *DECPT with the position of the decimal character and *SIGN
650 with the sign of the number. */
651 extern char *ecvt __P ((double __value, int __ndigit, int *__restrict __decpt,
652 int *__restrict __sign));
654 /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
655 with the position of the decimal character and *SIGN with the sign of
656 the number. */
657 extern char *fcvt __P ((double __value, int __ndigit, int *__restrict __decpt,
658 int *__restrict __sign));
660 /* If possible convert VALUE to a string with NDIGIT significant digits.
661 Otherwise use exponential representation. The resulting string will
662 be written to BUF. */
663 extern char *gcvt __P ((double __value, int __ndigit, char *__buf));
665 /* Long double versions of above functions. */
666 extern char *qecvt __P ((__long_double_t __value, int __ndigit,
667 int *__restrict __decpt, int *__restrict __sign));
668 extern char *qfcvt __P ((__long_double_t __value, int __ndigit,
669 int *__restrict __decpt, int *__restrict __sign));
670 extern char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf));
673 # ifdef __USE_MISC
674 /* Reentrant version of the functions above which provide their own
675 buffers. */
676 extern int ecvt_r __P ((double __value, int __ndigit, int *__restrict __decpt,
677 int *__restrict __sign, char *__restrict __buf,
678 size_t __len));
679 extern int fcvt_r __P ((double __value, int __ndigit, int *__restrict __decpt,
680 int *__restrict __sign, char *__restrict __buf,
681 size_t __len));
683 extern int qecvt_r __P ((__long_double_t __value, int __ndigit,
684 int *__restrict __decpt, int *__restrict __sign,
685 char *__restrict __buf, size_t __len));
686 extern int qfcvt_r __P ((__long_double_t __value, int __ndigit,
687 int *__restrict __decpt, int *__restrict __sign,
688 char *__restrict __buf, size_t __len));
689 # endif /* misc */
690 #endif /* use MISC || use X/Open Unix */
693 /* Return the length of the multibyte character
694 in S, which is no longer than N. */
695 extern int mblen __P ((__const char *__s, size_t __n));
696 /* Return the length of the given multibyte character,
697 putting its `wchar_t' representation in *PWC. */
698 extern int mbtowc __P ((wchar_t *__restrict __pwc,
699 __const char *__restrict __s, size_t __n));
700 /* Put the multibyte character represented
701 by WCHAR in S, returning its length. */
702 extern int wctomb __P ((char *__s, wchar_t __wchar));
705 /* Convert a multibyte string to a wide char string. */
706 extern size_t mbstowcs __P ((wchar_t *__restrict __pwcs,
707 __const char *__restrict __s, size_t __n));
708 /* Convert a wide char string to multibyte string. */
709 extern size_t wcstombs __P ((char *__restrict __s,
710 __const wchar_t *__restrict __pwcs, size_t __n));
713 #ifdef __USE_SVID
714 /* Determine whether the string value of RESPONSE matches the affirmation
715 or negative response expression as specified by the LC_MESSAGES category
716 in the program's current locale. Returns 1 if affirmative, 0 if
717 negative, and -1 if not matching. */
718 extern int rpmatch __P ((__const char *__response));
719 #endif
722 #ifdef __USE_XOPEN_EXTENDED
723 /* Parse comma separated suboption from *OPTIONP and match against
724 strings in TOKENS. If found return index and set *VALUEP to
725 optional value introduced by an equal sign. If the suboption is
726 not part of TOKENS return in *VALUEP beginning of unknown
727 suboption. On exit *OPTIONP is set to the beginning of the next
728 token or at the terminating NUL character. */
729 extern int getsubopt __P ((char **__restrict __optionp,
730 __const char *__const *__restrict __tokens,
731 char **__restrict __valuep));
732 #endif
735 #ifdef __USE_XOPEN
737 /* Setup DES tables according KEY. */
738 extern void setkey __P ((__const char *__key));
740 /* X/Open pseudo terminal handling. */
742 /* The next four functions all take a master pseudo-tty fd and
743 perform an operation on the associated slave: */
745 /* Chown the slave to the calling user. */
746 extern int grantpt __P ((int __fd));
748 /* Release an internal lock so the slave can be opened.
749 Call after grantpt(). */
750 extern int unlockpt __P ((int __fd));
752 /* Return the pathname of the pseudo terminal slave assoicated with
753 the master FD is open on, or NULL on errors.
754 The returned storage is good until the next call to this function. */
755 extern char *ptsname __P ((int __fd));
756 #endif
758 #ifdef __USE_GNU
759 /* Store at most BUFLEN characters of the pathname of the slave pseudo
760 terminal associated with the master FD is open on in BUF.
761 Return 0 on success, otherwise an error number. */
762 extern int ptsname_r __P ((int __fd, char *__buf, size_t __buflen));
764 /* Open a master pseudo terminal and return its file descriptor. */
765 extern int getpt __P ((void));
766 #endif
768 #endif /* don't just need malloc and calloc */
769 #undef __need_malloc_and_calloc
771 __END_DECLS
773 #endif /* stdlib.h */