OSDN Git Service

Add in a bunch of junk. Busybox now compiles (except for mkfs.minix and
[uclinux-h8/uClibc.git] / include / stdlib.h
1 /* stdlib.h  <ndf@linux.mit.edu> */
2 #include <features.h>
3 #include <sys/types.h>
4
5 #ifndef __STDLIB_H
6 #define __STDLIB_H
7
8 /* Don't overwrite user definitions of NULL */
9 #ifndef NULL
10 #define NULL ((void *) 0)
11 #endif
12
13 /* For program termination */
14 #define EXIT_FAILURE 1
15 #define EXIT_SUCCESS 0
16
17 /* Call all functions registered with `atexit' and `on_exit',
18  * in the reverse of the order in which they were registered
19  * perform stdio cleanup, and terminate program execution with STATUS.  */
20 extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
21 /* Register a function to be called when `exit' is called.  */
22 extern int atexit __P ((void (*__func) (void)));
23 /* Abort execution and generate a core-dump.  */
24 extern void abort __P ((void)) __attribute__ ((__noreturn__));
25
26 extern void * malloc __P ((size_t));
27 extern void * calloc __P ((size_t, size_t));
28 extern void free __P ((void *));
29 extern void * realloc __P ((void *, size_t));
30
31 #ifdef DEBUG_MALLOC
32
33 extern void * malloc_dbg __P ((size_t, char* func, char* file, int line));
34 extern void * calloc_dbg __P ((size_t, size_t, char* func, char* file, int line));
35 extern void free_dbg __P ((void *, char* func, char* file, int line));
36 extern void * realloc_dbg __P ((void *, size_t, char* func, char* file, int line));
37
38 #define malloc(x) malloc_dbg((x),__FUNCTION__,__FILE__,__LINE__)
39 #define calloc(x,y) calloc_dbg((x),(y),__FUNCTION__,__FILE__,__LINE__)
40 #define free(x) free_dbg((x),__FUNCTION__,__FILE__,__LINE__)
41 #define realloc(x) realloc((x),__FUNCTION__,__FILE__,__LINE__)
42
43 #endif
44
45 extern int rand __P ((void));
46 extern void srand __P ((unsigned int seed));
47
48 extern long strtol __P ((const char * nptr, char ** endptr, int base));
49 extern unsigned long strtoul __P ((const char * nptr,
50                                    char ** endptr, int base));
51 #ifndef __HAS_NO_FLOATS__
52 extern float strtod __P ((const char * nptr, char ** endptr));
53 #endif
54
55 extern char *getenv __P ((__const char *__name));
56
57 extern int putenv __P ((__const char *__string));
58
59 extern int setenv __P ((__const char *__name, __const char *__value,
60                         int __replace));
61
62 extern int system __P ((__const char *__command));
63
64 extern char * gcvt __P ((float number, size_t ndigit, char * buf));
65
66 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
67 /* Return the canonical absolute name of file NAME.  The last file name
68  * component need not exist, and may be a symlink to a nonexistent file.
69  * If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
70  * name is PATH_MAX chars or more, returns null with `errno' set to
71  * ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
72  * name in RESOLVED.  */
73 extern char *realpath __P ((__const char *__restrict __name,
74             char *__restrict __resolved));
75 #endif
76
77
78 /* Shorthand for type of comparison functions.  */
79 typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
80 typedef __compar_fn_t comparison_fn_t;
81 /* Sort NMEMB elements of BASE, of SIZE bytes each,
82    using COMPAR to perform the comparisons.  */
83 extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
84                           __compar_fn_t __compar));
85
86
87 #define atof(x) strtod((x),(char**)0)
88 #define atoi(x) (int)strtol((x),(char**)0,10)
89 #define atol(x) strtol((x),(char**)0,10)
90 char* itoa(int i);
91
92 /* Returned by `div'.  */
93 typedef struct
94   {
95     int quot;                   /* Quotient.  */
96     int rem;                    /* Remainder.  */
97   } div_t;
98
99 /* Returned by `ldiv'.  */
100 typedef struct
101   {
102     long int quot;              /* Quotient.  */
103     long int rem;               /* Remainder.  */
104   } ldiv_t;
105
106
107
108 #endif /* __STDLIB_H */