4 * Definitions for common types, variables, and functions.
6 * This file is part of the Mingw32 package.
9 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 /* Appropriated for Reactos Crtdll by Ariadne */
28 /* changed definition of environ and argc */
29 /* moved prototype for swab from string.h to stdlib.h */
38 * This seems like a convenient place to declare these variables, which
39 * give programs using WinMain (or main for that matter) access to main-ish
40 * argc and argv. environ is a pointer to a table of environment variables.
41 * NOTE: Strings in _argv and environ are ANSI strings.
43 extern int* __argc_dll;
44 extern char*** __argv_dll;
45 extern char*** _environ_dll;
46 #define __argc (*__argc_dll)
47 #define __argv (*__argv_dll)
48 #define _environ (*_environ_dll)
52 #define __need_wchar_t
54 #include <msvcrt/stddef.h>
56 #include <msvcrt/mbstring.h>
58 #ifndef __ATTRIB_NORETURN
60 #define _ATTRIB_NORETURN __attribute__ ((noreturn))
62 #define __int64 long long
63 #endif /* Not __int64 */
64 #else /* Not __GNUC__ */
65 #define _ATTRIB_NORETURN
69 double atof (const char* szNumber);
70 int atoi (const char* szNumber);
71 long atol (const char* szNumber);
74 double strtod (const char* szNumber, char** pszAfterNumber);
75 double wcstod (const wchar_t* wsNumber, wchar_t** pwsAfterNumber);
76 long strtol (const char* szNumber, char** pszAfterNumber, int nBase);
77 long wcstol (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, int nBase);
79 unsigned long strtoul (const char* szNumber, char** pszAfterNumber,
81 unsigned long wcstoul (const wchar_t* wsNumber, wchar_t** pwsAfterNumber,
84 size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size);
85 int wctomb (char* mbDest, wchar_t wc);
87 int mblen (const char* mbs, size_t sizeString);
88 size_t mbstowcs (wchar_t* wcaDest, const char* mbsConvert,
90 int mbtowc (wchar_t* wcDest, const char* mbConvert, size_t size);
94 * RAND_MAX is the maximum value that may be returned by rand.
95 * The minimum is zero.
97 #define RAND_MAX 0x7FFF
100 void srand (unsigned int nSeed);
103 void* calloc (size_t sizeObjCnt, size_t sizeObject);
104 void* malloc (size_t sizeObject);
105 void* realloc (void* pObject, size_t sizeNew);
106 void free (void* pObject);
108 /* These values may be used as exit status codes. */
109 #define EXIT_SUCCESS 0
110 #define EXIT_FAILURE -1
112 void abort (void) _ATTRIB_NORETURN;
113 void exit (int nStatus) _ATTRIB_NORETURN;
114 int atexit (void (*pfuncExitProcessing)(void));
116 int system (const char* szCommand); // impl in process
117 char* getenv (const char* szVarName);
118 wchar_t* _wgetenv (const wchar_t* szVarName);
120 typedef int (*_pfunccmp_t)(const void*, const void*);
122 void* bsearch (const void* pKey, const void* pBase, size_t cntObjects,
123 size_t sizeObject, _pfunccmp_t pfuncCmp);
124 void qsort (const void* pBase, size_t cntObjects, size_t sizeObject,
125 _pfunccmp_t pfuncCmp);
131 * div_t and ldiv_t are structures used to return the results of div and
134 * NOTE: div and ldiv appear not to work correctly unless
135 * -fno-pcc-struct-return is specified. This is included in the
136 * mingw32 specs file.
138 typedef struct { int quot, rem; } div_t;
139 typedef struct { long quot, rem; } ldiv_t;
140 typedef struct { long long quot, rem; } lldiv_t;
142 div_t div (int nNumerator, int nDenominator);
143 ldiv_t ldiv (long lNumerator, long lDenominator);
144 lldiv_t lldiv (long long lNumerator, long long lDenominator);
147 #ifndef __STRICT_ANSI__
150 * NOTE: Officially the three following functions are obsolete. The Win32 API
151 * functions SetErrorMode, Beep and Sleep are their replacements.
153 void _beep (unsigned int, unsigned int);
154 void _seterrormode (int nMode);
155 void _sleep (unsigned long ulTime);
157 void _exit (int nStatus) _ATTRIB_NORETURN;
159 int _putenv (const char *val);
160 int _wputenv(const wchar_t *val);
161 void _searchenv (const char *file, const char *var, char *path);
162 void _wsearchenv (const wchar_t *file, const wchar_t *var, wchar_t *path);
164 void _makepath( char *path, const char *drive, const char *dir,
165 const char *fname, const char *ext );
166 void _wmakepath( wchar_t *path, const wchar_t *drive, const wchar_t *dir,
167 const wchar_t *fname, const wchar_t *ext );
168 void _splitpath( const char *path, char *drive, char *dir,
169 char *fname, char *ext );
170 char* _fullpath( char* caBuf, const char* szPath, size_t sizeMax );
171 wchar_t *_wfullpath( wchar_t *absPath, const wchar_t *relPath, size_t maxLength );
173 char* _itoa (int nValue, char* sz, int nRadix);
174 char* _i64toa(__int64 value, char *string, int radix);
175 char* _ltoa (long lnValue, char* sz, int nRadix);
176 char* _ultoa(unsigned long value, char *string, int radix);
177 char* _ui64toa(unsigned __int64 value, char *string, int radix);
179 wchar_t* _itow (int nValue, wchar_t* sz, int nRadix);
180 wchar_t* _i64tow(__int64 value, wchar_t *string, int radix);
181 wchar_t* _ltow (long lnValue, wchar_t* sz, int nRadix);
182 wchar_t* _ultow(unsigned long value, wchar_t *string, int radix);
183 wchar_t* _ui64tow(unsigned __int64 value, wchar_t *string, int radix);
185 char* _ecvt (double dValue, int nDig, int* pnDec, int* pnSign);
186 char* _fcvt (double dValue, int nDig, int* pnDec, int* pnSign);
187 char* _gcvt (double dValue, int nDec, char* caBuf);
189 void _swab (const char* caFrom, char* caTo, size_t sizeToCopy);
191 unsigned int _rotl( unsigned int value, int shift );
192 unsigned int _rotr( unsigned int value, int shift );
193 unsigned long _lrotl( unsigned long value, int shift );
194 unsigned long _lrotr( unsigned long value, int shift );
196 __int64 _atoi64(const char *szNumber);
198 int _wtoi( const wchar_t *str );
199 __int64 _wtoi64(const wchar_t *str);
200 long _wtol( const wchar_t *str );
205 #define seterrormode _seterrormode
207 #define putenv _putenv
208 #define searchenv _searchenv
209 #define splitpath _splitpath
219 #endif /* Not _NO_OLDNAMES */
221 #endif /* Not __STRICT_ANSI__ */
224 * Undefine the no return attribute used in some function definitions
226 #undef _ATTRIB_NORETURN
232 #endif /* _STDLIB_H_ */