GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / sysroot / usr / include / stdlib.h
blobf4c4fd22d2ad6fc194e114724bb22718be881714
1 /* Copyright (C) 1991-2007, 2009 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 Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
20 * ISO C99 Standard: 7.20 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 # ifdef __UCLIBC_HAS_WCHAR__
31 # define __need_wchar_t
32 # endif
33 # define __need_NULL
34 #endif
35 #include <stddef.h>
37 __BEGIN_DECLS
39 #ifndef __need_malloc_and_calloc
40 #define _STDLIB_H 1
42 #if defined __USE_XOPEN && !defined _SYS_WAIT_H
43 /* XPG requires a few symbols from <sys/wait.h> being defined. */
44 # include <bits/waitflags.h>
45 # include <bits/waitstatus.h>
47 # ifdef __USE_BSD
49 /* Lots of hair to allow traditional BSD use of `union wait'
50 as well as POSIX.1 use of `int' for the status word. */
52 # if defined __GNUC__ && !defined __cplusplus
53 # define __WAIT_INT(status) \
54 (__extension__ (((union { __typeof(status) __in; int __i; }) \
55 { .__in = (status) }).__i))
56 # else
57 # define __WAIT_INT(status) (*(int *) &(status))
58 # endif
60 /* This is the type of the argument to `wait'. The funky union
61 causes redeclarations with either `int *' or `union wait *' to be
62 allowed without complaint. __WAIT_STATUS_DEFN is the type used in
63 the actual function definitions. */
65 # if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus
66 # define __WAIT_STATUS void *
67 # define __WAIT_STATUS_DEFN void *
68 # else
69 /* This works in GCC 2.6.1 and later. */
70 typedef union
72 union wait *__uptr;
73 int *__iptr;
74 } __WAIT_STATUS __attribute__ ((__transparent_union__));
75 # define __WAIT_STATUS_DEFN int *
76 # endif
78 # else /* Don't use BSD. */
80 # define __WAIT_INT(status) (status)
81 # define __WAIT_STATUS int *
82 # define __WAIT_STATUS_DEFN int *
84 # endif /* Use BSD. */
86 /* Define the macros <sys/wait.h> also would define this way. */
87 # define WEXITSTATUS(status) __WEXITSTATUS (__WAIT_INT (status))
88 # define WTERMSIG(status) __WTERMSIG (__WAIT_INT (status))
89 # define WSTOPSIG(status) __WSTOPSIG (__WAIT_INT (status))
90 # define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status))
91 # define WIFSIGNALED(status) __WIFSIGNALED (__WAIT_INT (status))
92 # define WIFSTOPPED(status) __WIFSTOPPED (__WAIT_INT (status))
93 # ifdef __WIFCONTINUED
94 # define WIFCONTINUED(status) __WIFCONTINUED (__WAIT_INT (status))
95 # endif
96 #endif /* X/Open and <sys/wait.h> not included. */
98 __BEGIN_NAMESPACE_STD
99 /* Returned by `div'. */
100 typedef struct
102 int quot; /* Quotient. */
103 int rem; /* Remainder. */
104 } div_t;
106 /* Returned by `ldiv'. */
107 #ifndef __ldiv_t_defined
108 typedef struct
110 long int quot; /* Quotient. */
111 long int rem; /* Remainder. */
112 } ldiv_t;
113 # define __ldiv_t_defined 1
114 #endif
115 __END_NAMESPACE_STD
117 #if defined __USE_ISOC99 && !defined __lldiv_t_defined
118 __BEGIN_NAMESPACE_C99
119 /* Returned by `lldiv'. */
120 __extension__ typedef struct
122 long long int quot; /* Quotient. */
123 long long int rem; /* Remainder. */
124 } lldiv_t;
125 # define __lldiv_t_defined 1
126 __END_NAMESPACE_C99
127 #endif
130 /* The largest number rand will return (same as INT_MAX). */
131 #define RAND_MAX 2147483647
134 /* We define these the same for all machines.
135 Changes from this to the outside world should be done in `_exit'. */
136 #define EXIT_FAILURE 1 /* Failing exit status. */
137 #define EXIT_SUCCESS 0 /* Successful exit status. */
140 /* Maximum length of a multibyte character in the current locale. */
141 #if 0
142 #define MB_CUR_MAX (__ctype_get_mb_cur_max ())
143 extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
144 #else
145 #ifdef __UCLIBC_HAS_WCHAR__
146 # define MB_CUR_MAX (_stdlib_mb_cur_max ())
147 extern size_t _stdlib_mb_cur_max (void) __THROW __wur;
148 #else
149 # define MB_CUR_MAX 1
150 #endif
151 #endif
154 __BEGIN_NAMESPACE_STD
155 #ifdef __UCLIBC_HAS_FLOATS__
156 /* Convert a string to a floating-point number. */
157 extern double atof (__const char *__nptr)
158 __THROW __attribute_pure__ __nonnull ((1)) __wur;
159 #endif /* __UCLIBC_HAS_FLOATS__ */
160 /* Convert a string to an integer. */
161 extern int atoi (__const char *__nptr)
162 __THROW __attribute_pure__ __nonnull ((1)) __wur;
163 /* Convert a string to a long integer. */
164 extern long int atol (__const char *__nptr)
165 __THROW __attribute_pure__ __nonnull ((1)) __wur;
166 __END_NAMESPACE_STD
168 #if defined __USE_ISOC99 || defined __USE_MISC
169 __BEGIN_NAMESPACE_C99
170 /* Convert a string to a long long integer. */
171 __extension__ extern long long int atoll (__const char *__nptr)
172 __THROW __attribute_pure__ __nonnull ((1)) __wur;
173 __END_NAMESPACE_C99
174 #endif
176 #ifdef __UCLIBC_HAS_FLOATS__
177 __BEGIN_NAMESPACE_STD
178 /* Convert a string to a floating-point number. */
179 extern double strtod (__const char *__restrict __nptr,
180 char **__restrict __endptr)
181 __THROW __nonnull ((1)) __wur;
182 __END_NAMESPACE_STD
184 #ifdef __USE_ISOC99
185 __BEGIN_NAMESPACE_C99
186 /* Likewise for `float' and `long double' sizes of floating-point numbers. */
187 extern float strtof (__const char *__restrict __nptr,
188 char **__restrict __endptr) __THROW __nonnull ((1)) __wur;
190 extern long double strtold (__const char *__restrict __nptr,
191 char **__restrict __endptr)
192 __THROW __nonnull ((1)) __wur;
193 __END_NAMESPACE_C99
194 #endif
195 #endif /* __UCLIBC_HAS_FLOATS__ */
197 __BEGIN_NAMESPACE_STD
198 /* Convert a string to a long integer. */
199 extern long int strtol (__const char *__restrict __nptr,
200 char **__restrict __endptr, int __base)
201 __THROW __nonnull ((1)) __wur;
202 /* Convert a string to an unsigned long integer. */
203 extern unsigned long int strtoul (__const char *__restrict __nptr,
204 char **__restrict __endptr, int __base)
205 __THROW __nonnull ((1)) __wur;
206 __END_NAMESPACE_STD
208 #ifdef __USE_BSD
209 #include <sys/types.h> /* for u_quad_t */
211 /* Convert a string to a quadword integer. */
212 __extension__
213 extern quad_t strtoq (__const char *__restrict __nptr,
214 char **__restrict __endptr, int __base)
215 __THROW __nonnull ((1)) __wur;
216 /* Convert a string to an unsigned quadword integer. */
217 __extension__
218 extern u_quad_t strtouq (__const char *__restrict __nptr,
219 char **__restrict __endptr, int __base)
220 __THROW __nonnull ((1)) __wur;
221 #endif /* GCC and use BSD. */
223 #if defined __USE_ISOC99 || defined __USE_MISC
224 __BEGIN_NAMESPACE_C99
225 /* Convert a string to a quadword integer. */
226 __extension__
227 extern long long int strtoll (__const char *__restrict __nptr,
228 char **__restrict __endptr, int __base)
229 __THROW __nonnull ((1)) __wur;
230 /* Convert a string to an unsigned quadword integer. */
231 __extension__
232 extern unsigned long long int strtoull (__const char *__restrict __nptr,
233 char **__restrict __endptr, int __base)
234 __THROW __nonnull ((1)) __wur;
235 __END_NAMESPACE_C99
236 #endif /* ISO C99 or GCC and use MISC. */
239 #if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
240 /* The concept of one static locale per category is not very well
241 thought out. Many applications will need to process its data using
242 information from several different locales. Another problem is
243 the implementation of the internationalization handling in the
244 ISO C++ standard library. To support this another set of
245 the functions using locale data exist which take an additional
246 argument.
248 Attention: even though several *_l interfaces are part of POSIX:2008,
249 these are not. */
251 /* Structure for reentrant locale using functions. This is an
252 (almost) opaque type for the user level programs. */
253 # include <xlocale.h>
255 /* Special versions of the functions above which take the locale to
256 use as an additional parameter. */
257 extern long int strtol_l (__const char *__restrict __nptr,
258 char **__restrict __endptr, int __base,
259 __locale_t __loc) __THROW __nonnull ((1, 4)) __wur;
261 extern unsigned long int strtoul_l (__const char *__restrict __nptr,
262 char **__restrict __endptr,
263 int __base, __locale_t __loc)
264 __THROW __nonnull ((1, 4)) __wur;
266 __extension__
267 extern long long int strtoll_l (__const char *__restrict __nptr,
268 char **__restrict __endptr, int __base,
269 __locale_t __loc)
270 __THROW __nonnull ((1, 4)) __wur;
272 __extension__
273 extern unsigned long long int strtoull_l (__const char *__restrict __nptr,
274 char **__restrict __endptr,
275 int __base, __locale_t __loc)
276 __THROW __nonnull ((1, 4)) __wur;
278 #ifdef __UCLIBC_HAS_FLOATS__
279 extern double strtod_l (__const char *__restrict __nptr,
280 char **__restrict __endptr, __locale_t __loc)
281 __THROW __nonnull ((1, 3)) __wur;
283 extern float strtof_l (__const char *__restrict __nptr,
284 char **__restrict __endptr, __locale_t __loc)
285 __THROW __nonnull ((1, 3)) __wur;
287 extern long double strtold_l (__const char *__restrict __nptr,
288 char **__restrict __endptr,
289 __locale_t __loc)
290 __THROW __nonnull ((1, 3)) __wur;
291 #endif /* __UCLIBC_HAS_FLOATS__ */
292 #endif /* GNU */
295 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
296 /* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
297 digit first. Returns a pointer to static storage overwritten by the
298 next call. */
299 extern char *l64a (long int __n) __THROW __wur;
301 /* Read a number from a string S in base 64 as above. */
302 extern long int a64l (__const char *__s)
303 __THROW __attribute_pure__ __nonnull ((1)) __wur;
305 #endif /* Use SVID || extended X/Open. */
307 #if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD
308 # include <sys/types.h> /* we need int32_t... */
310 /* These are the functions that actually do things. The `random', `srandom',
311 `initstate' and `setstate' functions are those from BSD Unices.
312 The `rand' and `srand' functions are required by the ANSI standard.
313 We provide both interfaces to the same random number generator. */
314 /* Return a random long integer between 0 and RAND_MAX inclusive. */
315 extern long int random (void) __THROW;
317 /* Seed the random number generator with the given number. */
318 extern void srandom (unsigned int __seed) __THROW;
320 /* Initialize the random number generator to use state buffer STATEBUF,
321 of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16,
322 32, 64, 128 and 256, the bigger the better; values less than 8 will
323 cause an error and values greater than 256 will be rounded down. */
324 extern char *initstate (unsigned int __seed, char *__statebuf,
325 size_t __statelen) __THROW __nonnull ((2));
327 /* Switch the random number generator to state buffer STATEBUF,
328 which should have been previously initialized by `initstate'. */
329 extern char *setstate (char *__statebuf) __THROW __nonnull ((1));
332 # ifdef __USE_MISC
333 /* Reentrant versions of the `random' family of functions.
334 These functions all use the following data structure to contain
335 state, rather than global state variables. */
337 struct random_data
339 int32_t *fptr; /* Front pointer. */
340 int32_t *rptr; /* Rear pointer. */
341 int32_t *state; /* Array of state values. */
342 #if 0
343 int rand_type; /* Type of random number generator. */
344 int rand_deg; /* Degree of random number generator. */
345 int rand_sep; /* Distance between front and rear. */
346 #else
347 /* random_r.c, TYPE_x, DEG_x, SEP_x - small enough for int8_t */
348 int8_t rand_type; /* Type of random number generator. */
349 int8_t rand_deg; /* Degree of random number generator. */
350 int8_t rand_sep; /* Distance between front and rear. */
351 #endif
352 int32_t *end_ptr; /* Pointer behind state table. */
355 extern int random_r (struct random_data *__restrict __buf,
356 int32_t *__restrict __result) __THROW __nonnull ((1, 2));
358 extern int srandom_r (unsigned int __seed, struct random_data *__buf)
359 __THROW __nonnull ((2));
361 extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
362 size_t __statelen,
363 struct random_data *__restrict __buf)
364 __THROW __nonnull ((2, 4));
366 extern int setstate_r (char *__restrict __statebuf,
367 struct random_data *__restrict __buf)
368 __THROW __nonnull ((1, 2));
369 # endif /* Use misc. */
370 #endif /* Use SVID || extended X/Open || BSD. */
373 __BEGIN_NAMESPACE_STD
374 /* Return a random integer between 0 and RAND_MAX inclusive. */
375 extern int rand (void) __THROW;
376 /* Seed the random number generator with the given number. */
377 extern void srand (unsigned int __seed) __THROW;
378 __END_NAMESPACE_STD
380 #ifdef __USE_POSIX
381 /* Reentrant interface according to POSIX.1. */
382 extern int rand_r (unsigned int *__seed) __THROW;
383 #endif
386 #if defined __USE_SVID || defined __USE_XOPEN
387 /* System V style 48-bit random number generator functions. */
389 #ifdef __UCLIBC_HAS_FLOATS__
390 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
391 extern double drand48 (void) __THROW;
392 extern double erand48 (unsigned short int __xsubi[3]) __THROW __nonnull ((1));
393 #endif /* __UCLIBC_HAS_FLOATS__ */
395 /* Return non-negative, long integer in [0,2^31). */
396 extern long int lrand48 (void) __THROW;
397 extern long int nrand48 (unsigned short int __xsubi[3])
398 __THROW __nonnull ((1));
400 /* Return signed, long integers in [-2^31,2^31). */
401 extern long int mrand48 (void) __THROW;
402 extern long int jrand48 (unsigned short int __xsubi[3])
403 __THROW __nonnull ((1));
405 /* Seed random number generator. */
406 extern void srand48 (long int __seedval) __THROW;
407 extern unsigned short int *seed48 (unsigned short int __seed16v[3])
408 __THROW __nonnull ((1));
409 extern void lcong48 (unsigned short int __param[7]) __THROW __nonnull ((1));
411 # ifdef __USE_MISC
412 /* Data structure for communication with thread safe versions. This
413 type is to be regarded as opaque. It's only exported because users
414 have to allocate objects of this type. */
415 struct drand48_data
417 unsigned short int __x[3]; /* Current state. */
418 unsigned short int __old_x[3]; /* Old state. */
419 unsigned short int __c; /* Additive const. in congruential formula. */
420 unsigned short int __init; /* Flag for initializing. */
421 unsigned long long int __a; /* Factor in congruential formula. */
424 #ifdef __UCLIBC_HAS_FLOATS__
425 /* Return non-negative, double-precision floating-point value in [0.0,1.0). */
426 extern int drand48_r (struct drand48_data *__restrict __buffer,
427 double *__restrict __result) __THROW __nonnull ((1, 2));
428 extern int erand48_r (unsigned short int __xsubi[3],
429 struct drand48_data *__restrict __buffer,
430 double *__restrict __result) __THROW __nonnull ((1, 2));
431 #endif /* __UCLIBC_HAS_FLOATS__ */
433 /* Return non-negative, long integer in [0,2^31). */
434 extern int lrand48_r (struct drand48_data *__restrict __buffer,
435 long int *__restrict __result)
436 __THROW __nonnull ((1, 2));
437 extern int nrand48_r (unsigned short int __xsubi[3],
438 struct drand48_data *__restrict __buffer,
439 long int *__restrict __result)
440 __THROW __nonnull ((1, 2));
442 /* Return signed, long integers in [-2^31,2^31). */
443 extern int mrand48_r (struct drand48_data *__restrict __buffer,
444 long int *__restrict __result)
445 __THROW __nonnull ((1, 2));
446 extern int jrand48_r (unsigned short int __xsubi[3],
447 struct drand48_data *__restrict __buffer,
448 long int *__restrict __result)
449 __THROW __nonnull ((1, 2));
451 /* Seed random number generator. */
452 extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
453 __THROW __nonnull ((2));
455 extern int seed48_r (unsigned short int __seed16v[3],
456 struct drand48_data *__buffer) __THROW __nonnull ((1, 2));
458 extern int lcong48_r (unsigned short int __param[7],
459 struct drand48_data *__buffer)
460 __THROW __nonnull ((1, 2));
461 # endif /* Use misc. */
462 #endif /* Use SVID or X/Open. */
464 #endif /* don't just need malloc and calloc */
466 #ifndef __malloc_and_calloc_defined
467 # define __malloc_and_calloc_defined
468 __BEGIN_NAMESPACE_STD
469 /* Allocate SIZE bytes of memory. */
470 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
471 /* We want the malloc symbols overridable at runtime
472 * libc_hidden_proto(malloc) */
473 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
474 extern void *calloc (size_t __nmemb, size_t __size)
475 __THROW __attribute_malloc__ __wur;
476 __END_NAMESPACE_STD
477 #endif
479 #ifndef __need_malloc_and_calloc
480 __BEGIN_NAMESPACE_STD
481 /* Re-allocate the previously allocated block
482 in PTR, making the new block SIZE bytes long. */
483 /* __attribute_malloc__ is not used, because if realloc returns
484 the same pointer that was passed to it, aliasing needs to be allowed
485 between objects pointed by the old and new pointers. */
486 extern void *realloc (void *__ptr, size_t __size)
487 __THROW __attribute_warn_unused_result__;
488 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
489 extern void free (void *__ptr) __THROW;
490 __END_NAMESPACE_STD
492 #if 0 /*def __USE_MISC*/
493 /* Free a block. An alias for `free'. (Sun Unices). */
494 extern void cfree (void *__ptr) __THROW;
495 #endif /* Use misc. */
497 #if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
498 # include <alloca.h>
499 #endif /* Use GNU, BSD, or misc. */
501 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
502 /* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */
503 extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
504 #endif
506 #if defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
507 /* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */
508 extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
509 __THROW __nonnull ((1)) __wur;
510 #endif
512 __BEGIN_NAMESPACE_STD
513 /* Abort execution and generate a core-dump. */
514 extern void abort (void) __THROW __attribute__ ((__noreturn__));
517 /* Register a function to be called when `exit' is called. */
518 extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
519 __END_NAMESPACE_STD
521 #ifdef __USE_MISC
522 /* Register a function to be called with the status
523 given to `exit' and the given argument. */
524 extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
525 __THROW __nonnull ((1));
526 #endif
528 __BEGIN_NAMESPACE_STD
529 /* Call all functions registered with `atexit' and `on_exit',
530 in the reverse of the order in which they were registered,
531 perform stdio cleanup, and terminate program execution with STATUS. */
532 extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
533 __END_NAMESPACE_STD
535 #ifdef __USE_ISOC99
536 __BEGIN_NAMESPACE_C99
537 /* Terminate the program with STATUS without calling any of the
538 functions registered with `atexit' or `on_exit'. */
539 extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__));
540 __END_NAMESPACE_C99
541 #endif
544 __BEGIN_NAMESPACE_STD
545 /* Return the value of envariable NAME, or NULL if it doesn't exist. */
546 extern char *getenv (__const char *__name) __THROW __nonnull ((1)) __wur;
547 __END_NAMESPACE_STD
549 #if 0
550 /* This function is similar to the above but returns NULL if the
551 programs is running with SUID or SGID enabled. */
552 extern char *__secure_getenv (__const char *__name)
553 __THROW __nonnull ((1)) __wur;
554 #endif
556 #if defined __USE_SVID || defined __USE_XOPEN
557 /* The SVID says this is in <stdio.h>, but this seems a better place. */
558 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
559 If there is no `=', remove NAME from the environment. */
560 extern int putenv (char *__string) __THROW __nonnull ((1));
561 #endif
563 #if defined __USE_BSD || defined __USE_XOPEN2K
564 /* Set NAME to VALUE in the environment.
565 If REPLACE is nonzero, overwrite an existing value. */
566 extern int setenv (__const char *__name, __const char *__value, int __replace)
567 __THROW __nonnull ((2));
569 /* Remove the variable NAME from the environment. */
570 extern int unsetenv (__const char *__name) __THROW;
571 #endif
573 /* The following is used by uClibc in atexit.c and sysconf.c */
574 /* We have no limit when __UCLIBC_DYNAMIC_ATEXIT__ is enabled. */
575 #ifdef __UCLIBC_DYNAMIC_ATEXIT__
576 # define __UCLIBC_MAX_ATEXIT INT_MAX
577 #else
578 # define __UCLIBC_MAX_ATEXIT 20
579 #endif
582 #ifdef __USE_MISC
583 /* The `clearenv' was planned to be added to POSIX.1 but probably
584 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
585 for Fortran 77) requires this function. */
586 extern int clearenv (void) __THROW;
587 #endif
590 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
591 # if defined __UCLIBC_SUSV3_LEGACY__
592 /* Generate a unique temporary file name from TEMPLATE.
593 The last six characters of TEMPLATE must be "XXXXXX";
594 they are replaced with a string that makes the file name unique.
595 Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */
596 extern char *mktemp (char *__template) __THROW __nonnull ((1)) __wur;
597 # endif
599 /* Generate a unique temporary file name from TEMPLATE.
600 The last six characters of TEMPLATE must be "XXXXXX";
601 they are replaced with a string that makes the filename unique.
602 Returns a file descriptor open on the file for reading and writing,
603 or -1 if it cannot create a uniquely-named file.
605 This function is a possible cancellation point and therefore not
606 marked with __THROW. */
607 # ifndef __USE_FILE_OFFSET64
608 extern int mkstemp (char *__template) __nonnull ((1)) __wur;
609 # else
610 # ifdef __REDIRECT
611 extern int __REDIRECT (mkstemp, (char *__template), mkstemp64)
612 __nonnull ((1)) __wur;
613 # else
614 # define mkstemp mkstemp64
615 # endif
616 # endif
617 # ifdef __USE_LARGEFILE64
618 extern int mkstemp64 (char *__template) __nonnull ((1)) __wur;
619 # endif
620 #endif
622 #if defined __USE_BSD || defined __USE_XOPEN2K8
623 /* Create a unique temporary directory from TEMPLATE.
624 The last six characters of TEMPLATE must be "XXXXXX";
625 they are replaced with a string that makes the directory name unique.
626 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
627 The directory is created mode 700. */
628 extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur;
629 #endif
632 __BEGIN_NAMESPACE_STD
633 /* Execute the given line as a shell command.
635 This function is a cancellation point and therefore not marked with
636 __THROW. */
637 extern int system (__const char *__command) __wur;
638 __END_NAMESPACE_STD
641 #ifdef __USE_GNU
642 /* Return a malloc'd string containing the canonical absolute name of the
643 existing named file. */
644 extern char *canonicalize_file_name (__const char *__name)
645 __THROW __nonnull ((1)) __wur;
646 #endif
648 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
649 /* Return the canonical absolute name of file NAME. If RESOLVED is
650 null, the result is malloc'd; otherwise, if the canonical name is
651 PATH_MAX chars or more, returns null with `errno' set to
652 ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
653 returns the name in RESOLVED. */
654 extern char *realpath (__const char *__restrict __name,
655 char *__restrict __resolved) __THROW __wur;
656 #endif
659 /* Shorthand for type of comparison functions. */
660 #ifndef __COMPAR_FN_T
661 # define __COMPAR_FN_T
662 typedef int (*__compar_fn_t) (__const void *, __const void *);
664 # ifdef __USE_GNU
665 typedef __compar_fn_t comparison_fn_t;
666 # endif
667 #endif
669 __BEGIN_NAMESPACE_STD
670 /* Do a binary search for KEY in BASE, which consists of NMEMB elements
671 of SIZE bytes each, using COMPAR to perform the comparisons. */
672 extern void *bsearch (__const void *__key, __const void *__base,
673 size_t __nmemb, size_t __size, __compar_fn_t __compar)
674 __nonnull ((1, 2, 5)) __wur;
676 /* Sort NMEMB elements of BASE, of SIZE bytes each,
677 using COMPAR to perform the comparisons. */
678 extern void qsort (void *__base, size_t __nmemb, size_t __size,
679 __compar_fn_t __compar) __nonnull ((1, 4));
682 /* Return the absolute value of X. */
683 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
684 extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
685 __END_NAMESPACE_STD
687 #ifdef __USE_ISOC99
688 __extension__ extern long long int llabs (long long int __x)
689 __THROW __attribute__ ((__const__)) __wur;
690 #endif
693 __BEGIN_NAMESPACE_STD
694 /* Return the `div_t', `ldiv_t' or `lldiv_t' representation
695 of the value of NUMER over DENOM. */
696 /* GCC may have built-ins for these someday. */
697 extern div_t div (int __numer, int __denom)
698 __THROW __attribute__ ((__const__)) __wur;
699 extern ldiv_t ldiv (long int __numer, long int __denom)
700 __THROW __attribute__ ((__const__)) __wur;
701 __END_NAMESPACE_STD
703 #ifdef __USE_ISOC99
704 __BEGIN_NAMESPACE_C99
705 __extension__ extern lldiv_t lldiv (long long int __numer,
706 long long int __denom)
707 __THROW __attribute__ ((__const__)) __wur;
708 __END_NAMESPACE_C99
709 #endif
712 #if ( defined __USE_SVID || defined __USE_XOPEN_EXTENDED ) && defined __UCLIBC_HAS_FLOATS__
713 /* Convert floating point numbers to strings. The returned values are
714 valid only until another call to the same function. */
716 # ifdef __UCLIBC_SUSV3_LEGACY__
717 #if 0
718 /* Convert VALUE to a string with NDIGIT digits and return a pointer to
719 this. Set *DECPT with the position of the decimal character and *SIGN
720 with the sign of the number. */
721 extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
722 int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
724 /* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT
725 with the position of the decimal character and *SIGN with the sign of
726 the number. */
727 extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
728 int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur;
729 #endif
731 /* If possible convert VALUE to a string with NDIGIT significant digits.
732 Otherwise use exponential representation. The resulting string will
733 be written to BUF. */
734 extern char *gcvt (double __value, int __ndigit, char *__buf)
735 __THROW __nonnull ((3)) __wur;
736 # endif /* __UCLIBC_SUSV3_LEGACY__ */
739 # if 0 /*def __USE_MISC*/
740 /* Long double versions of above functions. */
741 extern char *qecvt (long double __value, int __ndigit,
742 int *__restrict __decpt, int *__restrict __sign)
743 __THROW __nonnull ((3, 4)) __wur;
744 extern char *qfcvt (long double __value, int __ndigit,
745 int *__restrict __decpt, int *__restrict __sign)
746 __THROW __nonnull ((3, 4)) __wur;
747 extern char *qgcvt (long double __value, int __ndigit, char *__buf)
748 __THROW __nonnull ((3)) __wur;
751 /* Reentrant version of the functions above which provide their own
752 buffers. */
753 extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
754 int *__restrict __sign, char *__restrict __buf,
755 size_t __len) __THROW __nonnull ((3, 4, 5));
756 extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
757 int *__restrict __sign, char *__restrict __buf,
758 size_t __len) __THROW __nonnull ((3, 4, 5));
760 extern int qecvt_r (long double __value, int __ndigit,
761 int *__restrict __decpt, int *__restrict __sign,
762 char *__restrict __buf, size_t __len)
763 __THROW __nonnull ((3, 4, 5));
764 extern int qfcvt_r (long double __value, int __ndigit,
765 int *__restrict __decpt, int *__restrict __sign,
766 char *__restrict __buf, size_t __len)
767 __THROW __nonnull ((3, 4, 5));
768 # endif /* misc */
769 #endif /* use MISC || use X/Open Unix */
772 #ifdef __UCLIBC_HAS_WCHAR__
773 __BEGIN_NAMESPACE_STD
774 /* Return the length of the multibyte character
775 in S, which is no longer than N. */
776 extern int mblen (__const char *__s, size_t __n) __THROW __wur;
777 /* Return the length of the given multibyte character,
778 putting its `wchar_t' representation in *PWC. */
779 extern int mbtowc (wchar_t *__restrict __pwc,
780 __const char *__restrict __s, size_t __n) __THROW __wur;
781 /* Put the multibyte character represented
782 by WCHAR in S, returning its length. */
783 extern int wctomb (char *__s, wchar_t __wchar) __THROW __wur;
786 /* Convert a multibyte string to a wide char string. */
787 extern size_t mbstowcs (wchar_t *__restrict __pwcs,
788 __const char *__restrict __s, size_t __n) __THROW;
789 /* Convert a wide char string to multibyte string. */
790 extern size_t wcstombs (char *__restrict __s,
791 __const wchar_t *__restrict __pwcs, size_t __n)
792 __THROW;
793 __END_NAMESPACE_STD
794 #endif /* __UCLIBC_HAS_WCHAR__ */
797 #if 0 /*def __USE_SVID*/
798 /* Determine whether the string value of RESPONSE matches the affirmation
799 or negative response expression as specified by the LC_MESSAGES category
800 in the program's current locale. Returns 1 if affirmative, 0 if
801 negative, and -1 if not matching. */
802 extern int rpmatch (__const char *__response) __THROW __nonnull ((1)) __wur;
803 #endif
806 #ifdef __USE_XOPEN_EXTENDED
807 /* Parse comma separated suboption from *OPTIONP and match against
808 strings in TOKENS. If found return index and set *VALUEP to
809 optional value introduced by an equal sign. If the suboption is
810 not part of TOKENS return in *VALUEP beginning of unknown
811 suboption. On exit *OPTIONP is set to the beginning of the next
812 token or at the terminating NUL character. */
813 extern int getsubopt (char **__restrict __optionp,
814 char *__const *__restrict __tokens,
815 char **__restrict __valuep)
816 __THROW __nonnull ((1, 2, 3)) __wur;
817 #endif
820 #ifdef __USE_XOPEN
821 # if defined __UCLIBC_HAS_CRYPT__
822 /* Setup DES tables according KEY. */
823 extern void setkey (__const char *__key) __THROW __nonnull ((1));
824 # endif /* __UCLIBC_HAS_CRYPT__ */
825 #endif
828 /* X/Open pseudo terminal handling. */
830 #ifdef __USE_XOPEN2K
831 /* Return a master pseudo-terminal handle. */
832 extern int posix_openpt (int __oflag) __wur;
833 #endif
835 #ifdef __USE_XOPEN
836 /* The next four functions all take a master pseudo-tty fd and
837 perform an operation on the associated slave: */
839 #ifdef __UCLIBC_HAS_PTY__
840 /* Chown the slave to the calling user. */
841 extern int grantpt (int __fd) __THROW;
843 /* Release an internal lock so the slave can be opened.
844 Call after grantpt(). */
845 extern int unlockpt (int __fd) __THROW;
847 /* Return the pathname of the pseudo terminal slave assoicated with
848 the master FD is open on, or NULL on errors.
849 The returned storage is good until the next call to this function. */
850 extern char *ptsname (int __fd) __THROW __wur;
851 #endif /* __UCLIBC_HAS_PTY__ */
852 #endif
854 #ifdef __USE_GNU
855 # if defined __UCLIBC_HAS_PTY__
856 /* Store at most BUFLEN characters of the pathname of the slave pseudo
857 terminal associated with the master FD is open on in BUF.
858 Return 0 on success, otherwise an error number. */
859 extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
860 __THROW __nonnull ((2));
861 # endif
862 # if defined __UCLIBC_HAS_GETPT__
863 /* Open a master pseudo terminal and return its file descriptor. */
864 extern int getpt (void);
865 # endif
866 #endif
868 #if 0 /* def __USE_BSD */
869 /* Put the 1 minute, 5 minute and 15 minute load averages into the first
870 NELEM elements of LOADAVG. Return the number written (never more than
871 three, but may be less than NELEM), or -1 if an error occurred. */
872 extern int getloadavg (double __loadavg[], int __nelem)
873 __THROW __nonnull ((1));
874 #endif
876 #ifdef __UCLIBC_HAS_ARC4RANDOM__
877 #include <stdint.h>
878 extern uint32_t arc4random(void);
879 extern void arc4random_stir(void);
880 extern void arc4random_addrandom(unsigned char *, int);
881 #endif
884 #endif /* don't just need malloc and calloc */
885 #undef __need_malloc_and_calloc
887 __END_DECLS
889 #endif /* stdlib.h */