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