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;
31 #if !defined(_MSC_VER) && !defined(__int64)
32 #define __int64 long long
35 #define EXIT_SUCCESS 0
36 #define EXIT_FAILURE -1
37 #define RAND_MAX 0x7FFF
41 #define _MAX_FNAME 256
42 #define _MAX_DIR _MAX_FNAME
43 #define _MAX_EXT _MAX_FNAME
48 typedef struct _div_t
{
53 typedef struct _ldiv_t
{
58 #ifndef _SIZE_T_DEFINED
60 typedef unsigned __int64
size_t;
62 typedef unsigned int size_t;
64 #define _SIZE_T_DEFINED
67 #define __max(a,b) (((a) > (b)) ? (a) : (b))
68 #define __min(a,b) (((a) < (b)) ? (a) : (b))
70 #define max(a,b) (((a) > (b)) ? (a) : (b))
71 #define min(a,b) (((a) < (b)) ? (a) : (b))
74 /* _set_error_mode() constants */
75 #define _OUT_TO_DEFAULT 0
76 #define _OUT_TO_STDERR 1
77 #define _OUT_TO_MSGBOX 2
78 #define _REPORT_ERRMODE 3
85 extern unsigned int* __p__osver(void);
86 extern unsigned int* __p__winver(void);
87 extern unsigned int* __p__winmajor(void);
88 extern unsigned int* __p__winminor(void);
89 #define _osver (*__p__osver())
90 #define _winver (*__p__winver())
91 #define _winmajor (*__p__winmajor())
92 #define _winminor (*__p__winminor())
94 extern int* __p___argc(void);
95 extern char*** __p___argv(void);
96 extern wchar_t*** __p___wargv(void);
97 extern char*** __p__environ(void);
98 extern wchar_t*** __p__wenviron(void);
99 extern int* __p___mb_cur_max(void);
100 extern unsigned long* __doserrno(void);
101 extern unsigned int* __p__fmode(void);
102 /* FIXME: We need functions to access these:
104 * char** _sys_errlist;
106 #define __argc (*__p___argc())
107 #define __argv (*__p___argv())
108 #define __wargv (*__p___wargv())
109 #define _environ (*__p__environ())
110 #define _wenviron (*__p__wenviron())
111 #define __mb_cur_max (*__p___mb_cur_max())
112 #define _doserrno (*__doserrno())
113 #define _fmode (*_fmode)
116 extern int* _errno(void);
117 #define errno (*_errno())
120 typedef int (*_onexit_t
)(void);
123 __int64
_atoi64(const char*);
124 long double _atold(const char*);
125 void _beep(unsigned int,unsigned int);
126 char* _ecvt(double,int,int*,int*);
127 char* _fcvt(double,int,int*,int*);
128 char* _fullpath(char*,const char*,size_t);
129 char* _gcvt(double,int,char*);
130 char* _i64toa(__int64
,char*,int);
131 char* _itoa(int,char*,int);
132 char* _ltoa(long,char*,int);
133 unsigned long _lrotl(unsigned long,int);
134 unsigned long _lrotr(unsigned long,int);
135 void _makepath(char*,const char*,const char*,const char*,const char*);
136 size_t _mbstrlen(const char*);
137 _onexit_t
_onexit(_onexit_t
);
138 int _putenv(const char*);
139 unsigned int _rotl(unsigned int,int);
140 unsigned int _rotr(unsigned int,int);
141 void _searchenv(const char*,const char*,char*);
142 int _set_error_mode(int);
143 void _seterrormode(int);
144 void _sleep(unsigned long);
145 void _splitpath(const char*,char*,char*,char*,char*);
146 long double _strtold(const char*,char**);
147 void _swab(char*,char*,int);
148 char* _ui64toa(unsigned __int64
,char*,int);
149 char* _ultoa(unsigned long,char*,int);
154 int atexit(void (*)(void));
155 double atof(const char*);
156 int atoi(const char*);
157 long atol(const char*);
158 void* calloc(size_t,size_t);
161 ldiv_t ldiv(long,long);
165 char* getenv(const char*);
167 void* malloc(size_t);
168 int mblen(const char*,size_t);
169 void perror(const char*);
171 void* realloc(void*,size_t);
172 void srand(unsigned int);
173 double strtod(const char*,char**);
174 long strtol(const char*,char**,int);
175 unsigned long strtoul(const char*,char**,int);
176 int system(const char*);
177 void* bsearch(const void*,const void*,size_t,size_t,
178 int (*)(const void*,const void*));
179 void qsort(void*,size_t,size_t,
180 int (*)(const void*,const void*));
182 #ifndef _WSTDLIB_DEFINED
183 #define _WSTDLIB_DEFINED
184 wchar_t*_itow(int,wchar_t*,int);
185 wchar_t*_i64tow(__int64
,wchar_t*,int);
186 wchar_t*_ltow(long,wchar_t*,int);
187 wchar_t*_ui64tow(unsigned __int64
,wchar_t*,int);
188 wchar_t*_ultow(unsigned long,wchar_t*,int);
189 wchar_t*_wfullpath(wchar_t*,const wchar_t*,size_t);
190 wchar_t*_wgetenv(const wchar_t*);
191 void _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*);
192 void _wperror(const wchar_t*);
193 int _wputenv(const wchar_t*);
194 void _wsearchenv(const wchar_t*,const wchar_t*,wchar_t*);
195 void _wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wchar_t*);
196 int _wsystem(const wchar_t*);
197 int _wtoi(const wchar_t*);
198 __int64
_wtoi64(const wchar_t*);
199 long _wtol(const wchar_t*);
201 size_t mbstowcs(wchar_t*,const char*,size_t);
202 int mbtowc(wchar_t*,const char*,size_t);
203 double wcstod(const wchar_t*,wchar_t**);
204 long wcstol(const wchar_t*,wchar_t**,int);
205 size_t wcstombs(char*,const wchar_t*,size_t);
206 unsigned long wcstoul(const wchar_t*,wchar_t**,int);
207 int wctomb(char*,wchar_t);
208 #endif /* _WSTDLIB_DEFINED */
215 #define environ _environ
216 #define onexit_t _onexit_t
218 static inline char* ecvt(double value
, int ndigit
, int* decpt
, int* sign
) { return _ecvt(value
, ndigit
, decpt
, sign
); }
219 static inline char* fcvt(double value
, int ndigit
, int* decpt
, int* sign
) { return _fcvt(value
, ndigit
, decpt
, sign
); }
220 static inline char* gcvt(double value
, int ndigit
, char* buf
) { return _gcvt(value
, ndigit
, buf
); }
221 static inline char* itoa(int value
, char* str
, int radix
) { return _itoa(value
, str
, radix
); }
222 static inline char* ltoa(long value
, char* str
, int radix
) { return _ltoa(value
, str
, radix
); }
223 static inline _onexit_t
onexit(_onexit_t func
) { return _onexit(func
); }
224 static inline int putenv(const char* str
) { return _putenv(str
); }
225 static inline void swab(char* src
, char* dst
, int len
) { _swab(src
, dst
, len
); }
226 static inline char* ultoa(unsigned long value
, char* str
, int radix
) { return _ultoa(value
, str
, radix
); }
229 static inline div_t __wine_msvcrt_div(int num
, int denom
)
231 extern unsigned __int64
div(int,int);
233 unsigned __int64 res
= div(num
,denom
);
235 ret
.rem
= (int)(res
>> 32);
238 static inline ldiv_t __wine_msvcrt_ldiv(long num
, long denom
)
240 extern unsigned __int64
ldiv(long,long);
242 unsigned __int64 res
= ldiv(num
,denom
);
243 ret
.quot
= (long)res
;
244 ret
.rem
= (long)(res
>> 32);
247 #define div(num,denom) __wine_msvcrt_div(num,denom)
248 #define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom)
253 #endif /* __WINE_STDLIB_H */