OSDN Git Service

Bug ugly formatting update
[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 calloc __P ((size_t, size_t));
62 extern __ptr_t malloc __P ((size_t));
63 extern __ptr_t realloc __P ((__ptr_t, size_t));
64 extern void free __P ((__ptr_t));
65
66 #ifdef DEBUG_MALLOC
67 extern __ptr_t calloc_dbg __P ((size_t, size_t, char* func, char* file, int line));
68 extern __ptr_t malloc_dbg __P ((size_t, char* func, char* file, int line));
69 extern __ptr_t realloc_dbg __P ((__ptr_t, size_t, char* func, char* file, int line));
70 extern void free_dbg __P ((__ptr_t, char* func, char* file, int line));
71 #define calloc(x,y) calloc_dbg((x),(y),__FUNCTION__,__FILE__,__LINE__)
72 #define malloc(x) malloc_dbg((x),__FUNCTION__,__FILE__,__LINE__)
73 #define realloc(x) realloc((x),__FUNCTION__,__FILE__,__LINE__)
74 #define free(x) free_dbg((x),__FUNCTION__,__FILE__,__LINE__)
75 #endif
76
77
78
79 /* System and environment functions */
80 extern void abort __P ((void)) __attribute__ ((__noreturn__));
81 extern int atexit __P ((void (*__func) (void)));
82 extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
83 extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
84 extern char *getenv __P ((__const char *__name));
85 extern int putenv __P ((__const char *__string));
86 extern char *realpath __P ((__const char *__restrict __name,
87             char *__restrict __resolved));
88 extern int setenv __P ((__const char *__name, __const char *__value,
89                         int __replace));
90 extern int system __P ((__const char *__command));
91 extern void unsetenv __P ((__const char *__name));
92
93
94
95 /* Search and sort functions */
96 extern __ptr_t bsearch __P ((__const __ptr_t __key, __const __ptr_t __base,
97                            size_t __nmemb, size_t __size, __compar_fn_t __compar));
98 extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
99                           __compar_fn_t __compar));
100
101
102
103 /* Integer math functions */
104 extern int abs __P ((int __x)) __attribute__ ((__const__));
105 extern div_t div __P ((int __numer, int __denom)) __attribute__ ((__const__));
106 extern long int labs __P ((long int __x)) __attribute__ ((__const__));
107 extern ldiv_t ldiv __P ((long int __numer, long int __denom)) __attribute__ ((__const__));
108
109
110
111 #endif /* __STDLIB_H */