include: Add the msvcrt/crtdefs.h header and include it where needed.
[wine/wine64.git] / include / msvcrt / stdlib.h
blob65c61a2b04e16d0946ee47afcb12d103f2606cf7
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 <crtdefs.h>
13 #include <pshpack8.h>
15 #ifndef NULL
16 #ifdef __cplusplus
17 #define NULL 0
18 #else
19 #define NULL ((void*)0)
20 #endif
21 #endif
23 typedef struct
25 float f;
26 } _CRT_FLOAT;
28 typedef struct
30 double x;
31 } _CRT_DOUBLE;
33 typedef struct
35 unsigned char ld[10];
36 } _LDOUBLE;
38 #define EXIT_SUCCESS 0
39 #define EXIT_FAILURE -1
40 #define RAND_MAX 0x7FFF
42 #ifndef _MAX_PATH
43 #define _MAX_DRIVE 3
44 #define _MAX_FNAME 256
45 #define _MAX_DIR _MAX_FNAME
46 #define _MAX_EXT _MAX_FNAME
47 #define _MAX_PATH 260
48 #endif
51 typedef struct _div_t {
52 int quot;
53 int rem;
54 } div_t;
56 typedef struct _ldiv_t {
57 long quot;
58 long rem;
59 } ldiv_t;
61 #define __max(a,b) (((a) > (b)) ? (a) : (b))
62 #define __min(a,b) (((a) < (b)) ? (a) : (b))
63 #ifndef __cplusplus
64 #define max(a,b) (((a) > (b)) ? (a) : (b))
65 #define min(a,b) (((a) < (b)) ? (a) : (b))
66 #endif
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
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
79 extern unsigned int* __p__osver(void);
80 extern unsigned int* __p__winver(void);
81 extern unsigned int* __p__winmajor(void);
82 extern unsigned int* __p__winminor(void);
83 #define _osver (*__p__osver())
84 #define _winver (*__p__winver())
85 #define _winmajor (*__p__winmajor())
86 #define _winminor (*__p__winminor())
88 extern int* __p___argc(void);
89 extern char*** __p___argv(void);
90 extern wchar_t*** __p___wargv(void);
91 extern char*** __p__environ(void);
92 extern wchar_t*** __p__wenviron(void);
93 extern int* __p___mb_cur_max(void);
94 extern unsigned long* __doserrno(void);
95 extern unsigned int* __p__fmode(void);
96 /* FIXME: We need functions to access these:
97 * int _sys_nerr;
98 * char** _sys_errlist;
100 #define __argc (*__p___argc())
101 #define __argv (*__p___argv())
102 #define __wargv (*__p___wargv())
103 #define _environ (*__p__environ())
104 #define _wenviron (*__p__wenviron())
105 #define __mb_cur_max (*__p___mb_cur_max())
106 #define _doserrno (*__doserrno())
107 #define _fmode (*_fmode)
110 extern int* _errno(void);
111 #define errno (*_errno())
114 typedef int (*_onexit_t)(void);
117 int _atodbl(_CRT_DOUBLE*,char*);
118 int _atoflt(_CRT_FLOAT*,char*);
119 __int64 _atoi64(const char*);
120 long double _atold(const char*);
121 int _atoldbl(_LDOUBLE*,char*);
122 void _beep(unsigned int,unsigned int);
123 char* _ecvt(double,int,int*,int*);
124 char* _fcvt(double,int,int*,int*);
125 char* _fullpath(char*,const char*,size_t);
126 char* _gcvt(double,int,char*);
127 char* _i64toa(__int64,char*,int);
128 char* _itoa(int,char*,int);
129 char* _ltoa(long,char*,int);
130 unsigned long _lrotl(unsigned long,int);
131 unsigned long _lrotr(unsigned long,int);
132 void _makepath(char*,const char*,const char*,const char*,const char*);
133 size_t _mbstrlen(const char*);
134 _onexit_t _onexit(_onexit_t);
135 int _putenv(const char*);
136 unsigned int _rotl(unsigned int,int);
137 unsigned int _rotr(unsigned int,int);
138 void _searchenv(const char*,const char*,char*);
139 int _set_error_mode(int);
140 void _seterrormode(int);
141 void _sleep(unsigned long);
142 void _splitpath(const char*,char*,char*,char*,char*);
143 long double _strtold(const char*,char**);
144 void _swab(char*,char*,int);
145 char* _ui64toa(unsigned __int64,char*,int);
146 char* _ultoa(unsigned long,char*,int);
148 void _exit(int);
149 void abort(void);
150 int abs(int);
151 int atexit(void (*)(void));
152 double atof(const char*);
153 int atoi(const char*);
154 long atol(const char*);
155 void* calloc(size_t,size_t);
156 #ifndef __i386__
157 div_t div(int,int);
158 ldiv_t ldiv(long,long);
159 #endif
160 void exit(int);
161 void free(void*);
162 char* getenv(const char*);
163 long labs(long);
164 void* malloc(size_t);
165 int mblen(const char*,size_t);
166 void perror(const char*);
167 int rand(void);
168 void* realloc(void*,size_t);
169 void srand(unsigned int);
170 double strtod(const char*,char**);
171 long strtol(const char*,char**,int);
172 unsigned long strtoul(const char*,char**,int);
173 int system(const char*);
174 void* bsearch(const void*,const void*,size_t,size_t,
175 int (*)(const void*,const void*));
176 void qsort(void*,size_t,size_t,
177 int (*)(const void*,const void*));
179 #ifndef _WSTDLIB_DEFINED
180 #define _WSTDLIB_DEFINED
181 wchar_t*_itow(int,wchar_t*,int);
182 wchar_t*_i64tow(__int64,wchar_t*,int);
183 wchar_t*_ltow(long,wchar_t*,int);
184 wchar_t*_ui64tow(unsigned __int64,wchar_t*,int);
185 wchar_t*_ultow(unsigned long,wchar_t*,int);
186 wchar_t*_wfullpath(wchar_t*,const wchar_t*,size_t);
187 wchar_t*_wgetenv(const wchar_t*);
188 void _wmakepath(wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*,const wchar_t*);
189 void _wperror(const wchar_t*);
190 int _wputenv(const wchar_t*);
191 void _wsearchenv(const wchar_t*,const wchar_t*,wchar_t*);
192 void _wsplitpath(const wchar_t*,wchar_t*,wchar_t*,wchar_t*,wchar_t*);
193 int _wsystem(const wchar_t*);
194 int _wtoi(const wchar_t*);
195 __int64 _wtoi64(const wchar_t*);
196 long _wtol(const wchar_t*);
198 size_t mbstowcs(wchar_t*,const char*,size_t);
199 int mbtowc(wchar_t*,const char*,size_t);
200 double wcstod(const wchar_t*,wchar_t**);
201 long wcstol(const wchar_t*,wchar_t**,int);
202 size_t wcstombs(char*,const wchar_t*,size_t);
203 unsigned long wcstoul(const wchar_t*,wchar_t**,int);
204 int wctomb(char*,wchar_t);
205 #endif /* _WSTDLIB_DEFINED */
207 #ifdef __cplusplus
209 #endif
212 #define environ _environ
213 #define onexit_t _onexit_t
215 static inline char* ecvt(double value, int ndigit, int* decpt, int* sign) { return _ecvt(value, ndigit, decpt, sign); }
216 static inline char* fcvt(double value, int ndigit, int* decpt, int* sign) { return _fcvt(value, ndigit, decpt, sign); }
217 static inline char* gcvt(double value, int ndigit, char* buf) { return _gcvt(value, ndigit, buf); }
218 static inline char* itoa(int value, char* str, int radix) { return _itoa(value, str, radix); }
219 static inline char* ltoa(long value, char* str, int radix) { return _ltoa(value, str, radix); }
220 static inline _onexit_t onexit(_onexit_t func) { return _onexit(func); }
221 static inline int putenv(const char* str) { return _putenv(str); }
222 static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); }
223 static inline char* ultoa(unsigned long value, char* str, int radix) { return _ultoa(value, str, radix); }
225 #ifdef __i386__
226 static inline div_t __wine_msvcrt_div(int num, int denom)
228 extern unsigned __int64 div(int,int);
229 div_t ret;
230 unsigned __int64 res = div(num,denom);
231 ret.quot = (int)res;
232 ret.rem = (int)(res >> 32);
233 return ret;
235 static inline ldiv_t __wine_msvcrt_ldiv(long num, long denom)
237 extern unsigned __int64 ldiv(long,long);
238 ldiv_t ret;
239 unsigned __int64 res = ldiv(num,denom);
240 ret.quot = (long)res;
241 ret.rem = (long)(res >> 32);
242 return ret;
244 #define div(num,denom) __wine_msvcrt_div(num,denom)
245 #define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom)
246 #endif
248 #include <poppack.h>
250 #endif /* __WINE_STDLIB_H */