Enhanced robustness at startup.
[wine.git] / include / msvcrt / stdlib.h
blob11736f9ba0b7cba24579954cfe7c92623f1fe428
1 /*
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.
7 */
8 #ifndef __WINE_STDLIB_H
9 #define __WINE_STDLIB_H
11 #include "winnt.h"
13 #ifdef USE_MSVCRT_PREFIX
14 #define MSVCRT(x) MSVCRT_##x
15 #else
16 #define MSVCRT(x) x
17 #endif
20 #ifndef USE_MSVCRT_PREFIX
21 #define EXIT_SUCCESS 0
22 #define EXIT_FAILURE -1
23 #define RAND_MAX 0x7FFF
24 #else
25 #define MSVCRT_RAND_MAX 0x7FFF
26 #endif /* USE_MSVCRT_PREFIX */
28 #ifndef _MAX_PATH
29 #define _MAX_DRIVE 3
30 #define _MAX_FNAME 256
31 #define _MAX_DIR _MAX_FNAME
32 #define _MAX_EXT _MAX_FNAME
33 #define _MAX_PATH 260
34 #endif
37 #ifndef MSVCRT_SIZE_T_DEFINED
38 typedef unsigned int MSVCRT(size_t);
39 #define MSVCRT_SIZE_T_DEFINED
40 #endif
42 typedef struct MSVCRT(_div_t) {
43 int quot;
44 int rem;
45 } MSVCRT(div_t);
47 typedef struct MSVCRT(_ldiv_t) {
48 long quot;
49 long rem;
50 } MSVCRT(ldiv_t);
53 #define __max(a,b) (((a) > (b)) ? (a) : (b))
54 #define __min(a,b) (((a) < (b)) ? (a) : (b))
55 #ifndef __cplusplus
56 #define max(a,b) (((a) > (b)) ? (a) : (b))
57 #define min(a,b) (((a) < (b)) ? (a) : (b))
58 #endif
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
65 extern unsigned int* __p__osver();
66 extern unsigned int* __p__winver();
67 extern unsigned int* __p__winmajor();
68 extern unsigned int* __p__winminor();
69 #define _osver (*__p__osver())
70 #define _winver (*__p__winver())
71 #define _winmajor (*__p__winmajor())
72 #define _winminor (*__p__winminor())
74 extern int* __p___argc(void);
75 extern char*** __p___argv(void);
76 extern WCHAR*** __p___wargv(void);
77 extern char*** __p__environ(void);
78 extern WCHAR*** __p__wenviron(void);
79 extern int* __p___mb_cur_max(void);
80 extern unsigned long* __doserrno(void);
81 extern unsigned int* __p__fmode(void);
82 /* FIXME: We need functions to access these:
83 * int _sys_nerr;
84 * char** _sys_errlist;
86 #ifndef USE_MSVCRT_PREFIX
87 #define __argc (*__p___argc())
88 #define __argv (*__p___argv())
89 #define __wargv (*__p___wargv())
90 #define _environ (*__p__environ())
91 #define _wenviron (*__p__wenviron())
92 #define __mb_cur_max (*__p___mb_cur_max())
93 #define _doserrno (*__doserrno())
94 #define _fmode (*_fmode)
95 #elif !defined(__WINE__)
96 #define MSVCRT___argc (*__p___argc())
97 #define MSVCRT___argv (*__p___argv())
98 #define MSVCRT___wargv (*__p___wargv())
99 #define MSVCRT__environ (*__p__environ())
100 #define MSVCRT__wenviron (*__p__wenviron())
101 #define MSVCRT___mb_cur_max (*__p___mb_cur_max())
102 #define MSVCRT__doserrno (*__doserrno())
103 #define MSVCRT__fmode (*_fmode())
104 #endif /* USE_MSVCRT_PREFIX, __WINE__ */
107 extern int* MSVCRT(_errno)(void);
108 #ifndef USE_MSVCRT_PREFIX
109 #define errno (*_errno())
110 #elif !defined(__WINE__)
111 #define MSVCRT_errno (*MSVCRT__errno())
112 #endif /* USE_MSVCRT_PREFIX, __WINE__ */
115 typedef int (*_onexit_t)(void);
116 typedef int (*_pfunccmp_t)(const void*,const void*);
119 __int64 _atoi64(const char*);
120 long double _atold(const char*);
121 void _beep(unsigned int,unsigned int);
122 char* _ecvt(double,int,int*,int*);
123 char* _fcvt(double,int,int*,int*);
124 char* _fullpath(char*,const char*,MSVCRT(size_t));
125 char* _gcvt(double,int,char*);
126 char* _i64toa(__int64,char*,int);
127 char* _itoa(int,char*,int);
128 char* _ltoa(long,char*,int);
129 unsigned long _lrotl(unsigned long,int);
130 unsigned long _lrotr(unsigned long,int);
131 void _makepath(char*,const char*,const char*,const char*,const char*);
132 MSVCRT(size_t) _mbstrlen(const char*);
133 _onexit_t _onexit(_onexit_t);
134 int _putenv(const char*);
135 unsigned int _rotl(unsigned int,int);
136 unsigned int _rotr(unsigned int,int);
137 void _searchenv(const char*,const char*,char*);
138 int _set_error_mode(int);
139 void _seterrormode(int);
140 void _sleep(unsigned long);
141 void _splitpath(const char*,char*,char*,char*,char*);
142 long double _strtold(const char*,char**);
143 void _swab(char*,char*,int);
144 char* _ui64toa(unsigned __int64,char*,int);
145 char* _ultoa(unsigned long,char*,int);
147 void MSVCRT(_exit)(int);
148 void MSVCRT(abort)();
149 int MSVCRT(abs)(int);
150 int MSVCRT(atexit)(_onexit_t);
151 double MSVCRT(atof)(const char*);
152 int MSVCRT(atoi)(const char*);
153 long MSVCRT(atol)(const char*);
154 void* MSVCRT(bsearch)(const void*,const void*,MSVCRT(size_t),MSVCRT(size_t),_pfunccmp_t);
155 void* MSVCRT(calloc)(MSVCRT(size_t),MSVCRT(size_t));
156 #ifdef __i386__
157 LONGLONG MSVCRT(div)(int,int);
158 ULONGLONG MSVCRT(ldiv)(long,long);
159 #else
160 MSVCRT(div_t) MSVCRT(div)(int,int);
161 MSVCRT(ldiv_t) MSVCRT(ldiv)(long,long);
162 #endif
163 void MSVCRT(exit)(int);
164 void MSVCRT(free)(void*);
165 char* MSVCRT(getenv)(const char*);
166 long MSVCRT(labs)(long);
167 void* MSVCRT(malloc)(MSVCRT(size_t));
168 int MSVCRT(mblen)(const char*,MSVCRT(size_t));
169 void MSVCRT(perror)(const char*);
170 void MSVCRT(qsort)(const void*,MSVCRT(size_t),MSVCRT(size_t),_pfunccmp_t);
171 int MSVCRT(rand)(void);
172 void* MSVCRT(realloc)(void*,MSVCRT(size_t));
173 void MSVCRT(srand)(unsigned int);
174 double MSVCRT(strtod)(const char*,char**);
175 long MSVCRT(strtol)(const char*,char**,int);
176 unsigned long MSVCRT(strtoul)(const char*,char**,int);
177 int MSVCRT(system)(const char*);
179 WCHAR* _itow(int,WCHAR*,int);
180 WCHAR* _i64tow(__int64,WCHAR*,int);
181 WCHAR* _ltow(long,WCHAR*,int);
182 WCHAR* _ui64tow(unsigned __int64,WCHAR*,int);
183 WCHAR* _ultow(unsigned long,WCHAR*,int);
184 WCHAR* _wfullpath(WCHAR*,const WCHAR*,size_t);
185 WCHAR* _wgetenv(const WCHAR*);
186 void _wmakepath(WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*,const WCHAR*);
187 void _wperror(const WCHAR*);
188 int _wputenv(const WCHAR*);
189 void _wsearchenv(const WCHAR*,const WCHAR*,WCHAR*);
190 void _wsplitpath(const WCHAR*,WCHAR*,WCHAR*,WCHAR*,WCHAR*);
191 int _wsystem(const WCHAR*);
192 int _wtoi(const WCHAR*);
193 __int64 _wtoi64(const WCHAR*);
194 long _wtol(const WCHAR*);
196 MSVCRT(size_t) MSVCRT(mbstowcs)(WCHAR*,const char*,MSVCRT(size_t));
197 int MSVCRT(mbtowc)(WCHAR*,const char*,MSVCRT(size_t));
198 double MSVCRT(wcstod)(const WCHAR*,WCHAR**);
199 long MSVCRT(wcstol)(const WCHAR*,WCHAR**,int);
200 MSVCRT(size_t) MSVCRT(wcstombs)(char*,const WCHAR*,MSVCRT(size_t));
201 unsigned long MSVCRT(wcstoul)(const WCHAR*,WCHAR**,int);
202 int MSVCRT(wctomb)(char*,WCHAR);
204 #ifdef __cplusplus
206 #endif
209 #ifndef USE_MSVCRT_PREFIX
210 #define environ _environ
211 #define onexit_t _onexit_t
213 #define ecvt _ecvt
214 #define fcvt _fcvt
215 #define gcvt _gcvt
216 #define itoa _itoa
217 #define ltoa _ltoa
218 #define onexit _onexit
219 #define putenv _putenv
220 #define swab _swab
221 #define ultoa _ultoa
222 #endif /* USE_MSVCRT_PREFIX */
224 #endif /* __WINE_STDLIB_H */