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