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 #define __WINE_USE_MSVCRT
13 # ifdef USE_MSVCRT_PREFIX
14 # define MSVCRT(x) MSVCRT_##x
24 #define NULL ((void*)0)
28 #ifndef MSVCRT_WCHAR_T_DEFINED
29 #define MSVCRT_WCHAR_T_DEFINED
31 typedef unsigned short MSVCRT(wchar_t);
37 # define __int64 long long
41 #ifndef USE_MSVCRT_PREFIX
42 #define EXIT_SUCCESS 0
43 #define EXIT_FAILURE -1
44 #define RAND_MAX 0x7FFF
46 #define MSVCRT_RAND_MAX 0x7FFF
47 #endif /* USE_MSVCRT_PREFIX */
51 #define _MAX_FNAME 256
52 #define _MAX_DIR _MAX_FNAME
53 #define _MAX_EXT _MAX_FNAME
58 typedef struct MSVCRT(_div_t
) {
63 typedef struct MSVCRT(_ldiv_t
) {
68 #ifndef MSVCRT_SIZE_T_DEFINED
69 typedef unsigned int MSVCRT(size_t);
70 #define MSVCRT_SIZE_T_DEFINED
73 #define __max(a,b) (((a) > (b)) ? (a) : (b))
74 #define __min(a,b) (((a) < (b)) ? (a) : (b))
76 #define max(a,b) (((a) > (b)) ? (a) : (b))
77 #define min(a,b) (((a) < (b)) ? (a) : (b))
80 /* _set_error_mode() constants */
81 #define _OUT_TO_DEFAULT 0
82 #define _OUT_TO_STDERR 1
83 #define _OUT_TO_MSGBOX 2
84 #define _REPORT_ERRMODE 3
91 extern unsigned int* __p__osver();
92 extern unsigned int* __p__winver();
93 extern unsigned int* __p__winmajor();
94 extern unsigned int* __p__winminor();
95 #define _osver (*__p__osver())
96 #define _winver (*__p__winver())
97 #define _winmajor (*__p__winmajor())
98 #define _winminor (*__p__winminor())
100 extern int* __p___argc(void);
101 extern char*** __p___argv(void);
102 extern MSVCRT(wchar_t)*** __p___wargv(void);
103 extern char*** __p__environ(void);
104 extern MSVCRT(wchar_t)*** __p__wenviron(void);
105 extern int* __p___mb_cur_max(void);
106 extern unsigned long* __doserrno(void);
107 extern unsigned int* __p__fmode(void);
108 /* FIXME: We need functions to access these:
110 * char** _sys_errlist;
112 #ifndef USE_MSVCRT_PREFIX
113 #define __argc (*__p___argc())
114 #define __argv (*__p___argv())
115 #define __wargv (*__p___wargv())
116 #define _environ (*__p__environ())
117 #define _wenviron (*__p__wenviron())
118 #define __mb_cur_max (*__p___mb_cur_max())
119 #define _doserrno (*__doserrno())
120 #define _fmode (*_fmode)
121 #elif !defined(__WINE__)
122 #define MSVCRT___argc (*__p___argc())
123 #define MSVCRT___argv (*__p___argv())
124 #define MSVCRT___wargv (*__p___wargv())
125 #define MSVCRT__environ (*__p__environ())
126 #define MSVCRT__wenviron (*__p__wenviron())
127 #define MSVCRT___mb_cur_max (*__p___mb_cur_max())
128 #define MSVCRT__doserrno (*__doserrno())
129 #define MSVCRT__fmode (*_fmode())
130 #endif /* USE_MSVCRT_PREFIX, __WINE__ */
133 extern int* MSVCRT(_errno
)(void);
134 #ifndef USE_MSVCRT_PREFIX
135 # define errno (*_errno())
137 # define MSVCRT_errno (*MSVCRT__errno())
141 typedef int (*_onexit_t
)(void);
144 __int64
_atoi64(const char*);
145 long double _atold(const char*);
146 void _beep(unsigned int,unsigned int);
147 char* _ecvt(double,int,int*,int*);
148 char* _fcvt(double,int,int*,int*);
149 char* _fullpath(char*,const char*,MSVCRT(size_t));
150 char* _gcvt(double,int,char*);
151 char* _i64toa(__int64
,char*,int);
152 char* _itoa(int,char*,int);
153 char* _ltoa(long,char*,int);
154 unsigned long _lrotl(unsigned long,int);
155 unsigned long _lrotr(unsigned long,int);
156 void _makepath(char*,const char*,const char*,const char*,const char*);
157 MSVCRT(size_t) _mbstrlen(const char*);
158 _onexit_t
_onexit(_onexit_t
);
159 int _putenv(const char*);
160 unsigned int _rotl(unsigned int,int);
161 unsigned int _rotr(unsigned int,int);
162 void _searchenv(const char*,const char*,char*);
163 int _set_error_mode(int);
164 void _seterrormode(int);
165 void _sleep(unsigned long);
166 void _splitpath(const char*,char*,char*,char*,char*);
167 long double _strtold(const char*,char**);
168 void _swab(char*,char*,int);
169 char* _ui64toa(unsigned __int64
,char*,int);
170 char* _ultoa(unsigned long,char*,int);
172 void MSVCRT(_exit
)(int);
173 void MSVCRT(abort
)();
174 int MSVCRT(abs
)(int);
175 int MSVCRT(atexit
)(void (*)(void));
176 double MSVCRT(atof
)(const char*);
177 int MSVCRT(atoi
)(const char*);
178 long MSVCRT(atol
)(const char*);
179 void* MSVCRT(calloc
)(MSVCRT(size_t),MSVCRT(size_t));
181 long long MSVCRT(div
)(int,int);
182 unsigned long long MSVCRT(ldiv
)(long,long);
184 MSVCRT(div_t) MSVCRT(div
)(int,int);
185 MSVCRT(ldiv_t) MSVCRT(ldiv
)(long,long);
187 void MSVCRT(exit
)(int);
188 void MSVCRT(free
)(void*);
189 char* MSVCRT(getenv
)(const char*);
190 long MSVCRT(labs
)(long);
191 void* MSVCRT(malloc
)(MSVCRT(size_t));
192 int MSVCRT(mblen
)(const char*,MSVCRT(size_t));
193 void MSVCRT(perror
)(const char*);
194 int MSVCRT(rand
)(void);
195 void* MSVCRT(realloc
)(void*,MSVCRT(size_t));
196 void MSVCRT(srand
)(unsigned int);
197 double MSVCRT(strtod
)(const char*,char**);
198 long MSVCRT(strtol
)(const char*,char**,int);
199 unsigned long MSVCRT(strtoul
)(const char*,char**,int);
200 int MSVCRT(system
)(const char*);
202 #ifndef MSVCRT_WSTDLIB_DEFINED
203 #define MSVCRT_WSTDLIB_DEFINED
204 MSVCRT(wchar_t)*_itow(int,MSVCRT(wchar_t)*,int);
205 MSVCRT(wchar_t)*_i64tow(__int64
,MSVCRT(wchar_t)*,int);
206 MSVCRT(wchar_t)*_ltow(long,MSVCRT(wchar_t)*,int);
207 MSVCRT(wchar_t)*_ui64tow(unsigned __int64
,MSVCRT(wchar_t)*,int);
208 MSVCRT(wchar_t)*_ultow(unsigned long,MSVCRT(wchar_t)*,int);
209 MSVCRT(wchar_t)*_wfullpath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,size_t);
210 MSVCRT(wchar_t)*_wgetenv(const MSVCRT(wchar_t)*);
211 void _wmakepath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
212 void _wperror(const MSVCRT(wchar_t)*);
213 int _wputenv(const MSVCRT(wchar_t)*);
214 void _wsearchenv(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*);
215 void _wsplitpath(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*);
216 int _wsystem(const MSVCRT(wchar_t)*);
217 int _wtoi(const MSVCRT(wchar_t)*);
218 __int64
_wtoi64(const MSVCRT(wchar_t)*);
219 long _wtol(const MSVCRT(wchar_t)*);
221 MSVCRT(size_t) MSVCRT(mbstowcs
)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t));
222 int MSVCRT(mbtowc
)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t));
223 double MSVCRT(wcstod
)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**);
224 long MSVCRT(wcstol
)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int);
225 MSVCRT(size_t) MSVCRT(wcstombs
)(char*,const MSVCRT(wchar_t)*,MSVCRT(size_t));
226 unsigned long MSVCRT(wcstoul
)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int);
227 int MSVCRT(wctomb
)(char*,MSVCRT(wchar_t));
228 #endif /* MSVCRT_WSTDLIB_DEFINED */
235 #ifndef USE_MSVCRT_PREFIX
236 #define environ _environ
237 #define onexit_t _onexit_t
244 #define onexit _onexit
245 #define putenv _putenv
248 #endif /* USE_MSVCRT_PREFIX */
250 #endif /* __WINE_STDLIB_H */