1 | #ifndef _STDLIB_H |
---|
2 | #define _STDLIB_H |
---|
3 | |
---|
4 | |
---|
5 | #include <sys/types.h> |
---|
6 | #include <wchar.h> |
---|
7 | //#include <alloca.h> |
---|
8 | |
---|
9 | #define alloca(x) __builtin_alloca(x) |
---|
10 | |
---|
11 | void *calloc(size_t nmemb, size_t size); |
---|
12 | void *malloc(size_t size); |
---|
13 | void* realloc(void *ptr, size_t size); |
---|
14 | void* valloc(size_t size); |
---|
15 | void free(void *ptr); |
---|
16 | |
---|
17 | int atexit(void (*function)(void)); |
---|
18 | long int strtol(const char *nptr, char **endptr, int base); |
---|
19 | unsigned long int strtoul(const char *nptr, char **endptr, int base); |
---|
20 | double strtod(const char* s, char** endptr); |
---|
21 | |
---|
22 | extern int __ltostr(char *s, unsigned int size, unsigned long i, unsigned int base, int UpCase); |
---|
23 | extern int __dtostr(double d,char *buf,unsigned int maxlen,unsigned int prec,unsigned int prec2,int g); |
---|
24 | |
---|
25 | #if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L |
---|
26 | long long int strtoll(const char *nptr, char **endptr, int base); |
---|
27 | unsigned long long int strtoull(const char *nptr, char **endptr, int base); |
---|
28 | int __lltostr(char *s, unsigned int size, unsigned long long i, unsigned int base, int UpCase); |
---|
29 | #endif |
---|
30 | |
---|
31 | int atoi(const char *nptr); |
---|
32 | long int atol(const char *nptr); |
---|
33 | long long int atoll(const char *nptr); |
---|
34 | #define atof(_x) strtod((_x), NULL) |
---|
35 | |
---|
36 | void exit(int status); |
---|
37 | void abort(void); |
---|
38 | |
---|
39 | extern int rand(void); |
---|
40 | extern int rand_r(unsigned int *seed); |
---|
41 | extern void srand(unsigned int seed); |
---|
42 | |
---|
43 | extern char **environ; |
---|
44 | char *getenv(const char *name); |
---|
45 | int setenv(const char *name, const char *value, int overwrite); |
---|
46 | int unsetenv(const char *name); |
---|
47 | int putenv(const char *string); |
---|
48 | |
---|
49 | typedef unsigned short randbuf[3]; |
---|
50 | long lrand48(void); |
---|
51 | long mrand48(void); |
---|
52 | double drand48(void); |
---|
53 | void srand48(long seed); |
---|
54 | unsigned short *seed48(randbuf buf); |
---|
55 | void lcong48(unsigned short param[7]); |
---|
56 | long jrand48(randbuf buf); |
---|
57 | long nrand48(randbuf buf); |
---|
58 | double frand48(randbuf buf); |
---|
59 | |
---|
60 | void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); |
---|
61 | void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)); |
---|
62 | |
---|
63 | int mkstemp(char *_template); |
---|
64 | |
---|
65 | int abs(int i) __attribute__((__const__)); |
---|
66 | long int labs(long int i) __attribute__((__const__)); |
---|
67 | long long int llabs(long long int i) __attribute__((__const__)); |
---|
68 | |
---|
69 | |
---|
70 | #define EXIT_FAILURE 1 |
---|
71 | #define EXIT_SUCCESS 0 |
---|
72 | |
---|
73 | #define RAND_MAX 0x7ffffffe |
---|
74 | |
---|
75 | #define MB_CUR_MAX 1 |
---|
76 | |
---|
77 | /* now these functions are the greatest bullshit I have ever seen. |
---|
78 | * The ISO people must be out of their minds. */ |
---|
79 | |
---|
80 | typedef struct { int quot,rem; } div_t; |
---|
81 | typedef struct { long quot,rem; } ldiv_t; |
---|
82 | |
---|
83 | div_t div(int numerator, int denominator); |
---|
84 | ldiv_t ldiv(long numerator, long denominator); |
---|
85 | |
---|
86 | #ifdef _GNU_SOURCE |
---|
87 | typedef struct { long long quot,rem; } lldiv_t; |
---|
88 | lldiv_t lldiv(long long numerator, long long denominator); |
---|
89 | |
---|
90 | int clearenv(void); |
---|
91 | #endif |
---|
92 | |
---|
93 | int mbtowc(wchar_t *pwc, const char *s, size_t n); |
---|
94 | int wctomb(char *s, wchar_t wc); |
---|
95 | size_t mbstowcs(wchar_t *dest, const char *src, size_t n); |
---|
96 | int mblen(const char* s,size_t n); |
---|
97 | |
---|
98 | #endif |
---|