Portability fixes.
[wine/gsoc_dplay.git] / include / msvcrt / stdlib.h
blob7b640a2fb1cefe7508f0c156981f8f07ec879f0c
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
10 #ifndef __WINE_USE_MSVCRT
11 #define __WINE_USE_MSVCRT
12 #endif
14 #ifndef MSVCRT
15 # ifdef USE_MSVCRT_PREFIX
16 # define MSVCRT(x) MSVCRT_##x
17 # else
18 # define MSVCRT(x) x
19 # endif
20 #endif
22 #ifndef NULL
23 #ifdef __cplusplus
24 #define NULL 0
25 #else
26 #define NULL ((void*)0)
27 #endif
28 #endif
30 #ifndef MSVCRT_WCHAR_T_DEFINED
31 #define MSVCRT_WCHAR_T_DEFINED
32 #ifndef __cplusplus
33 typedef unsigned short MSVCRT(wchar_t);
34 #endif
35 #endif
37 #ifndef _MSC_VER
38 # ifndef __int64
39 # define __int64 long long
40 # endif
41 #endif
43 #ifndef USE_MSVCRT_PREFIX
44 #define EXIT_SUCCESS 0
45 #define EXIT_FAILURE -1
46 #define RAND_MAX 0x7FFF
47 #else
48 #define MSVCRT_RAND_MAX 0x7FFF
49 #endif /* USE_MSVCRT_PREFIX */
51 #ifndef _MAX_PATH
52 #define _MAX_DRIVE 3
53 #define _MAX_FNAME 256
54 #define _MAX_DIR _MAX_FNAME
55 #define _MAX_EXT _MAX_FNAME
56 #define _MAX_PATH 260
57 #endif
60 typedef struct MSVCRT(_div_t) {
61 int quot;
62 int rem;
63 } MSVCRT(div_t);
65 typedef struct MSVCRT(_ldiv_t) {
66 long quot;
67 long rem;
68 } MSVCRT(ldiv_t);
70 #ifndef MSVCRT_SIZE_T_DEFINED
71 typedef unsigned int MSVCRT(size_t);
72 #define MSVCRT_SIZE_T_DEFINED
73 #endif
75 #define __max(a,b) (((a) > (b)) ? (a) : (b))
76 #define __min(a,b) (((a) < (b)) ? (a) : (b))
77 #ifndef __cplusplus
78 #define max(a,b) (((a) > (b)) ? (a) : (b))
79 #define min(a,b) (((a) < (b)) ? (a) : (b))
80 #endif
82 /* _set_error_mode() constants */
83 #define _OUT_TO_DEFAULT 0
84 #define _OUT_TO_STDERR 1
85 #define _OUT_TO_MSGBOX 2
86 #define _REPORT_ERRMODE 3
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
93 extern unsigned int* __p__osver();
94 extern unsigned int* __p__winver();
95 extern unsigned int* __p__winmajor();
96 extern unsigned int* __p__winminor();
97 #define _osver (*__p__osver())
98 #define _winver (*__p__winver())
99 #define _winmajor (*__p__winmajor())
100 #define _winminor (*__p__winminor())
102 extern int* __p___argc(void);
103 extern char*** __p___argv(void);
104 extern MSVCRT(wchar_t)*** __p___wargv(void);
105 extern char*** __p__environ(void);
106 extern MSVCRT(wchar_t)*** __p__wenviron(void);
107 extern int* __p___mb_cur_max(void);
108 extern unsigned long* __doserrno(void);
109 extern unsigned int* __p__fmode(void);
110 /* FIXME: We need functions to access these:
111 * int _sys_nerr;
112 * char** _sys_errlist;
114 #ifndef USE_MSVCRT_PREFIX
115 #define __argc (*__p___argc())
116 #define __argv (*__p___argv())
117 #define __wargv (*__p___wargv())
118 #define _environ (*__p__environ())
119 #define _wenviron (*__p__wenviron())
120 #define __mb_cur_max (*__p___mb_cur_max())
121 #define _doserrno (*__doserrno())
122 #define _fmode (*_fmode)
123 #endif /* USE_MSVCRT_PREFIX */
126 extern int* MSVCRT(_errno)(void);
127 #ifndef USE_MSVCRT_PREFIX
128 # define errno (*_errno())
129 #else
130 # define MSVCRT_errno (*MSVCRT__errno())
131 #endif
134 typedef int (*_onexit_t)(void);
137 __int64 _atoi64(const char*);
138 long double _atold(const char*);
139 void _beep(unsigned int,unsigned int);
140 char* _ecvt(double,int,int*,int*);
141 char* _fcvt(double,int,int*,int*);
142 char* _fullpath(char*,const char*,MSVCRT(size_t));
143 char* _gcvt(double,int,char*);
144 char* _i64toa(__int64,char*,int);
145 char* _itoa(int,char*,int);
146 char* _ltoa(long,char*,int);
147 unsigned long _lrotl(unsigned long,int);
148 unsigned long _lrotr(unsigned long,int);
149 void _makepath(char*,const char*,const char*,const char*,const char*);
150 MSVCRT(size_t) _mbstrlen(const char*);
151 _onexit_t _onexit(_onexit_t);
152 int _putenv(const char*);
153 unsigned int _rotl(unsigned int,int);
154 unsigned int _rotr(unsigned int,int);
155 void _searchenv(const char*,const char*,char*);
156 int _set_error_mode(int);
157 void _seterrormode(int);
158 void _sleep(unsigned long);
159 void _splitpath(const char*,char*,char*,char*,char*);
160 long double _strtold(const char*,char**);
161 void _swab(char*,char*,int);
162 char* _ui64toa(unsigned __int64,char*,int);
163 char* _ultoa(unsigned long,char*,int);
165 void MSVCRT(_exit)(int);
166 void MSVCRT(abort)();
167 int MSVCRT(abs)(int);
168 int MSVCRT(atexit)(void (*)(void));
169 double MSVCRT(atof)(const char*);
170 int MSVCRT(atoi)(const char*);
171 long MSVCRT(atol)(const char*);
172 void* MSVCRT(calloc)(MSVCRT(size_t),MSVCRT(size_t));
173 #ifdef __i386__
174 __int64 MSVCRT(div)(int,int);
175 unsigned __int64 MSVCRT(ldiv)(long,long);
176 #else
177 MSVCRT(div_t) MSVCRT(div)(int,int);
178 MSVCRT(ldiv_t) MSVCRT(ldiv)(long,long);
179 #endif
180 void MSVCRT(exit)(int);
181 void MSVCRT(free)(void*);
182 char* MSVCRT(getenv)(const char*);
183 long MSVCRT(labs)(long);
184 void* MSVCRT(malloc)(MSVCRT(size_t));
185 int MSVCRT(mblen)(const char*,MSVCRT(size_t));
186 void MSVCRT(perror)(const char*);
187 int MSVCRT(rand)(void);
188 void* MSVCRT(realloc)(void*,MSVCRT(size_t));
189 void MSVCRT(srand)(unsigned int);
190 double MSVCRT(strtod)(const char*,char**);
191 long MSVCRT(strtol)(const char*,char**,int);
192 unsigned long MSVCRT(strtoul)(const char*,char**,int);
193 int MSVCRT(system)(const char*);
194 void* MSVCRT(bsearch)(const void*,const void*,MSVCRT(size_t),MSVCRT(size_t),
195 int (*)(const void*,const void*));
196 void MSVCRT(qsort)(void*,MSVCRT(size_t),MSVCRT(size_t),
197 int (*)(const void*,const void*));
199 #ifndef MSVCRT_WSTDLIB_DEFINED
200 #define MSVCRT_WSTDLIB_DEFINED
201 MSVCRT(wchar_t)*_itow(int,MSVCRT(wchar_t)*,int);
202 MSVCRT(wchar_t)*_i64tow(__int64,MSVCRT(wchar_t)*,int);
203 MSVCRT(wchar_t)*_ltow(long,MSVCRT(wchar_t)*,int);
204 MSVCRT(wchar_t)*_ui64tow(unsigned __int64,MSVCRT(wchar_t)*,int);
205 MSVCRT(wchar_t)*_ultow(unsigned long,MSVCRT(wchar_t)*,int);
206 MSVCRT(wchar_t)*_wfullpath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,size_t);
207 MSVCRT(wchar_t)*_wgetenv(const MSVCRT(wchar_t)*);
208 void _wmakepath(MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*);
209 void _wperror(const MSVCRT(wchar_t)*);
210 int _wputenv(const MSVCRT(wchar_t)*);
211 void _wsearchenv(const MSVCRT(wchar_t)*,const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*);
212 void _wsplitpath(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*,MSVCRT(wchar_t)*);
213 int _wsystem(const MSVCRT(wchar_t)*);
214 int _wtoi(const MSVCRT(wchar_t)*);
215 __int64 _wtoi64(const MSVCRT(wchar_t)*);
216 long _wtol(const MSVCRT(wchar_t)*);
218 MSVCRT(size_t) MSVCRT(mbstowcs)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t));
219 int MSVCRT(mbtowc)(MSVCRT(wchar_t)*,const char*,MSVCRT(size_t));
220 double MSVCRT(wcstod)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**);
221 long MSVCRT(wcstol)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int);
222 MSVCRT(size_t) MSVCRT(wcstombs)(char*,const MSVCRT(wchar_t)*,MSVCRT(size_t));
223 unsigned long MSVCRT(wcstoul)(const MSVCRT(wchar_t)*,MSVCRT(wchar_t)**,int);
224 int MSVCRT(wctomb)(char*,MSVCRT(wchar_t));
225 #endif /* MSVCRT_WSTDLIB_DEFINED */
227 #ifdef __cplusplus
229 #endif
232 #ifndef USE_MSVCRT_PREFIX
233 #define environ _environ
234 #define onexit_t _onexit_t
236 static inline char* ecvt(double value, int ndigit, int* decpt, int* sign) { return _ecvt(value, ndigit, decpt, sign); }
237 static inline char* fcvt(double value, int ndigit, int* decpt, int* sign) { return _fcvt(value, ndigit, decpt, sign); }
238 static inline char* gcvt(double value, int ndigit, char* buf) { return _gcvt(value, ndigit, buf); }
239 static inline char* itoa(int value, char* str, int radix) { return _itoa(value, str, radix); }
240 static inline char* ltoa(long value, char* str, int radix) { return _ltoa(value, str, radix); }
241 static inline _onexit_t onexit(_onexit_t func) { return _onexit(func); }
242 static inline int putenv(const char* str) { return _putenv(str); }
243 static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); }
244 static inline char* ultoa(unsigned long value, char* str, int radix) { return _ultoa(value, str, radix); }
245 #endif /* USE_MSVCRT_PREFIX */
247 #endif /* __WINE_STDLIB_H */