Rev 9810 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8687 | turbocat | 1 | #ifndef _STDLIB_H_ |
2 | #define _STDLIB_H_ |
||
3 | |||
4 | #include |
||
5 | |||
9766 | turbocat | 6 | #define RAND_MAX 65535 |
8687 | turbocat | 7 | #ifndef NULL |
9766 | turbocat | 8 | #define NULL ((void*)0) |
8687 | turbocat | 9 | #endif |
10 | |||
9766 | turbocat | 11 | #define min(a, b) ((a) < (b) ? (a) : (b)) |
12 | #define max(a, b) ((a) > (b) ? (a) : (b)) |
||
8687 | turbocat | 13 | |
9766 | turbocat | 14 | typedef struct { |
9233 | turbocat | 15 | int quot; |
9766 | turbocat | 16 | int rem; |
9233 | turbocat | 17 | } div_t; |
8687 | turbocat | 18 | |
9766 | turbocat | 19 | typedef struct { |
20 | long quot; |
||
9233 | turbocat | 21 | long rem; |
22 | } ldiv_t; |
||
8687 | turbocat | 23 | |
9766 | turbocat | 24 | typedef struct { |
25 | long long quot; |
||
26 | long long rem; |
||
9233 | turbocat | 27 | } lldiv_t; |
28 | |||
9766 | turbocat | 29 | static inline div_t div(int num, int den) |
30 | { |
||
31 | return (div_t) { num / den, num % den }; |
||
9233 | turbocat | 32 | } |
33 | |||
9766 | turbocat | 34 | static inline ldiv_t ldiv(long num, long den) |
35 | { |
||
36 | return (ldiv_t) { num / den, num % den }; |
||
9233 | turbocat | 37 | } |
38 | |||
9766 | turbocat | 39 | static inline lldiv_t lldiv(long long num, long long den) |
40 | { |
||
41 | return (lldiv_t) { num / den, num % den }; |
||
9233 | turbocat | 42 | } |
43 | |||
9811 | Coldy | 44 | extern void* _FUNC(malloc)(size_t size); |
45 | extern void* _FUNC(calloc)(size_t num, size_t size); |
||
46 | extern void* _FUNC(realloc)(void* ptr, size_t newsize); |
||
47 | extern void _FUNC(free)(void* ptr); |
||
8687 | turbocat | 48 | |
9811 | Coldy | 49 | extern long int _FUNC(strtol)(const char* str, char** endptr, int base); |
8687 | turbocat | 50 | |
9811 | Coldy | 51 | extern void _FUNC(exit)(int status); |
8687 | turbocat | 52 | |
9811 | Coldy | 53 | extern void _FUNC(srand)(unsigned s); |
54 | extern int _FUNC(rand)(void); |
||
8743 | turbocat | 55 | |
9811 | Coldy | 56 | extern void _FUNC(__assert_fail)(const char* expr, const char* file, int line, const char* func); |
57 | extern void _FUNC(qsort)(void* base0, size_t n, size_t size, int (*compar)(const void*, const void*)); |
||
9013 | turbocat | 58 | |
9811 | Coldy | 59 | extern double _FUNC(strtod)(const char* s, char** sret); |
60 | extern double _FUNC(atof)(const char* ascii); |
||
9137 | turbocat | 61 | |
9811 | Coldy | 62 | extern int _FUNC(atoi)(const char* s); |
63 | extern long _FUNC(atol)(const char*); |
||
64 | extern long long _FUNC(atoll)(const char*); |
||
65 | extern void _FUNC(itoa)(int n, char* s); |
||
9766 | turbocat | 66 | |
9811 | Coldy | 67 | extern int _FUNC(abs)(int); |
68 | extern long _FUNC(labs)(long); |
||
69 | extern long long _FUNC(llabs)(long long); |
||
9766 | turbocat | 70 | |
8743 | turbocat | 71 | #endif> |