OSDN Git Service

Fix all the makefiles. Clean up some warnings, cleanup some headers.
[uclinux-h8/uClibc.git] / include / stdlib.h
1 /* stdlib.h  */
2 #include <features.h>
3 #include <sys/types.h>
4 #include <limits.h>
5
6 #ifndef __STDLIB_H
7 #define __STDLIB_H
8
9 /* Don't overwrite user definitions of NULL */
10 #ifndef NULL
11 #define NULL ((void *) 0)
12 #endif
13
14 /* We define these the same for all machines.
15  * Changes from this to the outside world should be done in `_exit'.  */
16 #define EXIT_FAILURE    1       /* Failing exit status.  */
17 #define EXIT_SUCCESS    0       /* Successful exit status.  */
18
19 /* The largest number rand will return */
20 #define RAND_MAX        INT_MIN
21
22 /* Maximum length of a multibyte character in the current locale.  */
23 #define MB_CUR_MAX  1
24
25 typedef struct
26 {
27     int quot;                   /* Quotient.  */
28     int rem;                    /* Remainder.  */
29 } div_t;
30
31 typedef struct
32 {
33     long int quot;              /* Quotient.  */
34     long int rem;               /* Remainder.  */
35 } ldiv_t;
36
37 /*  comparison function used by bsearch() and qsort() */
38 typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
39 typedef __compar_fn_t comparison_fn_t;
40
41
42 /* String to number conversion functions */
43 #define atof(x) strtod((x),(char**)0)
44 #define atoi(x) (int)strtol((x),(char**)0,10)
45 #define atol(x) strtol((x),(char**)0,10)
46 extern long strtol __P ((const char * nptr, char ** endptr, int base));
47 extern unsigned long strtoul __P ((const char * nptr, char ** endptr, int base));
48 #ifndef __HAS_NO_FLOATS__
49 extern char * gcvt __P ((float number, size_t ndigit, char * buf));
50 extern float strtod __P ((const char * nptr, char ** endptr));
51 #endif
52
53
54
55 /* Random number functions */
56 extern int rand __P ((void));
57 extern void srand __P ((unsigned int seed));
58
59
60 /* Memory management functions */
61 extern __ptr_t alloca __P ((size_t __size));
62 extern __ptr_t calloc __P ((size_t, size_t));
63 extern __ptr_t malloc __P ((size_t));
64 extern __ptr_t realloc __P ((__ptr_t, size_t));
65 extern void free __P ((__ptr_t));
66
67 #ifdef DEBUG_MALLOC
68 extern __ptr_t malloc_dbg __P ((size_t, char* func, char* file, int line));
69 extern __ptr_t calloc_dbg __P ((size_t, size_t, char* func, char* file, int line));
70 extern void free_dbg __P ((__ptr_t, char* func, char* file, int line));
71 extern __ptr_t realloc_dbg __P ((__ptr_t, size_t, char* func, char* file, int line));
72 #define malloc(x) malloc_dbg((x),__FUNCTION__,__FILE__,__LINE__)
73 #define calloc(x,y) calloc_dbg((x),(y),__FUNCTION__,__FILE__,__LINE__)
74 #define free(x) free_dbg((x),__FUNCTION__,__FILE__,__LINE__)
75 #define realloc(x) realloc((x),__FUNCTION__,__FILE__,__LINE__)
76 #endif
77
78
79
80 /* System and environment functions */
81 extern void abort __P ((void)) __attribute__ ((__noreturn__));
82 extern int atexit __P ((void (*__func) (void)));
83 extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
84 extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
85 extern char *getenv __P ((__const char *__name));
86 extern int putenv __P ((__const char *__string));
87 extern char *realpath __P ((__const char *__restrict __name,
88             char *__restrict __resolved));
89 extern int setenv __P ((__const char *__name, __const char *__value,
90                         int __replace));
91 extern int system __P ((__const char *__command));
92 extern void unsetenv __P ((__const char *__name));
93
94
95
96 /* Search and sort functions */
97 extern __ptr_t bsearch __P ((__const __ptr_t __key, __const __ptr_t __base,
98                            size_t __nmemb, size_t __size, __compar_fn_t __compar));
99 extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
100                           __compar_fn_t __compar));
101
102
103
104 /* Integer math functions */
105 extern int abs __P ((int __x)) __attribute__ ((__const__));
106 extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
107 extern long int labs __P ((long int __x)) __attribute__ ((__const__));
108 extern ldiv_t ldiv __P ((long int __numer, long int __denom)) __attribute__ ((__const__));
109
110
111
112 #endif /* __STDLIB_H */