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 #include "msvcrt/malloc.h" /* For size_t, malloc & co */
14 #include "msvcrt/search.h" /* For bsearch and qsort */
17 #ifndef USE_MSVCRT_PREFIX
18 #define EXIT_SUCCESS 0
19 #define EXIT_FAILURE -1
20 #define RAND_MAX 0x7FFF
22 #define MSVCRT_RAND_MAX 0x7FFF
23 #endif /* USE_MSVCRT_PREFIX */
27 #define _MAX_FNAME 256
28 #define _MAX_DIR _MAX_FNAME
29 #define _MAX_EXT _MAX_FNAME
34 typedef struct MSVCRT(_div_t
) {
39 typedef struct MSVCRT(_ldiv_t
) {
45 #define __max(a,b) (((a) > (b)) ? (a) : (b))
46 #define __min(a,b) (((a) < (b)) ? (a) : (b))
48 #define max(a,b) (((a) > (b)) ? (a) : (b))
49 #define min(a,b) (((a) < (b)) ? (a) : (b))
57 extern unsigned int* __p__osver();
58 extern unsigned int* __p__winver();
59 extern unsigned int* __p__winmajor();
60 extern unsigned int* __p__winminor();
61 #define _osver (*__p__osver())
62 #define _winver (*__p__winver())
63 #define _winmajor (*__p__winmajor())
64 #define _winminor (*__p__winminor())
66 extern int* __p___argc(void);
67 extern char*** __p___argv(void);
68 extern WCHAR
*** __p___wargv(void);
69 extern char*** __p__environ(void);
70 extern WCHAR
*** __p__wenviron(void);
71 extern int* __p___mb_cur_max(void);
72 extern unsigned long* __doserrno(void);
73 extern unsigned int* __p__fmode(void);
74 /* FIXME: We need functions to access these:
76 * char** _sys_errlist;
78 #ifndef USE_MSVCRT_PREFIX
79 #define __argc (*__p___argc())
80 #define __argv (*__p___argv())
81 #define __wargv (*__p___wargv())
82 #define _environ (*__p__environ())
83 #define _wenviron (*__p__wenviron())
84 #define __mb_cur_max (*__p___mb_cur_max())
85 #define _doserrno (*__doserrno())
86 #define _fmode (*_fmode)
87 #elif !defined(__WINE__)
88 #define MSVCRT___argc (*__p___argc())
89 #define MSVCRT___argv (*__p___argv())
90 #define MSVCRT___wargv (*__p___wargv())
91 #define MSVCRT__environ (*__p__environ())
92 #define MSVCRT__wenviron (*__p__wenviron())
93 #define MSVCRT___mb_cur_max (*__p___mb_cur_max())
94 #define MSVCRT__doserrno (*__doserrno())
95 #define MSVCRT__fmode (*_fmode())
96 #endif /* USE_MSVCRT_PREFIX, __WINE__ */
99 extern int* MSVCRT(_errno
)(void);
100 #ifndef USE_MSVCRT_PREFIX
101 #define errno (*_errno())
102 #elif !defined(__WINE__)
103 #define MSVCRT_errno (*MSVCRT__errno())
104 #endif /* USE_MSVCRT_PREFIX, __WINE__ */
107 typedef int (*_onexit_t
)(void);
110 __int64
_atoi64(const char*);
111 long double _atold(const char*);
112 void _beep(unsigned int,unsigned int);
113 char* _ecvt(double,int,int*,int*);
114 char* _fcvt(double,int,int*,int*);
115 char* _fullpath(char*,const char*,MSVCRT(size_t));
116 char* _gcvt(double,int,char*);
117 char* _i64toa(__int64
,char*,int);
118 char* _itoa(int,char*,int);
119 char* _ltoa(long,char*,int);
120 unsigned long _lrotl(unsigned long,int);
121 unsigned long _lrotr(unsigned long,int);
122 void _makepath(char*,const char*,const char*,const char*,const char*);
123 MSVCRT(size_t) _mbstrlen(const char*);
124 _onexit_t
_onexit(_onexit_t
);
125 int _putenv(const char*);
126 unsigned int _rotl(unsigned int,int);
127 unsigned int _rotr(unsigned int,int);
128 void _searchenv(const char*,const char*,char*);
129 int _set_error_mode(int);
130 void _seterrormode(int);
131 void _sleep(unsigned long);
132 void _splitpath(const char*,char*,char*,char*,char*);
133 long double _strtold(const char*,char**);
134 void _swab(char*,char*,int);
135 char* _ui64toa(unsigned __int64
,char*,int);
136 char* _ultoa(unsigned long,char*,int);
138 void MSVCRT(_exit
)(int);
139 void MSVCRT(abort
)();
140 int MSVCRT(abs
)(int);
141 int MSVCRT(atexit
)(void (*)(void));
142 double MSVCRT(atof
)(const char*);
143 int MSVCRT(atoi
)(const char*);
144 long MSVCRT(atol
)(const char*);
146 long long MSVCRT(div
)(int,int);
147 unsigned long long MSVCRT(ldiv
)(long,long);
149 MSVCRT(div_t) MSVCRT(div
)(int,int);
150 MSVCRT(ldiv_t) MSVCRT(ldiv
)(long,long);
152 void MSVCRT(exit
)(int);
153 char* MSVCRT(getenv
)(const char*);
154 long MSVCRT(labs
)(long);
155 int MSVCRT(mblen
)(const char*,MSVCRT(size_t));
156 void MSVCRT(perror
)(const char*);
157 int MSVCRT(rand
)(void);
158 void MSVCRT(srand
)(unsigned int);
159 double MSVCRT(strtod
)(const char*,char**);
160 long MSVCRT(strtol
)(const char*,char**,int);
161 unsigned long MSVCRT(strtoul
)(const char*,char**,int);
162 int MSVCRT(system
)(const char*);
164 WCHAR
* _itow(int,WCHAR
*,int);
165 WCHAR
* _i64tow(__int64
,WCHAR
*,int);
166 WCHAR
* _ltow(long,WCHAR
*,int);
167 WCHAR
* _ui64tow(unsigned __int64
,WCHAR
*,int);
168 WCHAR
* _ultow(unsigned long,WCHAR
*,int);
169 WCHAR
* _wfullpath(WCHAR
*,const WCHAR
*,size_t);
170 WCHAR
* _wgetenv(const WCHAR
*);
171 void _wmakepath(WCHAR
*,const WCHAR
*,const WCHAR
*,const WCHAR
*,const WCHAR
*);
172 void _wperror(const WCHAR
*);
173 int _wputenv(const WCHAR
*);
174 void _wsearchenv(const WCHAR
*,const WCHAR
*,WCHAR
*);
175 void _wsplitpath(const WCHAR
*,WCHAR
*,WCHAR
*,WCHAR
*,WCHAR
*);
176 int _wsystem(const WCHAR
*);
177 int _wtoi(const WCHAR
*);
178 __int64
_wtoi64(const WCHAR
*);
179 long _wtol(const WCHAR
*);
181 MSVCRT(size_t) MSVCRT(mbstowcs
)(WCHAR
*,const char*,MSVCRT(size_t));
182 int MSVCRT(mbtowc
)(WCHAR
*,const char*,MSVCRT(size_t));
183 double MSVCRT(wcstod
)(const WCHAR
*,WCHAR
**);
184 long MSVCRT(wcstol
)(const WCHAR
*,WCHAR
**,int);
185 MSVCRT(size_t) MSVCRT(wcstombs
)(char*,const WCHAR
*,MSVCRT(size_t));
186 unsigned long MSVCRT(wcstoul
)(const WCHAR
*,WCHAR
**,int);
187 int MSVCRT(wctomb
)(char*,WCHAR
);
194 #ifndef USE_MSVCRT_PREFIX
195 #define environ _environ
196 #define onexit_t _onexit_t
203 #define onexit _onexit
204 #define putenv _putenv
207 #endif /* USE_MSVCRT_PREFIX */
209 #endif /* __WINE_STDLIB_H */