00001 #ifndef _STDLIB_H_
00002 #define _STDLIB_H_ 1
00003
00004 #define __need_NULL
00005 #define __need_size_t
00006 #define __need_wchar_t
00007 #include <stddef.h>
00008
00009 #ifndef __ptr_t
00010 #define __ptr_t void *
00011 #endif
00012
00013 typedef struct {
00014 int quot;
00015 int rem;
00016 } div_t;
00017
00018 typedef struct {
00019 long quot;
00020 long rem;
00021 } ldiv_t;
00022
00023 typedef int (*__compar_fn_t)(const void *, const void *);
00024
00025 #define RAND_MAX 0x7FFFFFFF
00026
00027 #ifndef __ATTR_CONST__
00028 #define __ATTR_CONST__ __attribute__((__const__))
00029 #endif
00030
00031 #ifndef __ATTR_MALLOC__
00032 #define __ATTR_MALLOC__ __attribute__((__malloc__))
00033 #endif
00034
00035 #ifndef __ATTR_NORETURN__
00036 #define __ATTR_NORETURN__ __attribute__((__noreturn__))
00037 #endif
00038
00039 #ifndef __ATTR_PURE__
00040 #define __ATTR_PURE__ __attribute__((__pure__))
00041 #endif
00042
00043 extern __inline__ void abort(void) __ATTR_NORETURN__;
00044 extern __inline__ void
00045 abort(void)
00046 {
00047 for (;;);
00048 }
00049
00050 extern __inline__ int abs(int __x) __ATTR_CONST__;
00051 extern __inline__ int
00052 abs(int __x)
00053 {
00054 return (__x < 0) ? -__x : __x;
00055 }
00056
00057 extern __inline__ long labs(long __x) __ATTR_CONST__;
00058 extern __inline__ long
00059 labs(long __x)
00060 {
00061 return (__x < 0) ? -__x : __x;
00062 }
00063
00064 extern void *bsearch(const void *, const void *, size_t, size_t,
00065 int (*)(const void *, const void *));
00066
00067
00068 extern div_t div(int, int) __asm__("__divmodhi4") __ATTR_CONST__;
00069 extern ldiv_t ldiv(long, long) __asm__("__divmodsi4") __ATTR_CONST__;
00070
00071 extern void qsort(void *, size_t, size_t, __compar_fn_t);
00072
00073 extern long strtol(const char *, char **, int);
00074 extern unsigned long strtoul(const char *, char **, int);
00075
00076 extern __inline__ long atol(const char *) __ATTR_PURE__;
00077 extern __inline__ long
00078 atol(const char *__p)
00079 {
00080 return strtol(__p, (char **) 0, 10);
00081 }
00082
00083 #if 0
00084 extern __inline__ int atoi(const char *__p) __ATTR_PURE__;
00085 extern __inline__ int
00086 atoi(const char *__p)
00087 {
00088 return (int) atol(__p);
00089 }
00090 #else
00091
00092 extern int atoi(const char *) __ATTR_PURE__;
00093 #endif
00094
00095 extern void exit(int) __ATTR_NORETURN__;
00096
00097
00098 extern void *malloc(size_t) __ATTR_MALLOC__;
00099 extern void free(void *);
00100 extern double strtod(const char *, char **);
00101
00102
00103 char *itoa(int value, char *string, int radix);
00104 extern char *dtostre( double f, char * s, unsigned char ndig, unsigned char flags);
00105
00106 #if 0
00107 extern int atexit(void (*)(void));
00108 extern double atof(const char *);
00109 extern void *calloc(size_t, size_t);
00110 extern int rand(void);
00111 extern void *realloc(void *, size_t);
00112 extern void srand(unsigned int);
00113 #endif
00114
00115 #endif