]> sourceware.org Git - glibc.git/blame - stdlib/stdlib.h
Update.
[glibc.git] / stdlib / stdlib.h
CommitLineData
19361cb7 1/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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/*
377a515b 20 * ISO C Standard: 4.10 GENERAL UTILITIES <stdlib.h>
28f540f4
RM
21 */
22
23#ifndef _STDLIB_H
28f540f4 24#define _STDLIB_H 1
5107cf1d 25
28f540f4
RM
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
28f540f4
RM
34__BEGIN_DECLS
35
36/* Returned by `div'. */
37typedef struct
38 {
39 int quot; /* Quotient. */
40 int rem; /* Remainder. */
41 } div_t;
42
43/* Returned by `ldiv'. */
44typedef struct
45 {
46 long int quot; /* Quotient. */
47 long int rem; /* Remainder. */
48 } ldiv_t;
49
377a515b 50#ifdef __USE_ISOC9X
59dd8641
RM
51/* Returned by `lldiv'. */
52typedef struct
53 {
54 long long int quot; /* Quotient. */
55 long long int rem; /* Remainder. */
56 } lldiv_t;
57#endif
58
28f540f4
RM
59
60/* The largest number rand will return (same as INT_MAX). */
61#define RAND_MAX 2147483647
62
63
64/* We define these the same for all machines.
65 Changes from this to the outside world should be done in `_exit'. */
66#define EXIT_FAILURE 1 /* Failing exit status. */
67#define EXIT_SUCCESS 0 /* Successful exit status. */
68
69
0200214b
RM
70/* Maximum length of a multibyte character in the current locale. */
71#define MB_CUR_MAX (__ctype_get_mb_cur_max ())
72extern int __ctype_get_mb_cur_max __P ((void));
28f540f4
RM
73
74
75/* Convert a string to a floating-point number. */
76extern double atof __P ((__const char *__nptr));
77/* Convert a string to an integer. */
78extern int atoi __P ((__const char *__nptr));
79/* Convert a string to a long integer. */
80extern long int atol __P ((__const char *__nptr));
81
2f6d1f1b 82#if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
7cc27f44
UD
83/* These functions will part of the standard C library in ISO C 9X. */
84extern long long int atoll __P ((__const char *__nptr));
85#endif
86
28f540f4 87/* Convert a string to a floating-point number. */
2f6d1f1b
UD
88extern double strtod __P ((__const char *__restrict __nptr,
89 char **__restrict __endptr));
28f540f4
RM
90
91#ifdef __USE_GNU
92/* Likewise for `float' and `long double' sizes of floating-point numbers. */
2f6d1f1b
UD
93extern float strtof __P ((__const char *__restrict __nptr,
94 char **__restrict __endptr));
95
96extern __long_double_t strtold __P ((__const char *__restrict __nptr,
97 char **__restrict __endptr));
28f540f4
RM
98#endif
99
100/* Convert a string to a long integer. */
2f6d1f1b
UD
101extern long int strtol __P ((__const char *__restrict __nptr,
102 char **__restrict __endptr, int __base));
28f540f4 103/* Convert a string to an unsigned long integer. */
2f6d1f1b
UD
104extern unsigned long int strtoul __P ((__const char *__restrict __nptr,
105 char **__restrict __endptr,
106 int __base));
28f540f4 107
2f6d1f1b 108#if defined __GNUC__ && defined __USE_BSD
28f540f4 109/* Convert a string to a quadword integer. */
2f6d1f1b
UD
110extern long long int strtoq __P ((__const char *__restrict __nptr,
111 char **__restrict __endptr, int __base));
28f540f4 112/* Convert a string to an unsigned quadword integer. */
2f6d1f1b
UD
113extern unsigned long long int strtouq __P ((__const char *__restrict __nptr,
114 char **__restrict __endptr,
115 int __base));
28f540f4
RM
116#endif /* GCC and use BSD. */
117
2f6d1f1b 118#if defined __USE_ISOC9X || (defined __GNUC__ && defined __USE_MISC)
7cc27f44
UD
119/* These functions will part of the standard C library in ISO C 9X. */
120
76060ec0 121/* Convert a string to a quadword integer. */
2f6d1f1b
UD
122extern long long int strtoll __P ((__const char *__restrict __nptr,
123 char **__restrict __endptr, int __base));
76060ec0 124/* Convert a string to an unsigned quadword integer. */
2f6d1f1b
UD
125extern unsigned long long int strtoull __P ((__const char *__restrict __nptr,
126 char **__restrict __endptr,
127 int __base));
128#endif /* ISO C 9X or GCC and use MISC. */
76060ec0
RM
129
130
0501d603
UD
131#ifdef __USE_GNU
132/* The concept of one static locale per category is not very well
133 thought out. Many applications will need to process its data using
134 information from several different locales. Another application is
135 the implementation of the internationalization handling in the
136 upcoming ISO C++ standard library. To support this another set of
137 the functions using locale data exist which have an additional
138 argument.
139
140 Attention: all these functions are *not* standardized in any form.
141 This is a proof-of-concept implementation. */
142
143/* Structure for reentrant locale using functions. This is an
144 (almost) opaque type for the user level programs. */
145# include <xlocale.h>
146
147/* Special versions of the functions above which take the locale to
148 use as an additional parameter. */
149extern long int __strtol_l __P ((__const char *__restrict __nptr,
150 char **__restrict __endptr, int __base,
151 __locale_t __loc));
152
153extern unsigned long int __strtoul_l __P ((__const char *__restrict __nptr,
154 char **__restrict __endptr,
155 int __base, __locale_t __loc));
156
157extern long long int __strtoll_l __P ((__const char *__restrict __nptr,
158 char **__restrict __endptr, int __base,
159 __locale_t __loc));
160
161extern unsigned long long int __strtoull_l __P ((__const char *__restrict
162 __nptr,
163 char **__restrict __endptr,
164 int __base,
165 __locale_t __loc));
166
167extern double __strtod_l __P ((__const char *__restrict __nptr,
168 char **__restrict __endptr, __locale_t __loc));
169
170extern float __strtof_l __P ((__const char *__restrict __nptr,
171 char **__restrict __endptr, __locale_t __loc));
172
173extern __long_double_t __strtold_l __P ((__const char *__restrict __nptr,
174 char **__restrict __endptr,
175 __locale_t __loc));
176#endif /* GNU */
177
f0bf9cb9
RM
178
179/* The internal entry points for `strtoX' take an extra flag argument
180 saying whether or not to parse locale-dependent number grouping. */
181
2f6d1f1b
UD
182extern double __strtod_internal __P ((__const char *__restrict __nptr,
183 char **__restrict __endptr,
184 int __group));
185extern float __strtof_internal __P ((__const char *__restrict __nptr,
186 char **__restrict __endptr, int __group));
187extern __long_double_t __strtold_internal __P ((__const char *
188 __restrict __nptr,
189 char **__restrict __endptr,
190 int __group));
191extern long int __strtol_internal __P ((__const char *__restrict __nptr,
192 char **__restrict __endptr,
75cd5204 193 int __base, int __group));
2f6d1f1b
UD
194extern unsigned long int __strtoul_internal __P ((__const char *
195 __restrict __nptr,
196 char **__restrict __endptr,
197 int __base, int __group));
75cd5204 198#ifdef __GNUC__
2f6d1f1b
UD
199extern long long int __strtoll_internal __P ((__const char *__restrict __nptr,
200 char **__restrict __endptr,
201 int __base, int __group));
202extern unsigned long long int __strtoull_internal __P ((__const char *
203 __restrict __nptr,
204 char **
205 __restrict __endptr,
206 int __base,
207 int __group));
75cd5204 208#endif /* GCC */
f0bf9cb9 209
377a515b 210#if defined __OPTIMIZE__ && __GNUC__ >= 2
f0bf9cb9
RM
211/* Define inline functions which call the internal entry points. */
212
2604afb1
UD
213extern __inline double
214strtod (__const char *__restrict __nptr, char **__restrict __endptr)
215{
216 return __strtod_internal (__nptr, __endptr, 0);
217}
218extern __inline long int
219strtol (__const char *__restrict __nptr, char **__restrict __endptr,
220 int __base)
221{
222 return __strtol_internal (__nptr, __endptr, __base, 0);
223}
224extern __inline unsigned long int
225strtoul (__const char *__restrict __nptr, char **__restrict __endptr,
226 int __base)
227{
228 return __strtoul_internal (__nptr, __endptr, __base, 0);
229}
230
231# ifdef __USE_GNU
232extern __inline float
233strtof (__const char *__restrict __nptr, char **__restrict __endptr)
234{
235 return __strtof_internal (__nptr, __endptr, 0);
236}
237extern __inline __long_double_t
238strtold (__const char *__restrict __nptr, char **__restrict __endptr)
239{
240 return __strtold_internal (__nptr, __endptr, 0);
241}
242# endif
243
244# ifdef __USE_BSD
245extern __inline long long int
246strtoq (__const char *__restrict __nptr, char **__restrict __endptr,
247 int __base)
248{
249 return __strtoll_internal (__nptr, __endptr, __base, 0);
250}
251extern __inline unsigned long long int
252strtouq (__const char *__restrict __nptr, char **__restrict __endptr,
253 int __base)
254{
255 return __strtoull_internal (__nptr, __endptr, __base, 0);
256}
257# endif
258
259# if defined __USE_MISC || defined __USE_ISOC9X
260extern __inline long long int
261strtoll (__const char *__restrict __nptr, char **__restrict __endptr,
262 int __base)
263{
264 return __strtoll_internal (__nptr, __endptr, __base, 0);
265}
266extern __inline unsigned long long int
267strtoull (__const char * __restrict __nptr, char **__restrict __endptr,
268 int __base)
269{
270 return __strtoull_internal (__nptr, __endptr, __base, 0);
271}
272# endif
273
274extern __inline double
275atof (__const char *__nptr)
276{
277 return strtod (__nptr, (char **) NULL);
278}
279extern __inline int
280atoi (__const char *__nptr)
281{
282 return (int) strtol (__nptr, (char **) NULL, 10);
283}
284extern __inline long int
285atol (__const char *__nptr)
286{
287 return strtol (__nptr, (char **) NULL, 10);
288}
289
290# if defined __USE_MISC || defined __USE_ISOC9X
291extern __inline long long int
292atoll (__const char *__nptr)
293{
294 return strtoll (__nptr, (char **) NULL, 10);
295}
296# endif
28f540f4
RM
297#endif /* Optimizing GCC >=2. */
298
299
377a515b 300#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
bbed653c
RM
301/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
302 digit first. Returns a pointer to static storage overwritten by the
303 next call. */
304extern char *l64a __P ((long int __n));
305
036cc82f
RM
306/* Read a number from a string S in base 64 as above. */
307extern long int a64l __P ((__const char *__s));
28f540f4 308
b20e47cb
RM
309
310#include <sys/types.h> /* we need int32_t... */
311
28f540f4
RM
312/* These are the functions that actually do things. The `random', `srandom',
313 `initstate' and `setstate' functions are those from BSD Unices.
314 The `rand' and `srand' functions are required by the ANSI standard.
315 We provide both interfaces to the same random number generator. */
316/* Return a random long integer between 0 and RAND_MAX inclusive. */
b20e47cb 317extern int32_t __random __P ((void));
9ebb936d
RM
318extern int32_t random __P ((void));
319
28f540f4
RM
320/* Seed the random number generator with the given number. */
321extern void __srandom __P ((unsigned int __seed));
9ebb936d 322extern void srandom __P ((unsigned int __seed));
28f540f4
RM
323
324/* Initialize the random number generator to use state buffer STATEBUF,
325 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
326 32, 64, 128 and 256, the bigger the better; values less than 8 will
327 cause an error and values greater than 256 will be rounded down. */
328extern __ptr_t __initstate __P ((unsigned int __seed, __ptr_t __statebuf,
329 size_t __statelen));
9ebb936d
RM
330extern __ptr_t initstate __P ((unsigned int __seed, __ptr_t __statebuf,
331 size_t __statelen));
332
28f540f4
RM
333/* Switch the random number generator to state buffer STATEBUF,
334 which should have been previously initialized by `initstate'. */
335extern __ptr_t __setstate __P ((__ptr_t __statebuf));
28f540f4
RM
336extern __ptr_t setstate __P ((__ptr_t __statebuf));
337
60478656 338
2604afb1 339# ifdef __USE_MISC
60478656
RM
340/* Reentrant versions of the `random' family of functions.
341 These functions all use the following data structure to contain
342 state, rather than global state variables. */
343
344struct random_data
345 {
b20e47cb
RM
346 int32_t *fptr; /* Front pointer. */
347 int32_t *rptr; /* Rear pointer. */
348 int32_t *state; /* Array of state values. */
60478656
RM
349 int rand_type; /* Type of random number generator. */
350 int rand_deg; /* Degree of random number generator. */
351 int rand_sep; /* Distance between front and rear. */
b20e47cb 352 int32_t *end_ptr; /* Pointer behind state table. */
60478656
RM
353 };
354
b20e47cb
RM
355extern int __random_r __P ((struct random_data *__buf, int32_t *__result));
356extern int random_r __P ((struct random_data *__buf, int32_t *__result));
8a523922 357
60478656 358extern int __srandom_r __P ((unsigned int __seed, struct random_data *__buf));
8a523922
UD
359extern int srandom_r __P ((unsigned int __seed, struct random_data *__buf));
360
60478656
RM
361extern int __initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
362 size_t __statelen, struct random_data *__buf));
60478656
RM
363extern int initstate_r __P ((unsigned int __seed, __ptr_t __statebuf,
364 size_t __statelen, struct random_data *__buf));
8a523922
UD
365
366extern int __setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
60478656 367extern int setstate_r __P ((__ptr_t __statebuf, struct random_data *__buf));
2604afb1 368# endif /* Use misc. */
19361cb7 369#endif /* Use SVID || extended X/Open. */
60478656
RM
370
371
2c6fe0bd
UD
372/* Return a random integer between 0 and RAND_MAX inclusive. */
373extern int rand __P ((void));
374/* Seed the random number generator with the given number. */
375extern void srand __P ((unsigned int __seed));
376
19361cb7 377#ifdef __USE_MISC
47707456
UD
378/* Reentrant interface according to POSIX.1. */
379extern int __rand_r __P ((unsigned int *__seed));
380extern int rand_r __P ((unsigned int *__seed));
381#endif
382
2c6fe0bd 383
377a515b 384#if defined __USE_SVID || defined __USE_XOPEN
60478656
RM
385/* System V style 48-bit random number generator functions. */
386
2c6fe0bd
UD
387/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
388extern double drand48 __P ((void));
389extern double erand48 __P ((unsigned short int __xsubi[3]));
390
391/* Return non-negative, long integer in [0,2^31). */
b4012b75
UD
392extern long int lrand48 __P ((void));
393extern long int nrand48 __P ((unsigned short int __xsubi[3]));
2c6fe0bd
UD
394
395/* Return signed, long integers in [-2^31,2^31). */
b4012b75
UD
396extern long int mrand48 __P ((void));
397extern long int jrand48 __P ((unsigned short int __xsubi[3]));
2c6fe0bd
UD
398
399/* Seed random number generator. */
b4012b75 400extern void srand48 __P ((long int __seedval));
2c6fe0bd
UD
401extern unsigned short int *seed48 __P ((unsigned short int __seed16v[3]));
402extern void lcong48 __P ((unsigned short int __param[7]));
403
60478656
RM
404/* Data structure for communication with thread safe versions. */
405struct drand48_data
406 {
407 unsigned short int X[3]; /* Current state. */
408 unsigned short int a[3]; /* Factor in congruential formula. */
409 unsigned short int c; /* Additive const. in congruential formula. */
410 unsigned short int old_X[3]; /* Old state. */
411 int init; /* Flag for initializing. */
412 };
413
19361cb7 414#ifdef __USE_MISC
60478656 415/* Return non-negative, double-precision floating-point value in [0.0,1.0). */
60478656 416extern int drand48_r __P ((struct drand48_data *__buffer, double *__result));
47f13fd4
UD
417extern int __erand48_r __P ((unsigned short int __xsubi[3],
418 struct drand48_data *__buffer, double *__result));
60478656
RM
419extern int erand48_r __P ((unsigned short int __xsubi[3],
420 struct drand48_data *__buffer, double *__result));
2c6fe0bd 421
60478656 422/* Return non-negative, long integer in [0,2^31). */
b4012b75 423extern int lrand48_r __P ((struct drand48_data *__buffer, long int *__result));
47f13fd4
UD
424extern int __nrand48_r __P ((unsigned short int __xsubi[3],
425 struct drand48_data *__buffer,
426 long int *__result));
60478656 427extern int nrand48_r __P ((unsigned short int __xsubi[3],
b4012b75 428 struct drand48_data *__buffer, long int *__result));
2c6fe0bd 429
60478656 430/* Return signed, long integers in [-2^31,2^31). */
b4012b75 431extern int mrand48_r __P ((struct drand48_data *__buffer, long int *__result));
47f13fd4
UD
432extern int __jrand48_r __P ((unsigned short int __xsubi[3],
433 struct drand48_data *__buffer,
434 long int *__result));
60478656 435extern int jrand48_r __P ((unsigned short int __xsubi[3],
b4012b75 436 struct drand48_data *__buffer, long int *__result));
2c6fe0bd 437
60478656 438/* Seed random number generator. */
47f13fd4
UD
439extern int __srand48_r __P ((long int __seedval,
440 struct drand48_data *__buffer));
b4012b75 441extern int srand48_r __P ((long int __seedval, struct drand48_data *__buffer));
47f13fd4
UD
442
443extern int __seed48_r __P ((unsigned short int __seed16v[3],
444 struct drand48_data *__buffer));
60478656
RM
445extern int seed48_r __P ((unsigned short int __seed16v[3],
446 struct drand48_data *__buffer));
47f13fd4
UD
447
448extern int __lcong48_r __P ((unsigned short int __param[7],
449 struct drand48_data *__buffer));
60478656
RM
450extern int lcong48_r __P ((unsigned short int __param[7],
451 struct drand48_data *__buffer));
19361cb7 452#endif /* Use misc. */
60478656
RM
453
454/* Internal function to compute next state of the generator. */
455extern int __drand48_iterate __P ((unsigned short int __xsubi[3],
456 struct drand48_data *__buffer));
2c6fe0bd 457#endif /* Use SVID or X/Open. */
28f540f4
RM
458
459
460/* Allocate SIZE bytes of memory. */
461extern __ptr_t malloc __P ((size_t __size));
462/* Re-allocate the previously allocated block
463 in __ptr_t, making the new block SIZE bytes long. */
464extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size));
465/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
466extern __ptr_t calloc __P ((size_t __nmemb, size_t __size));
467/* Free a block allocated by `malloc', `realloc' or `calloc'. */
468extern void free __P ((__ptr_t __ptr));
469
470#ifdef __USE_MISC
471/* Free a block. An alias for `free'. (Sun Unices). */
472extern void cfree __P ((__ptr_t __ptr));
473#endif /* Use misc. */
474
377a515b 475#if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
2604afb1 476# include <alloca.h>
28f540f4
RM
477#endif /* Use GNU, BSD, or misc. */
478
377a515b 479#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
28f540f4
RM
480/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
481extern __ptr_t valloc __P ((size_t __size));
482#endif
483
484
485/* Abort execution and generate a core-dump. */
486extern void abort __P ((void)) __attribute__ ((__noreturn__));
487
488
489/* Register a function to be called when `exit' is called. */
490extern int atexit __P ((void (*__func) (void)));
491
492#ifdef __USE_MISC
493/* Register a function to be called with the status
494 given to `exit' and the given argument. */
10dc2a90
UD
495extern int __on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
496 __ptr_t __arg));
28f540f4
RM
497extern int on_exit __P ((void (*__func) (int __status, __ptr_t __arg),
498 __ptr_t __arg));
499#endif
500
501/* Call all functions registered with `atexit' and `on_exit',
502 in the reverse of the order in which they were registered
503 perform stdio cleanup, and terminate program execution with STATUS. */
504extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
505
506
507/* Return the value of envariable NAME, or NULL if it doesn't exist. */
508extern char *getenv __P ((__const char *__name));
509
d68171ed
UD
510/* This function is similar to the above but returns NULL if the
511 programs is running with SUID or SGID enabled. */
512extern char *__secure_getenv __P ((__const char *__name));
513
377a515b 514#if defined __USE_SVID || defined __USE_XOPEN
28f540f4
RM
515/* The SVID says this is in <stdio.h>, but this seems a better place. */
516/* Put STRING, which is of the form "NAME=VALUE", in the environment.
517 If there is no `=', remove NAME from the environment. */
518extern int putenv __P ((__const char *__string));
519#endif
520
521#ifdef __USE_BSD
522/* Set NAME to VALUE in the environment.
523 If REPLACE is nonzero, overwrite an existing value. */
524extern int setenv __P ((__const char *__name, __const char *__value,
525 int __replace));
196980f5
RM
526
527/* Remove the variable NAME from the environment. */
528extern void unsetenv __P ((__const char *__name));
28f540f4
RM
529#endif
530
f0e44959
UD
531#ifdef __USE_MISC
532/* The `clearenv' was planned to be added to POSIX.1 but probably
533 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
534 for Fortran 77) requires this function. */
22d57dd3 535extern int __clearenv __P ((void));
f0e44959
UD
536extern int clearenv __P ((void));
537#endif
538
2c6fe0bd 539
377a515b 540#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
2c6fe0bd
UD
541/* Generate a unique temporary file name from TEMPLATE.
542 The last six characters of TEMPLATE must be "XXXXXX";
543 they are replaced with a string that makes the file name unique.
544 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
545extern char *mktemp __P ((char *__template));
546
547/* Generate a unique temporary file name from TEMPLATE.
548 The last six characters of TEMPLATE must be "XXXXXX";
549 they are replaced with a string that makes the filename unique.
550 Returns a file descriptor open on the file for reading and writing,
551 or -1 if it cannot create a uniquely-named file. */
552extern int mkstemp __P ((char *__template));
553#endif
554
555
28f540f4
RM
556/* Execute the given line as a shell command. */
557extern int system __P ((__const char *__command));
558
559
fa0bc87c
RM
560#ifdef __USE_GNU
561/* Return a malloc'd string containing the canonical absolute name of the
562 named file. The last file name component need not exist, and may be a
563 symlink to a nonexistent file. */
564extern char *canonicalize_file_name __P ((__const char *__name));
565#endif
566
377a515b 567#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
fa0bc87c
RM
568/* Return the canonical absolute name of file NAME. The last file name
569 component need not exist, and may be a symlink to a nonexistent file.
570 If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
571 name is PATH_MAX chars or more, returns null with `errno' set to
572 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
573 name in RESOLVED. */
574extern char *realpath __P ((__const char *__name, char *__resolved));
575#endif
576
577
28f540f4 578/* Shorthand for type of comparison functions. */
60478656 579#ifndef __COMPAR_FN_T
2604afb1 580# define __COMPAR_FN_T
28f540f4
RM
581typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
582
2604afb1 583# ifdef __USE_GNU
28f540f4 584typedef __compar_fn_t comparison_fn_t;
2604afb1 585# endif
28f540f4
RM
586#endif
587
588/* Do a binary search for KEY in BASE, which consists of NMEMB elements
589 of SIZE bytes each, using COMPAR to perform the comparisons. */
590extern __ptr_t bsearch __P ((__const __ptr_t __key, __const __ptr_t __base,
591 size_t __nmemb, size_t __size,
592 __compar_fn_t __compar));
593
594/* Sort NMEMB elements of BASE, of SIZE bytes each,
595 using COMPAR to perform the comparisons. */
596extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
597 __compar_fn_t __compar));
598
599
28f540f4 600/* Return the absolute value of X. */
7176f4e4
RM
601extern int abs __P ((int __x)) __attribute__ ((__const__));
602extern long int labs __P ((long int __x)) __attribute__ ((__const__));
2604afb1 603#ifdef __USE_ISOC9X
2f6d1f1b
UD
604extern long long int llabs __P ((long long int __x))
605 __attribute__ ((__const__));
59dd8641 606#endif
28f540f4
RM
607
608
59dd8641 609/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
28f540f4
RM
610 of the value of NUMER over DENOM. */
611/* GCC may have built-ins for these someday. */
7176f4e4 612extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
2f6d1f1b
UD
613extern ldiv_t ldiv __P ((long int __numer, long int __denom))
614 __attribute__ ((__const__));
615#ifdef __USE_ISOC9X
616extern lldiv_t lldiv __P ((long long int __numer, long long int __denom))
617 __attribute__ ((__const__));
59dd8641 618#endif
28f540f4
RM
619
620
377a515b 621#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
60478656
RM
622/* Convert floating point numbers to strings. The returned values are
623 valid only until another call to the same function. */
624
625/* Convert VALUE to a string with NDIGIT digits and return a pointer to
626 this. Set *DECPT with the position of the decimal character and *SIGN
627 with the sign of the number. */
2c6fe0bd
UD
628extern char *ecvt __P ((double __value, int __ndigit, int *__decpt,
629 int *__sign));
60478656
RM
630
631/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
632 with the position of the decimal character and *SIGN with the sign of
633 the number. */
2c6fe0bd
UD
634extern char *fcvt __P ((double __value, int __ndigit, int *__decpt,
635 int *__sign));
60478656
RM
636
637/* If possible convert VALUE to a string with NDIGIT significant digits.
638 Otherwise use exponential representation. The resulting string will
639 be written to BUF. */
2c6fe0bd 640extern char *gcvt __P ((double __value, int __ndigit, char *__buf));
60478656 641
2064087b 642/* Long double versions of above functions. */
2c6fe0bd
UD
643extern char *qecvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
644 int *__sign));
645extern char *qfcvt __P ((__long_double_t __value, int __ndigit, int *__decpt,
646 int *__sign));
647extern char *qgcvt __P ((__long_double_t __value, int __ndigit, char *__buf));
2064087b
RM
648
649
19361cb7 650#ifdef __USE_MISC
60478656
RM
651/* Reentrant version of the functions above which provide their own
652 buffers. */
2c6fe0bd
UD
653extern int ecvt_r __P ((double __value, int __ndigit, int *__decpt,
654 int *__sign, char *__buf, size_t __len));
655extern int fcvt_r __P ((double __value, int __ndigit, int *__decpt,
656 int *__sign, char *__buf, size_t __len));
657
658extern int qecvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
659 int *__sign, char *__buf, size_t __len));
660extern int qfcvt_r __P ((__long_double_t __value, int __ndigit, int *__decpt,
661 int *__sign, char *__buf, size_t __len));
19361cb7 662#endif /* misc */
2c6fe0bd 663#endif /* use MISC || use X/Open Unix */
60478656
RM
664
665
28f540f4
RM
666/* Return the length of the multibyte character
667 in S, which is no longer than N. */
668extern int mblen __P ((__const char *__s, size_t __n));
669/* Return the length of the given multibyte character,
670 putting its `wchar_t' representation in *PWC. */
2f6d1f1b
UD
671extern int mbtowc __P ((wchar_t *__restrict __pwc,
672 __const char *__restrict __s, size_t __n));
28f540f4
RM
673/* Put the multibyte character represented
674 by WCHAR in S, returning its length. */
675extern int wctomb __P ((char *__s, wchar_t __wchar));
676
377a515b 677#if defined __OPTIMIZE__ && __GNUC__ >= 2
2604afb1
UD
678extern __inline int
679mblen (__const char *__s, size_t __n)
680{
681 return mbtowc ((wchar_t *) NULL, __s, __n);
682}
28f540f4
RM
683#endif /* Optimizing GCC >=2. */
684
685
686/* Convert a multibyte string to a wide char string. */
2f6d1f1b
UD
687extern size_t mbstowcs __P ((wchar_t *__restrict __pwcs,
688 __const char *__restrict __s, size_t __n));
28f540f4 689/* Convert a wide char string to multibyte string. */
2f6d1f1b
UD
690extern size_t wcstombs __P ((char *__restrict __s,
691 __const wchar_t *__restrict __pwcs, size_t __n));
28f540f4
RM
692
693
857fa1b8
RM
694#ifdef __USE_SVID
695/* Determine whether the string value of RESPONSE matches the affirmation
696 or negative response expression as specified by the LC_MESSAGES category
697 in the program's current locale. Returns 1 if affirmative, 0 if
698 negative, and -1 if not matching. */
699extern int rpmatch __P ((__const char *__response));
700#endif
701
702
2c6fe0bd 703#ifdef __USE_XOPEN_EXTENDED
2064087b
RM
704/* Parse comma separated suboption from *OPTIONP and match against
705 strings in TOKENS. If found return index and set *VALUEP to
706 optional value introduced by an equal sign. If the suboption is
707 not part of TOKENS return in *VALUEP beginning of unknown
708 suboption. On exit *OPTIONP is set to the beginning of the next
2604afb1 709 token or at the terminating NUL character. */
2064087b
RM
710extern int getsubopt __P ((char **__optionp, __const char *__const *__tokens,
711 char **__valuep));
712#endif
713
714
2c6fe0bd
UD
715#ifdef __USE_XOPEN
716
717/* Setup DES tables according KEY. */
718extern void setkey __P ((__const char *__key));
719#endif
720
721
28f540f4
RM
722__END_DECLS
723
724#endif /* stdlib.h */
This page took 0.147316 seconds and 5 git commands to generate.