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