2 * Standard library definitions
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.
8 #ifndef __WINE_STDLIB_H
9 #define __WINE_STDLIB_H
10 #ifndef __WINE_USE_MSVCRT
11 #define __WINE_USE_MSVCRT
20 #define NULL ((void*)0)
24 #ifndef _WCHAR_T_DEFINED
25 #define _WCHAR_T_DEFINED
27 typedef unsigned short wchar_t;
47 #if defined(__x86_64__) && !defined(_WIN64)
51 #if !defined(_MSC_VER) && !defined(__int64)
55 # define __int64 long long
59 #define EXIT_SUCCESS 0
60 #define EXIT_FAILURE -1
61 #define RAND_MAX 0x7FFF
65 #define _MAX_FNAME 256
66 #define _MAX_DIR _MAX_FNAME
67 #define _MAX_EXT _MAX_FNAME
72 typedef struct _div_t
{
77 typedef struct _ldiv_t
{
82 #ifndef _SIZE_T_DEFINED
84 typedef unsigned __int64
size_t;
86 typedef unsigned int size_t;
88 #define _SIZE_T_DEFINED
91 #define __max(a,b) (((a) > (b)) ? (a) : (b))
92 #define __min(a,b) (((a) < (b)) ? (a) : (b))
94 #define max(a,b) (((a) > (b)) ? (a) : (b))
95 #define min(a,b) (((a) < (b)) ? (a) : (b))
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
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())
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:
128 * char** _sys_errlist;
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)
140 extern int* _errno(void);
141 #define errno (*_errno())
144 typedef int (*_onexit_t
)(void);
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);
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);
188 ldiv_t ldiv(long,long);
192 char* getenv(const char*);
194 void* malloc(size_t);
195 int mblen(const char*,size_t);
196 void perror(const char*);
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*));
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*);
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 */
242 #define environ _environ
243 #define onexit_t _onexit_t
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
); }
256 static inline div_t __wine_msvcrt_div(int num
, int denom
)
258 extern unsigned __int64
div(int,int);
260 unsigned __int64 res
= div(num
,denom
);
262 ret
.rem
= (int)(res
>> 32);
265 static inline ldiv_t __wine_msvcrt_ldiv(long num
, long denom
)
267 extern unsigned __int64
ldiv(long,long);
269 unsigned __int64 res
= ldiv(num
,denom
);
270 ret
.quot
= (long)res
;
271 ret
.rem
= (long)(res
>> 32);
274 #define div(num,denom) __wine_msvcrt_div(num,denom)
275 #define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom)
280 #endif /* __WINE_STDLIB_H */