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
19 #define NULL ((void*)0)
38 #define EXIT_SUCCESS 0
39 #define EXIT_FAILURE -1
40 #define RAND_MAX 0x7FFF
44 #define _MAX_FNAME 256
45 #define _MAX_DIR _MAX_FNAME
46 #define _MAX_EXT _MAX_FNAME
51 typedef struct _div_t
{
56 typedef struct _ldiv_t
{
61 #define __max(a,b) (((a) > (b)) ? (a) : (b))
62 #define __min(a,b) (((a) < (b)) ? (a) : (b))
64 #define max(a,b) (((a) > (b)) ? (a) : (b))
65 #define min(a,b) (((a) < (b)) ? (a) : (b))
68 /* _set_error_mode() constants */
69 #define _OUT_TO_DEFAULT 0
70 #define _OUT_TO_STDERR 1
71 #define _OUT_TO_MSGBOX 2
72 #define _REPORT_ERRMODE 3
81 extern unsigned int* __cdecl
__p__osver(void);
82 #define _osver (*__p__osver())
83 extern unsigned int* __cdecl
__p__winver(void);
84 #define _winver (*__p__winver())
85 extern unsigned int* __cdecl
__p__winmajor(void);
86 #define _winmajor (*__p__winmajor())
87 extern unsigned int* __cdecl
__p__winminor(void);
88 #define _winminor (*__p__winminor())
89 extern int* __cdecl
__p___argc(void);
90 #define __argc (*__p___argc())
91 extern char*** __cdecl
__p___argv(void);
92 #define __argv (*__p___argv())
93 extern wchar_t*** __cdecl
__p___wargv(void);
94 #define __wargv (*__p___wargv())
95 extern char*** __cdecl
__p__environ(void);
96 #define _environ (*__p__environ())
97 extern wchar_t*** __cdecl
__p__wenviron(void);
98 #define _wenviron (*__p__wenviron())
99 extern unsigned int* __cdecl
__p__fmode(void);
100 #define _fmode (*__p__fmode())
104 extern unsigned int _osver
;
105 extern unsigned int _winver
;
106 extern unsigned int _winmajor
;
107 extern unsigned int _winminor
;
109 extern char **__argv
;
110 extern wchar_t **__wargv
;
111 extern char **_environ
;
112 extern wchar_t **_wenviron
;
113 extern unsigned int _fmode
;
115 #endif /* __i386__ */
117 extern int* __cdecl
___mb_cur_max_func(void);
118 #define __mb_cur_max (*___mb_cur_max_func())
119 extern unsigned long* __cdecl
__doserrno(void);
120 #define _doserrno (*__doserrno())
121 extern int* __cdecl
_errno(void);
122 #define errno (*_errno())
124 /* FIXME: We need functions to access these:
126 * char** _sys_errlist;
130 typedef int (__cdecl
*_onexit_t
)(void);
133 int __cdecl
_atodbl(_CRT_DOUBLE
*,char*);
134 int __cdecl
_atoflt(_CRT_FLOAT
*,char*);
135 __int64 __cdecl
_atoi64(const char*);
136 long double __cdecl
_atold(const char*);
137 int __cdecl
_atoldbl(_LDOUBLE
*,char*);
138 void __cdecl
_beep(unsigned int,unsigned int);
139 char* __cdecl
_ecvt(double,int,int*,int*);
140 char* __cdecl
_fcvt(double,int,int*,int*);
141 char* __cdecl
_fullpath(char*,const char*,size_t);
142 char* __cdecl
_gcvt(double,int,char*);
143 char* __cdecl
_i64toa(__int64
,char*,int);
144 char* __cdecl
_itoa(int,char*,int);
145 char* __cdecl
_ltoa(long,char*,int);
146 unsigned long __cdecl
_lrotl(unsigned long,int);
147 unsigned long __cdecl
_lrotr(unsigned long,int);
148 void __cdecl
_makepath(char*,const char*,const char*,const char*,const char*);
149 size_t __cdecl
_mbstrlen(const char*);
150 _onexit_t __cdecl
_onexit(_onexit_t
);
151 int __cdecl
_putenv(const char*);
152 unsigned int __cdecl
_rotl(unsigned int,int);
153 unsigned int __cdecl
_rotr(unsigned int,int);
154 void __cdecl
_searchenv(const char*,const char*,char*);
155 int __cdecl
_set_error_mode(int);
156 void __cdecl
_seterrormode(int);
157 void __cdecl
_sleep(unsigned long);
158 void __cdecl
_splitpath(const char*,char*,char*,char*,char*);
159 long double __cdecl
_strtold(const char*,char**);
160 void __cdecl
_swab(char*,char*,int);
161 char* __cdecl
_ui64toa(unsigned __int64
,char*,int);
162 char* __cdecl
_ultoa(unsigned long,char*,int);
164 void __cdecl
_exit(int);
165 void __cdecl
abort(void);
166 int __cdecl
abs(int);
167 int __cdecl
atexit(void (*)(void));
168 double __cdecl
atof(const char*);
169 int __cdecl
atoi(const char*);
170 long __cdecl
atol(const char*);
171 void* __cdecl
calloc(size_t,size_t);
173 div_t __cdecl
div(int,int);
174 ldiv_t __cdecl
ldiv(long,long);
176 void __cdecl
exit(int);
177 void __cdecl
free(void*);
178 char* __cdecl
getenv(const char*);
179 long __cdecl
labs(long);
180 void* __cdecl
malloc(size_t);
181 int __cdecl
mblen(const char*,size_t);
182 void __cdecl
perror(const char*);
183 int __cdecl
rand(void);
184 void* __cdecl
realloc(void*,size_t);
185 void __cdecl
srand(unsigned int);
186 double __cdecl
strtod(const char*,char**);
187 long __cdecl
strtol(const char*,char**,int);
188 unsigned long __cdecl
strtoul(const char*,char**,int);
189 int __cdecl
system(const char*);
190 void* __cdecl
bsearch(const void*,const void*,size_t,size_t,int (*)(const void*,const void*));
191 void __cdecl
qsort(void*,size_t,size_t,int (*)(const void*,const void*));
193 #ifndef _WSTDLIB_DEFINED
194 #define _WSTDLIB_DEFINED
195 wchar_t* __cdecl
_itow(int,wchar_t*,int);
196 wchar_t* __cdecl
_i64tow(__int64
,wchar_t*,int);
197 wchar_t* __cdecl
_ltow(long,wchar_t*,int);
198 wchar_t* __cdecl
_ui64tow(unsigned __int64
,wchar_t*,int);
199 wchar_t* __cdecl
_ultow(unsigned long,wchar_t*,int);
200 wchar_t* __cdecl
_wfullpath(wchar_t*,const wchar_t*,size_t);
201 wchar_t* __cdecl
_wgetenv(const wchar_t*);
202 void __cdecl
_wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*);
203 void __cdecl
_wperror(const wchar_t*);
204 int __cdecl
_wputenv(const wchar_t*);
205 void __cdecl
_wsearchenv(const wchar_t*,const wchar_t*,wchar_t*);
206 void __cdecl
_wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wchar_t*);
207 int __cdecl
_wsystem(const wchar_t*);
208 int __cdecl
_wtoi(const wchar_t*);
209 __int64 __cdecl
_wtoi64(const wchar_t*);
210 long __cdecl
_wtol(const wchar_t*);
212 size_t __cdecl
mbstowcs(wchar_t*,const char*,size_t);
213 int __cdecl
mbtowc(wchar_t*,const char*,size_t);
214 double __cdecl
wcstod(const wchar_t*,wchar_t**);
215 long __cdecl
wcstol(const wchar_t*,wchar_t**,int);
216 size_t __cdecl
wcstombs(char*,const wchar_t*,size_t);
217 unsigned long __cdecl
wcstoul(const wchar_t*,wchar_t**,int);
218 int __cdecl
wctomb(char*,wchar_t);
219 #endif /* _WSTDLIB_DEFINED */
226 #define environ _environ
227 #define onexit_t _onexit_t
229 static inline char* ecvt(double value
, int ndigit
, int* decpt
, int* sign
) { return _ecvt(value
, ndigit
, decpt
, sign
); }
230 static inline char* fcvt(double value
, int ndigit
, int* decpt
, int* sign
) { return _fcvt(value
, ndigit
, decpt
, sign
); }
231 static inline char* gcvt(double value
, int ndigit
, char* buf
) { return _gcvt(value
, ndigit
, buf
); }
232 static inline char* itoa(int value
, char* str
, int radix
) { return _itoa(value
, str
, radix
); }
233 static inline char* ltoa(long value
, char* str
, int radix
) { return _ltoa(value
, str
, radix
); }
234 static inline _onexit_t
onexit(_onexit_t func
) { return _onexit(func
); }
235 static inline int putenv(const char* str
) { return _putenv(str
); }
236 static inline void swab(char* src
, char* dst
, int len
) { _swab(src
, dst
, len
); }
237 static inline char* ultoa(unsigned long value
, char* str
, int radix
) { return _ultoa(value
, str
, radix
); }
240 static inline div_t __wine_msvcrt_div(int num
, int denom
)
242 extern unsigned __int64
div(int,int);
244 unsigned __int64 res
= div(num
,denom
);
246 ret
.rem
= (int)(res
>> 32);
249 static inline ldiv_t __wine_msvcrt_ldiv(long num
, long denom
)
251 extern unsigned __int64
ldiv(long,long);
253 unsigned __int64 res
= ldiv(num
,denom
);
254 ret
.quot
= (long)res
;
255 ret
.rem
= (long)(res
>> 32);
258 #define div(num,denom) __wine_msvcrt_div(num,denom)
259 #define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom)
264 #endif /* __WINE_STDLIB_H */