]>
Commit | Line | Data |
---|---|---|
bbed653c | 1 | /* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. |
ba1ffaa1 | 2 | This file is part of the GNU C Library. |
28f540f4 | 3 | |
ba1ffaa1 UD |
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. | |
28f540f4 | 8 | |
ba1ffaa1 UD |
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. | |
28f540f4 | 13 | |
ba1ffaa1 UD |
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. */ | |
28f540f4 RM |
18 | |
19 | /* | |
ba1ffaa1 | 20 | * ISO S Standard: 4.10 GENERAL UTILITIES <stdlib.h> |
28f540f4 RM |
21 | */ |
22 | ||
23 | #ifndef _STDLIB_H | |
24 | ||
25 | #define _STDLIB_H 1 | |
26 | #include <features.h> | |
27 | ||
28 | /* Get size_t, wchar_t and NULL from <stddef.h>. */ | |
29 | #define __need_size_t | |
30 | #define __need_wchar_t | |
31 | #define __need_NULL | |
32 | #include <stddef.h> | |
33 | ||
34 | #define __need_Emath | |
35 | #include <errno.h> | |
36 | ||
37 | __BEGIN_DECLS | |
38 | ||
39 | /* Returned by `div'. */ | |
40 | typedef struct | |
41 | { | |
42 | int quot; /* Quotient. */ | |
43 | int rem; /* Remainder. */ | |
44 | } div_t; | |
45 | ||
46 | /* Returned by `ldiv'. */ | |
47 | typedef struct | |
48 | { | |
49 | long int quot; /* Quotient. */ | |
50 | long int rem; /* Remainder. */ | |
51 | } ldiv_t; | |
52 | ||
59dd8641 RM |
53 | #ifdef __USE_GNU |
54 | /* Returned by `lldiv'. */ | |
55 | typedef struct | |
56 | { | |
57 | long long int quot; /* Quotient. */ | |
58 | long long int rem; /* Remainder. */ | |
59 | } lldiv_t; | |
60 | #endif | |
61 | ||
28f540f4 RM |
62 | |
63 | /* The largest number rand will return (same as INT_MAX). */ | |
64 | #define RAND_MAX 2147483647 | |
65 | ||
66 | ||
67 | /* We define these the same for all machines. | |
68 | Changes from this to the outside world should be done in `_exit'. */ | |
69 | #define EXIT_FAILURE 1 /* Failing exit status. */ | |
70 | #define EXIT_SUCCESS 0 /* Successful exit status. */ | |
71 | ||
72 | ||
0200214b RM |
73 | /* Maximum length of a multibyte character in the current locale. */ |
74 | #define MB_CUR_MAX (__ctype_get_mb_cur_max ()) | |
75 | extern int __ctype_get_mb_cur_max __P ((void)); | |
28f540f4 RM |
76 | |
77 | ||
78 | /* Convert a string to a floating-point number. */ | |
79 | extern double atof __P ((__const char *__nptr)); | |
80 | /* Convert a string to an integer. */ | |
81 | extern int atoi __P ((__const char *__nptr)); | |
82 | /* Convert a string to a long integer. */ | |
83 | extern long int atol __P ((__const char *__nptr)); | |
84 | ||
85 | /* Convert a string to a floating-point number. */ | |
86 | extern double strtod __P ((__const char *__nptr, char **__endptr)); | |
87 | ||
88 | #ifdef __USE_GNU | |
89 | /* Likewise for `float' and `long double' sizes of floating-point numbers. */ | |
28f540f4 | 90 | extern float strtof __P ((__const char *__nptr, char **__endptr)); |
28f540f4 RM |
91 | extern __long_double_t strtold __P ((__const char *__nptr, char **__endptr)); |
92 | #endif | |
93 | ||
94 | /* Convert a string to a long integer. */ | |
95 | extern long int strtol __P ((__const char *__nptr, char **__endptr, | |
96 | int __base)); | |
97 | /* Convert a string to an unsigned long integer. */ | |
98 | extern unsigned long int strtoul __P ((__const char *__nptr, | |
99 | char **__endptr, int __base)); | |
100 | ||
101 | #if defined (__GNUC__) && defined (__USE_BSD) | |
102 | /* Convert a string to a quadword integer. */ | |
103 | extern long long int strtoq __P ((__const char *__nptr, char **__endptr, | |
104 | int __base)); | |
105 | /* Convert a string to an unsigned quadword integer. */ | |
106 | extern unsigned long long int strtouq __P ((__const char *__nptr, | |
107 | char **__endptr, int __base)); | |
108 | #endif /* GCC and use BSD. */ | |
109 | ||
76060ec0 RM |
110 | #if defined (__GNUC__) && defined (__USE_MISC) |
111 | /* Convert a string to a quadword integer. */ | |
112 | extern long long int strtoll __P ((__const char *__nptr, char **__endptr, | |
113 | int __base)); | |
114 | /* Convert a string to an unsigned quadword integer. */ | |
115 | extern unsigned long long int strtoull __P ((__const char *__nptr, | |
116 | char **__endptr, int __base)); | |
117 | #endif /* GCC and use MISC. */ | |
118 | ||
119 | ||
f0bf9cb9 RM |
120 | |
121 | /* The internal entry points for `strtoX' take an extra flag argument | |
122 | saying whether or not to parse locale-dependent number grouping. */ | |
123 | ||
75cd5204 RM |
124 | extern double __strtod_internal __P ((__const char *__nptr, |
125 | char **__endptr, int __group)); | |
126 | extern float __strtof_internal __P ((__const char *__nptr, char **__endptr, | |
127 | int __group)); | |
128 | extern __long_double_t __strtold_internal __P ((__const char *__nptr, | |
129 | char **__endptr, int __group)); | |
130 | extern long int __strtol_internal __P ((__const char *__nptr, char **__endptr, | |
131 | int __base, int __group)); | |
132 | extern unsigned long int __strtoul_internal __P ((__const char *__nptr, | |
f0bf9cb9 | 133 | char **__endptr, int __base, |
75cd5204 RM |
134 | int __group)); |
135 | #ifdef __GNUC__ | |
136 | extern long long int __strtoq_internal __P ((__const char *__nptr, | |
137 | char **__endptr, int __base, | |
138 | int __group)); | |
139 | extern unsigned long long int __strtouq_internal __P ((__const char *__nptr, | |
140 | char **__endptr, | |
141 | int __base, | |
142 | int __group)); | |
143 | #endif /* GCC */ | |
f0bf9cb9 | 144 | |
28f540f4 | 145 | #if defined (__OPTIMIZE__) && __GNUC__ >= 2 |
f0bf9cb9 RM |
146 | /* Define inline functions which call the internal entry points. */ |
147 | ||
148 | extern __inline double strtod (__const char *__nptr, char **__endptr) | |
149 | { return __strtod_internal (__nptr, __endptr, 0); } | |
150 | extern __inline long int strtol (__const char *__nptr, | |
151 | char **__endptr, int __base) | |
152 | { return __strtol_internal (__nptr, __endptr, __base, 0); } | |
153 | extern __inline unsigned long int strtoul (__const char *__nptr, | |
154 | char **__endptr, int __base) | |
155 | { return __strtoul_internal (__nptr, __endptr, __base, 0); } | |
156 | ||
157 | #ifdef __USE_GNU | |
158 | extern __inline float strtof (__const char *__nptr, char **__endptr) | |
159 | { return __strtof_internal (__nptr, __endptr, 0); } | |
160 | extern __inline __long_double_t strtold (__const char *__nptr, char **__endptr) | |
161 | { return __strtold_internal (__nptr, __endptr, 0); } | |
162 | #endif | |
163 | ||
164 | #ifdef __USE_BSD | |
165 | extern __inline long long int strtoq (__const char *__nptr, char **__endptr, | |
166 | int __base) | |
167 | { return __strtoq_internal (__nptr, __endptr, __base, 0); } | |
168 | extern __inline unsigned long long int strtouq (__const char *__nptr, | |
75cd5204 | 169 | char **__endptr, int __base) |
f0bf9cb9 RM |
170 | { return __strtouq_internal (__nptr, __endptr, __base, 0); } |
171 | #endif | |
172 | ||
76060ec0 RM |
173 | #ifdef __USE_MISC |
174 | extern __inline long long int strtoll (__const char *__nptr, char **__endptr, | |
175 | int __base) | |
176 | { return __strtoq_internal (__nptr, __endptr, __base, 0); } | |
177 | extern __inline unsigned long long int strtoull (__const char *__nptr, | |
178 | char **__endptr, int __base) | |
179 | { return __strtouq_internal (__nptr, __endptr, __base, 0); } | |
180 | #endif | |
181 | ||
28f540f4 | 182 | extern __inline double atof (__const char *__nptr) |
f0bf9cb9 | 183 | { return strtod (__nptr, (char **) NULL); } |
28f540f4 RM |
184 | extern __inline int atoi (__const char *__nptr) |
185 | { return (int) strtol (__nptr, (char **) NULL, 10); } | |
186 | extern __inline long int atol (__const char *__nptr) | |
187 | { return strtol (__nptr, (char **) NULL, 10); } | |
188 | #endif /* Optimizing GCC >=2. */ | |
189 | ||
190 | ||
bbed653c RM |
191 | #ifdef __USE_SVID |
192 | /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant | |
193 | digit first. Returns a pointer to static storage overwritten by the | |
194 | next call. */ | |
195 | extern char *l64a __P ((long int __n)); | |
196 | ||
036cc82f RM |
197 | /* Read a number from a string S in base 64 as above. */ |
198 | extern long int a64l __P ((__const char *__s)); | |
bbed653c RM |
199 | #endif |
200 | ||
201 | ||
28f540f4 RM |
202 | /* Return a random integer between 0 and RAND_MAX inclusive. */ |
203 | extern int rand __P ((void)); | |
204 | /* Seed the random number generator with the given number. */ | |
205 | extern void srand __P ((unsigned int __seed)); | |
206 | ||
b20e47cb RM |
207 | #ifdef __USE_BSD |
208 | ||
209 | #include <sys/types.h> /* we need int32_t... */ | |
210 | ||
28f540f4 RM |
211 | /* These are the functions that actually do things. The `random', `srandom', |
212 | `initstate' and `setstate' functions are those from BSD Unices. | |
213 | The `rand' and `srand' functions are required by the ANSI standard. | |
214 | We provide both interfaces to the same random number generator. */ | |
215 | /* Return a random long integer between 0 and RAND_MAX inclusive. */ | |
b20e47cb | 216 | extern int32_t __random __P ((void)); |
9ebb936d RM |
217 | extern int32_t random __P ((void)); |
218 | ||
28f540f4 RM |
219 | /* Seed the random number generator with the given number. */ |
220 | extern void __srandom __P ((unsigned int __seed)); | |
9ebb936d | 221 | extern void srandom __P ((unsigned int __seed)); |
28f540f4 RM |
222 | |
223 | /* Initialize the random number generator to use state buffer STATEBUF, | |
224 | of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16, | |
225 | 32, 64, 128 and 256, the bigger the better; values less than 8 will | |
226 | cause an error and values greater than 256 will be rounded down. */ | |
227 | extern __ptr_t __initstate __P ((unsigned int __seed, __ptr_t __statebuf, | |
228 | size_t __statelen)); | |
9ebb936d RM |
229 | extern __ptr_t initstate __P ((unsigned int __seed, __ptr_t __statebuf, |
230 | size_t __statelen)); | |
231 | ||
28f540f4 RM |
232 | /* Switch the random number generator to state buffer STATEBUF, |
233 | which should have been previously initialized by `initstate'. */ | |
234 | extern __ptr_t __setstate __P ((__ptr_t __statebuf)); | |
28f540f4 RM |
235 | extern __ptr_t setstate __P ((__ptr_t __statebuf)); |
236 | ||
60478656 RM |
237 | |
238 | #ifdef __USE_REENTRANT | |
239 | /* Reentrant versions of the `random' family of functions. | |
240 | These functions all use the following data structure to contain | |
241 | state, rather than global state variables. */ | |
242 | ||
243 | struct random_data | |
244 | { | |
b20e47cb RM |
245 | int32_t *fptr; /* Front pointer. */ |
246 | int32_t *rptr; /* Rear pointer. */ | |
247 | int32_t *state; /* Array of state values. */ | |
60478656 RM |
248 | int rand_type; /* Type of random number generator. */ |
249 | int rand_deg; /* Degree of random number generator. */ | |
250 | int rand_sep; /* Distance between front and rear. */ | |
b20e47cb | 251 | int32_t *end_ptr; /* Pointer behind state table. */ |
60478656 RM |
252 | }; |
253 | ||
b20e47cb RM |
254 | extern int __random_r __P ((struct random_data *__buf, int32_t *__result)); |
255 | extern int random_r __P ((struct random_data *__buf, int32_t *__result)); | |
60478656 RM |
256 | extern int __srandom_r __P ((unsigned int __seed, struct random_data *__buf)); |
257 | extern int __initstate_r __P ((unsigned int __seed, __ptr_t __statebuf, | |
258 | size_t __statelen, struct random_data *__buf)); | |
259 | extern int __setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf)); | |
260 | ||
60478656 RM |
261 | extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf)); |
262 | extern int initstate_r __P ((unsigned int __seed, __ptr_t __statebuf, | |
263 | size_t __statelen, struct random_data *__buf)); | |
264 | extern int setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf)); | |
265 | #endif /* __USE_REENTRANT. */ | |
266 | #endif /* Use BSD. */ | |
267 | ||
268 | ||
269 | #ifdef __USE_SVID | |
270 | /* System V style 48-bit random number generator functions. */ | |
271 | ||
272 | /* Data structure for communication with thread safe versions. */ | |
273 | struct drand48_data | |
274 | { | |
275 | unsigned short int X[3]; /* Current state. */ | |
276 | unsigned short int a[3]; /* Factor in congruential formula. */ | |
277 | unsigned short int c; /* Additive const. in congruential formula. */ | |
278 | unsigned short int old_X[3]; /* Old state. */ | |
279 | int init; /* Flag for initializing. */ | |
280 | }; | |
281 | ||
282 | /* Return non-negative, double-precision floating-point value in [0.0,1.0). */ | |
283 | extern double drand48 __P ((void)); | |
284 | extern int drand48_r __P ((struct drand48_data *__buffer, double *__result)); | |
285 | extern double erand48 __P ((unsigned short int __xsubi[3])); | |
286 | extern int erand48_r __P ((unsigned short int __xsubi[3], | |
287 | struct drand48_data *__buffer, double *__result)); | |
288 | /* Return non-negative, long integer in [0,2^31). */ | |
289 | extern long lrand48 __P ((void)); | |
290 | extern int lrand48_r __P ((struct drand48_data *__buffer, long *__result)); | |
291 | extern long nrand48 __P ((unsigned short int __xsubi[3])); | |
292 | extern int nrand48_r __P ((unsigned short int __xsubi[3], | |
293 | struct drand48_data *__buffer, long *__result)); | |
294 | /* Return signed, long integers in [-2^31,2^31). */ | |
295 | extern long mrand48 __P ((void)); | |
296 | extern int mrand48_r __P ((struct drand48_data *__buffer, long *__result)); | |
297 | extern long jrand48 __P ((unsigned short int __xsubi[3])); | |
298 | extern int jrand48_r __P ((unsigned short int __xsubi[3], | |
299 | struct drand48_data *__buffer, long *__result)); | |
300 | /* Seed random number generator. */ | |
301 | extern void srand48 __P ((long __seedval)); | |
302 | extern int srand48_r __P ((long __seedval, struct drand48_data *__buffer)); | |
303 | extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3])); | |
304 | extern int seed48_r __P ((unsigned short int __seed16v[3], | |
305 | struct drand48_data *__buffer)); | |
306 | extern void lcong48 __P ((unsigned short int __param[7])); | |
307 | extern int lcong48_r __P ((unsigned short int __param[7], | |
308 | struct drand48_data *__buffer)); | |
309 | ||
310 | /* Internal function to compute next state of the generator. */ | |
311 | extern int __drand48_iterate __P ((unsigned short int __xsubi[3], | |
312 | struct drand48_data *__buffer)); | |
313 | #endif /* __USE_SVID. */ | |
28f540f4 RM |
314 | |
315 | ||
316 | /* Allocate SIZE bytes of memory. */ | |
317 | extern __ptr_t malloc __P ((size_t __size)); | |
318 | /* Re-allocate the previously allocated block | |
319 | in __ptr_t, making the new block SIZE bytes long. */ | |
320 | extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size)); | |
321 | /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ | |
322 | extern __ptr_t calloc __P ((size_t __nmemb, size_t __size)); | |
323 | /* Free a block allocated by `malloc', `realloc' or `calloc'. */ | |
324 | extern void free __P ((__ptr_t __ptr)); | |
325 | ||
326 | #ifdef __USE_MISC | |
327 | /* Free a block. An alias for `free'. (Sun Unices). */ | |
328 | extern void cfree __P ((__ptr_t __ptr)); | |
329 | #endif /* Use misc. */ | |
330 | ||
331 | #if defined(__USE_GNU) || defined(__USE_BSD) || defined(__USE_MISC) | |
332 | #include <alloca.h> | |
333 | #endif /* Use GNU, BSD, or misc. */ | |
334 | ||
335 | #ifdef __USE_BSD | |
336 | /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */ | |
337 | extern __ptr_t valloc __P ((size_t __size)); | |
338 | #endif | |
339 | ||
340 | ||
341 | /* Abort execution and generate a core-dump. */ | |
342 | extern void abort __P ((void)) __attribute__ ((__noreturn__)); | |
343 | ||
344 | ||
345 | /* Register a function to be called when `exit' is called. */ | |
346 | extern int atexit __P ((void (*__func) (void))); | |
347 | ||
348 | #ifdef __USE_MISC | |
349 | /* Register a function to be called with the status | |
350 | given to `exit' and the given argument. */ | |
351 | extern int on_exit __P ((void (*__func) (int __status, __ptr_t __arg), | |
352 | __ptr_t __arg)); | |
353 | #endif | |
354 | ||
355 | /* Call all functions registered with `atexit' and `on_exit', | |
356 | in the reverse of the order in which they were registered | |
357 | perform stdio cleanup, and terminate program execution with STATUS. */ | |
358 | extern void exit __P ((int __status)) __attribute__ ((__noreturn__)); | |
359 | ||
360 | ||
361 | /* Return the value of envariable NAME, or NULL if it doesn't exist. */ | |
362 | extern char *getenv __P ((__const char *__name)); | |
363 | ||
d68171ed UD |
364 | /* This function is similar to the above but returns NULL if the |
365 | programs is running with SUID or SGID enabled. */ | |
366 | extern char *__secure_getenv __P ((__const char *__name)); | |
367 | ||
28f540f4 RM |
368 | #ifdef __USE_SVID |
369 | /* The SVID says this is in <stdio.h>, but this seems a better place. */ | |
370 | /* Put STRING, which is of the form "NAME=VALUE", in the environment. | |
371 | If there is no `=', remove NAME from the environment. */ | |
372 | extern int putenv __P ((__const char *__string)); | |
373 | #endif | |
374 | ||
375 | #ifdef __USE_BSD | |
376 | /* Set NAME to VALUE in the environment. | |
377 | If REPLACE is nonzero, overwrite an existing value. */ | |
378 | extern int setenv __P ((__const char *__name, __const char *__value, | |
379 | int __replace)); | |
196980f5 RM |
380 | |
381 | /* Remove the variable NAME from the environment. */ | |
382 | extern void unsetenv __P ((__const char *__name)); | |
28f540f4 RM |
383 | #endif |
384 | ||
f0e44959 UD |
385 | #ifdef __USE_MISC |
386 | /* The `clearenv' was planned to be added to POSIX.1 but probably | |
387 | never made it. Nevertheless the POSIX.9 standard (POSIX bindings | |
388 | for Fortran 77) requires this function. */ | |
389 | extern int clearenv __P ((void)); | |
390 | #endif | |
391 | ||
28f540f4 RM |
392 | /* Execute the given line as a shell command. */ |
393 | extern int system __P ((__const char *__command)); | |
394 | ||
395 | ||
fa0bc87c RM |
396 | #ifdef __USE_GNU |
397 | /* Return a malloc'd string containing the canonical absolute name of the | |
398 | named file. The last file name component need not exist, and may be a | |
399 | symlink to a nonexistent file. */ | |
400 | extern char *canonicalize_file_name __P ((__const char *__name)); | |
401 | #endif | |
402 | ||
403 | #ifdef __USE_BSD | |
404 | /* Return the canonical absolute name of file NAME. The last file name | |
405 | component need not exist, and may be a symlink to a nonexistent file. | |
406 | If RESOLVED is null, the result is malloc'd; otherwise, if the canonical | |
407 | name is PATH_MAX chars or more, returns null with `errno' set to | |
408 | ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the | |
409 | name in RESOLVED. */ | |
410 | extern char *realpath __P ((__const char *__name, char *__resolved)); | |
411 | #endif | |
412 | ||
413 | ||
28f540f4 | 414 | /* Shorthand for type of comparison functions. */ |
60478656 RM |
415 | #ifndef __COMPAR_FN_T |
416 | #define __COMPAR_FN_T | |
28f540f4 | 417 | typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t)); |
60478656 | 418 | #endif |
28f540f4 RM |
419 | |
420 | #ifdef __USE_GNU | |
421 | typedef __compar_fn_t comparison_fn_t; | |
422 | #endif | |
423 | ||
424 | /* Do a binary search for KEY in BASE, which consists of NMEMB elements | |
425 | of SIZE bytes each, using COMPAR to perform the comparisons. */ | |
426 | extern __ptr_t bsearch __P ((__const __ptr_t __key, __const __ptr_t __base, | |
427 | size_t __nmemb, size_t __size, | |
428 | __compar_fn_t __compar)); | |
429 | ||
430 | /* Sort NMEMB elements of BASE, of SIZE bytes each, | |
431 | using COMPAR to perform the comparisons. */ | |
432 | extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size, | |
433 | __compar_fn_t __compar)); | |
434 | ||
435 | ||
28f540f4 | 436 | /* Return the absolute value of X. */ |
7176f4e4 RM |
437 | extern int abs __P ((int __x)) __attribute__ ((__const__)); |
438 | extern long int labs __P ((long int __x)) __attribute__ ((__const__)); | |
59dd8641 RM |
439 | #ifdef __USE_GNU |
440 | extern long long int llabs __P ((long long int __x)) __attribute__ ((__const__)); | |
441 | #endif | |
28f540f4 RM |
442 | |
443 | ||
59dd8641 | 444 | /* Return the `div_t', `ldiv_t' or `lldiv_t' representation |
28f540f4 RM |
445 | of the value of NUMER over DENOM. */ |
446 | /* GCC may have built-ins for these someday. */ | |
7176f4e4 RM |
447 | extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__)); |
448 | extern ldiv_t ldiv __P ((long int __numer, long int __denom)) __attribute__ ((__const__)); | |
59dd8641 RM |
449 | #ifdef __USE_GNU |
450 | extern lldiv_t lldiv __P ((long long int __numer, long long int __denom)) __attribute__ ((__const__)); | |
451 | #endif | |
28f540f4 RM |
452 | |
453 | ||
60478656 RM |
454 | #ifdef __USE_SVID |
455 | /* Convert floating point numbers to strings. The returned values are | |
456 | valid only until another call to the same function. */ | |
457 | ||
458 | /* Convert VALUE to a string with NDIGIT digits and return a pointer to | |
459 | this. Set *DECPT with the position of the decimal character and *SIGN | |
460 | with the sign of the number. */ | |
036cc82f | 461 | char *ecvt __P ((double __value, int __ndigit, int *__decpt, int *__sign)); |
60478656 RM |
462 | |
463 | /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT | |
464 | with the position of the decimal character and *SIGN with the sign of | |
465 | the number. */ | |
036cc82f | 466 | char *fcvt __P ((double __value, int __ndigit, int *__decpt, int *__sign)); |
60478656 RM |
467 | |
468 | /* If possible convert VALUE to a string with NDIGIT significant digits. | |
469 | Otherwise use exponential representation. The resulting string will | |
470 | be written to BUF. */ | |
471 | char *gcvt __P ((double __value, int __ndigit, char *__buf)); | |
472 | ||
2064087b RM |
473 | /* Long double versions of above functions. */ |
474 | char *qecvt __P ((__long_double_t __value, int __ndigit, int *__decpt, | |
036cc82f | 475 | int *__sign)); |
2064087b | 476 | char *qfcvt __P ((__long_double_t __value, int __ndigit, int *__decpt, |
036cc82f | 477 | int *__sign)); |
2064087b RM |
478 | char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf)); |
479 | ||
480 | ||
481 | #ifdef __USE_REENTRANT | |
60478656 RM |
482 | /* Reentrant version of the functions above which provide their own |
483 | buffers. */ | |
036cc82f | 484 | int ecvt_r __P ((double __value, int __ndigit, int *__decpt, int *__sign, |
c2216480 | 485 | char *__buf, size_t __len)); |
036cc82f | 486 | int fcvt_r __P ((double __value, int __ndigit, int *__decpt, int *__sign, |
c2216480 | 487 | char *__buf, size_t __len)); |
2064087b RM |
488 | |
489 | int qecvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt, | |
036cc82f | 490 | int *__sign, char *__buf, size_t __len)); |
2064087b | 491 | int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt, |
036cc82f | 492 | int *__sign, char *__buf, size_t __len)); |
2064087b | 493 | #endif |
60478656 RM |
494 | #endif |
495 | ||
496 | ||
28f540f4 RM |
497 | /* Return the length of the multibyte character |
498 | in S, which is no longer than N. */ | |
499 | extern int mblen __P ((__const char *__s, size_t __n)); | |
500 | /* Return the length of the given multibyte character, | |
501 | putting its `wchar_t' representation in *PWC. */ | |
036cc82f | 502 | extern int mbtowc __P ((wchar_t *__pwc, __const char *__s, size_t __n)); |
28f540f4 RM |
503 | /* Put the multibyte character represented |
504 | by WCHAR in S, returning its length. */ | |
505 | extern int wctomb __P ((char *__s, wchar_t __wchar)); | |
506 | ||
507 | #if defined (__OPTIMIZE__) && __GNUC__ >= 2 | |
508 | extern __inline int mblen (__const char *__s, size_t __n) | |
509 | { return mbtowc ((wchar_t *) NULL, __s, __n); } | |
510 | #endif /* Optimizing GCC >=2. */ | |
511 | ||
512 | ||
513 | /* Convert a multibyte string to a wide char string. */ | |
036cc82f | 514 | extern size_t mbstowcs __P ((wchar_t *__pwcs, __const char *__s, size_t __n)); |
28f540f4 | 515 | /* Convert a wide char string to multibyte string. */ |
036cc82f | 516 | extern size_t wcstombs __P ((char *__s, __const wchar_t *__pwcs, size_t __n)); |
28f540f4 RM |
517 | |
518 | ||
857fa1b8 RM |
519 | #ifdef __USE_SVID |
520 | /* Determine whether the string value of RESPONSE matches the affirmation | |
521 | or negative response expression as specified by the LC_MESSAGES category | |
522 | in the program's current locale. Returns 1 if affirmative, 0 if | |
523 | negative, and -1 if not matching. */ | |
524 | extern int rpmatch __P ((__const char *__response)); | |
525 | #endif | |
526 | ||
527 | ||
2064087b RM |
528 | #ifdef __USE_MISC |
529 | /* Parse comma separated suboption from *OPTIONP and match against | |
530 | strings in TOKENS. If found return index and set *VALUEP to | |
531 | optional value introduced by an equal sign. If the suboption is | |
532 | not part of TOKENS return in *VALUEP beginning of unknown | |
533 | suboption. On exit *OPTIONP is set to the beginning of the next | |
534 | otken or at the terminating NUL character. */ | |
535 | extern int getsubopt __P ((char **__optionp, __const char *__const *__tokens, | |
536 | char **__valuep)); | |
537 | #endif | |
538 | ||
539 | ||
28f540f4 RM |
540 | __END_DECLS |
541 | ||
542 | #endif /* stdlib.h */ |