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