Commit | Line | Data |
---|---|---|
eee695dd FG |
1 | /* |
2 | * Standard library definitions | |
3 | * | |
4 | * Derived from the mingw header written by Colin Peters. | |
5 | * Modified for Wine use by Jon Griffiths and Francois Gouget. | |
6 | * This file is in the public domain. | |
7 | */ | |
8 | #ifndef __WINE_STDLIB_H | |
9 | #define __WINE_STDLIB_H | |
5f175508 | 10 | #ifndef __WINE_USE_MSVCRT |
a45907c4 | 11 | #define __WINE_USE_MSVCRT |
5f175508 | 12 | #endif |
eee695dd | 13 | |
36d0e5b7 DP |
14 | #ifndef NULL |
15 | #ifdef __cplusplus | |
16 | #define NULL 0 | |
17 | #else | |
18 | #define NULL ((void*)0) | |
19 | #endif | |
20 | #endif | |
21 | ||
03774624 DP |
22 | #ifndef _WCHAR_T_DEFINED |
23 | #define _WCHAR_T_DEFINED | |
3f5ff2fb | 24 | #ifndef __cplusplus |
03774624 | 25 | typedef unsigned short wchar_t; |
3f5ff2fb AJ |
26 | #endif |
27 | #endif | |
eee695dd | 28 | |
3f5ff2fb AJ |
29 | #ifndef _MSC_VER |
30 | # ifndef __int64 | |
31 | # define __int64 long long | |
32 | # endif | |
33 | #endif | |
eee695dd | 34 | |
eee695dd FG |
35 | #define EXIT_SUCCESS 0 |
36 | #define EXIT_FAILURE -1 | |
37 | #define RAND_MAX 0x7FFF | |
eee695dd FG |
38 | |
39 | #ifndef _MAX_PATH | |
40 | #define _MAX_DRIVE 3 | |
41 | #define _MAX_FNAME 256 | |
42 | #define _MAX_DIR _MAX_FNAME | |
43 | #define _MAX_EXT _MAX_FNAME | |
44 | #define _MAX_PATH 260 | |
45 | #endif | |
46 | ||
47 | ||
03774624 | 48 | typedef struct _div_t { |
eee695dd FG |
49 | int quot; |
50 | int rem; | |
03774624 | 51 | } div_t; |
eee695dd | 52 | |
03774624 | 53 | typedef struct _ldiv_t { |
eee695dd FG |
54 | long quot; |
55 | long rem; | |
03774624 | 56 | } ldiv_t; |
eee695dd | 57 | |
03774624 DP |
58 | #ifndef _SIZE_T_DEFINED |
59 | typedef unsigned int size_t; | |
60 | #define _SIZE_T_DEFINED | |
3f5ff2fb | 61 | #endif |
eee695dd FG |
62 | |
63 | #define __max(a,b) (((a) > (b)) ? (a) : (b)) | |
64 | #define __min(a,b) (((a) < (b)) ? (a) : (b)) | |
65 | #ifndef __cplusplus | |
66 | #define max(a,b) (((a) > (b)) ? (a) : (b)) | |
67 | #define min(a,b) (((a) < (b)) ? (a) : (b)) | |
68 | #endif | |
69 | ||
79027d16 FG |
70 | /* _set_error_mode() constants */ |
71 | #define _OUT_TO_DEFAULT 0 | |
72 | #define _OUT_TO_STDERR 1 | |
73 | #define _OUT_TO_MSGBOX 2 | |
74 | #define _REPORT_ERRMODE 3 | |
75 | ||
eee695dd FG |
76 | |
77 | #ifdef __cplusplus | |
78 | extern "C" { | |
79 | #endif | |
80 | ||
4056d7ef EP |
81 | extern unsigned int* __p__osver(void); |
82 | extern unsigned int* __p__winver(void); | |
83 | extern unsigned int* __p__winmajor(void); | |
84 | extern unsigned int* __p__winminor(void); | |
eee695dd FG |
85 | #define _osver (*__p__osver()) |
86 | #define _winver (*__p__winver()) | |
87 | #define _winmajor (*__p__winmajor()) | |
88 | #define _winminor (*__p__winminor()) | |
89 | ||
90 | extern int* __p___argc(void); | |
91 | extern char*** __p___argv(void); | |
03774624 | 92 | extern wchar_t*** __p___wargv(void); |
eee695dd | 93 | extern char*** __p__environ(void); |
03774624 | 94 | extern wchar_t*** __p__wenviron(void); |
eee695dd | 95 | extern int* __p___mb_cur_max(void); |
03774624 | 96 | extern unsigned long* __doserrno(void); |
eee695dd FG |
97 | extern unsigned int* __p__fmode(void); |
98 | /* FIXME: We need functions to access these: | |
99 | * int _sys_nerr; | |
100 | * char** _sys_errlist; | |
101 | */ | |
eee695dd FG |
102 | #define __argc (*__p___argc()) |
103 | #define __argv (*__p___argv()) | |
104 | #define __wargv (*__p___wargv()) | |
105 | #define _environ (*__p__environ()) | |
106 | #define _wenviron (*__p__wenviron()) | |
107 | #define __mb_cur_max (*__p___mb_cur_max()) | |
108 | #define _doserrno (*__doserrno()) | |
109 | #define _fmode (*_fmode) | |
eee695dd FG |
110 | |
111 | ||
03774624 DP |
112 | extern int* _errno(void); |
113 | #define errno (*_errno()) | |
eee695dd FG |
114 | |
115 | ||
03774624 | 116 | typedef int (*_onexit_t)(void); |
eee695dd FG |
117 | |
118 | ||
119 | __int64 _atoi64(const char*); | |
120 | long double _atold(const char*); | |
121 | void _beep(unsigned int,unsigned int); | |
122 | char* _ecvt(double,int,int*,int*); | |
123 | char* _fcvt(double,int,int*,int*); | |
03774624 | 124 | char* _fullpath(char*,const char*,size_t); |
eee695dd FG |
125 | char* _gcvt(double,int,char*); |
126 | char* _i64toa(__int64,char*,int); | |
127 | char* _itoa(int,char*,int); | |
128 | char* _ltoa(long,char*,int); | |
129 | unsigned long _lrotl(unsigned long,int); | |
130 | unsigned long _lrotr(unsigned long,int); | |
131 | void _makepath(char*,const char*,const char*,const char*,const char*); | |
03774624 DP |
132 | size_t _mbstrlen(const char*); |
133 | _onexit_t _onexit(_onexit_t); | |
eee695dd FG |
134 | int _putenv(const char*); |
135 | unsigned int _rotl(unsigned int,int); | |
136 | unsigned int _rotr(unsigned int,int); | |
137 | void _searchenv(const char*,const char*,char*); | |
138 | int _set_error_mode(int); | |
139 | void _seterrormode(int); | |
140 | void _sleep(unsigned long); | |
141 | void _splitpath(const char*,char*,char*,char*,char*); | |
142 | long double _strtold(const char*,char**); | |
03774624 | 143 | void _swab(char*,char*,int); |
eee695dd FG |
144 | char* _ui64toa(unsigned __int64,char*,int); |
145 | char* _ultoa(unsigned long,char*,int); | |
146 | ||
03774624 | 147 | void _exit(int); |
4056d7ef | 148 | void abort(void); |
03774624 DP |
149 | int abs(int); |
150 | int atexit(void (*)(void)); | |
151 | double atof(const char*); | |
152 | int atoi(const char*); | |
153 | long atol(const char*); | |
154 | void* calloc(size_t,size_t); | |
0b19a6f7 | 155 | #ifndef __i386__ |
03774624 DP |
156 | div_t div(int,int); |
157 | ldiv_t ldiv(long,long); | |
eee695dd | 158 | #endif |
03774624 DP |
159 | void exit(int); |
160 | void free(void*); | |
161 | char* getenv(const char*); | |
162 | long labs(long); | |
163 | void* malloc(size_t); | |
164 | int mblen(const char*,size_t); | |
165 | void perror(const char*); | |
166 | int rand(void); | |
167 | void* realloc(void*,size_t); | |
168 | void srand(unsigned int); | |
169 | double strtod(const char*,char**); | |
170 | long strtol(const char*,char**,int); | |
171 | unsigned long strtoul(const char*,char**,int); | |
172 | int system(const char*); | |
173 | void* bsearch(const void*,const void*,size_t,size_t, | |
3fd4087d | 174 | int (*)(const void*,const void*)); |
03774624 | 175 | void qsort(void*,size_t,size_t, |
3fd4087d | 176 | int (*)(const void*,const void*)); |
eee695dd | 177 | |
03774624 DP |
178 | #ifndef _WSTDLIB_DEFINED |
179 | #define _WSTDLIB_DEFINED | |
180 | wchar_t*_itow(int,wchar_t*,int); | |
181 | wchar_t*_i64tow(__int64,wchar_t*,int); | |
182 | wchar_t*_ltow(long,wchar_t*,int); | |
183 | wchar_t*_ui64tow(unsigned __int64,wchar_t*,int); | |
184 | wchar_t*_ultow(unsigned long,wchar_t*,int); | |
185 | wchar_t*_wfullpath(wchar_t*,const wchar_t*,size_t); | |
186 | wchar_t*_wgetenv(const wchar_t*); | |
187 | void _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*); | |
188 | void _wperror(const wchar_t*); | |
189 | int _wputenv(const wchar_t*); | |
190 | void _wsearchenv(const wchar_t*,const wchar_t*,wchar_t*); | |
191 | void _wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wchar_t*); | |
192 | int _wsystem(const wchar_t*); | |
193 | int _wtoi(const wchar_t*); | |
194 | __int64 _wtoi64(const wchar_t*); | |
195 | long _wtol(const wchar_t*); | |
196 | ||
197 | size_t mbstowcs(wchar_t*,const char*,size_t); | |
198 | int mbtowc(wchar_t*,const char*,size_t); | |
199 | double wcstod(const wchar_t*,wchar_t**); | |
200 | long wcstol(const wchar_t*,wchar_t**,int); | |
201 | size_t wcstombs(char*,const wchar_t*,size_t); | |
202 | unsigned long wcstoul(const wchar_t*,wchar_t**,int); | |
203 | int wctomb(char*,wchar_t); | |
204 | #endif /* _WSTDLIB_DEFINED */ | |
eee695dd FG |
205 | |
206 | #ifdef __cplusplus | |
207 | } | |
208 | #endif | |
209 | ||
210 | ||
eee695dd FG |
211 | #define environ _environ |
212 | #define onexit_t _onexit_t | |
213 | ||
992d1b99 MS |
214 | static inline char* ecvt(double value, int ndigit, int* decpt, int* sign) { return _ecvt(value, ndigit, decpt, sign); } |
215 | static inline char* fcvt(double value, int ndigit, int* decpt, int* sign) { return _fcvt(value, ndigit, decpt, sign); } | |
216 | static inline char* gcvt(double value, int ndigit, char* buf) { return _gcvt(value, ndigit, buf); } | |
217 | static inline char* itoa(int value, char* str, int radix) { return _itoa(value, str, radix); } | |
218 | static inline char* ltoa(long value, char* str, int radix) { return _ltoa(value, str, radix); } | |
219 | static inline _onexit_t onexit(_onexit_t func) { return _onexit(func); } | |
220 | static inline int putenv(const char* str) { return _putenv(str); } | |
5f175508 | 221 | static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); } |
992d1b99 | 222 | static inline char* ultoa(unsigned long value, char* str, int radix) { return _ultoa(value, str, radix); } |
0b19a6f7 AJ |
223 | |
224 | #ifdef __i386__ | |
225 | static inline div_t __wine_msvcrt_div(int num, int denom) | |
226 | { | |
227 | extern unsigned __int64 div(int,int); | |
228 | div_t ret; | |
229 | unsigned __int64 res = div(num,denom); | |
230 | ret.quot = (int)res; | |
231 | ret.rem = (int)(res >> 32); | |
232 | return ret; | |
233 | } | |
234 | static inline ldiv_t __wine_msvcrt_ldiv(long num, long denom) | |
235 | { | |
236 | extern unsigned __int64 ldiv(long,long); | |
237 | ldiv_t ret; | |
238 | unsigned __int64 res = ldiv(num,denom); | |
239 | ret.quot = (long)res; | |
240 | ret.rem = (long)(res >> 32); | |
241 | return ret; | |
242 | } | |
243 | #define div(num,denom) __wine_msvcrt_div(num,denom) | |
244 | #define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom) | |
245 | #endif | |
246 | ||
eee695dd | 247 | #endif /* __WINE_STDLIB_H */ |