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.
23 * $Date: 1999/04/14 07:10:15 $
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 <crtdll/stddef.h>
56 #include <crtdll/mbstring.h>
58 #ifndef __ATTRIB_NORETURN
60 #define _ATTRIB_NORETURN __attribute__ ((noreturn))
61 #else /* Not __GNUC__ */
62 #define _ATTRIB_NORETURN
66 double atof (const char* szNumber
);
67 int atoi (const char* szNumber
);
68 long atol (const char* szNumber
);
71 double strtod (const char* szNumber
, char** pszAfterNumber
);
72 double wcstod (const wchar_t* wsNumber
, wchar_t** pwsAfterNumber
);
73 long strtol (const char* szNumber
, char** pszAfterNumber
, int nBase
);
74 long wcstol (const wchar_t* wsNumber
, wchar_t** pwsAfterNumber
, int nBase
);
76 unsigned long strtoul (const char* szNumber
, char** pszAfterNumber
,
78 unsigned long wcstoul (const wchar_t* wsNumber
, wchar_t** pwsAfterNumber
,
81 size_t wcstombs (char* mbsDest
, const wchar_t* wsConvert
, size_t size
);
82 int wctomb (char* mbDest
, wchar_t wc
);
84 int mblen (const char* mbs
, size_t sizeString
);
85 size_t mbstowcs (wchar_t* wcaDest
, const char* mbsConvert
,
87 int mbtowc (wchar_t* wcDest
, const char* mbConvert
, size_t size
);
91 * RAND_MAX is the maximum value that may be returned by rand.
92 * The minimum is zero.
94 #define RAND_MAX 0x7FFF
97 void srand (unsigned int nSeed
);
100 void* calloc (size_t sizeObjCnt
, size_t sizeObject
);
101 void* malloc (size_t sizeObject
);
102 void* realloc (void* pObject
, size_t sizeNew
);
103 void free (void* pObject
);
105 /* These values may be used as exit status codes. */
106 #define EXIT_SUCCESS 0
107 #define EXIT_FAILURE -1
109 void abort (void) _ATTRIB_NORETURN
;
110 void exit (int nStatus
) _ATTRIB_NORETURN
;
111 int atexit (void (*pfuncExitProcessing
)(void));
113 int system (const char* szCommand
); // impl in process
114 char* getenv (const char* szVarName
); // impl in stdio
116 typedef int (*_pfunccmp_t
)(const void*, const void*);
118 void* bsearch (const void* pKey
, const void* pBase
, size_t cntObjects
,
119 size_t sizeObject
, _pfunccmp_t pfuncCmp
);
120 void qsort (const void* pBase
, size_t cntObjects
, size_t sizeObject
,
121 _pfunccmp_t pfuncCmp
);
127 * div_t and ldiv_t are structures used to return the results of div and
130 * NOTE: div and ldiv appear not to work correctly unless
131 * -fno-pcc-struct-return is specified. This is included in the
132 * mingw32 specs file.
134 typedef struct { int quot
, rem
; } div_t;
135 typedef struct { long quot
, rem
; } ldiv_t;
136 typedef struct { long long quot
, rem
; } lldiv_t
;
138 div_t div (int nNumerator
, int nDenominator
);
139 ldiv_t ldiv (long lNumerator
, long lDenominator
);
140 lldiv_t
lldiv (long long lNumerator
, long long lDenominator
);
143 #ifndef __STRICT_ANSI__
146 * NOTE: Officially the three following functions are obsolete. The Win32 API
147 * functions SetErrorMode, Beep and Sleep are their replacements.
149 void _beep (unsigned int, unsigned int);
150 void _seterrormode (int nMode
);
151 void _sleep (unsigned long ulTime
);
153 void _exit (int nStatus
) _ATTRIB_NORETURN
;
155 int _putenv (const char* szNameEqValue
);
156 void _searchenv (const char* szFileName
, const char* szVar
,
157 char* szFullPathBuf
);
159 void _splitpath( const char *path
, char *drive
, char *dir
,
160 char *fname
, char *ext
);
162 char* _itoa (int nValue
, char* sz
, int nRadix
);
163 char* _ltoa (long lnValue
, char* sz
, int nRadix
);
165 char* _ecvt (double dValue
, int nDig
, int* pnDec
, int* pnSign
);
166 char* _fcvt (double dValue
, int nDig
, int* pnDec
, int* pnSign
);
167 char* _gcvt (double dValue
, int nDec
, char* caBuf
);
169 char* _fullpath (char* caBuf
, const char* szPath
, size_t sizeMax
);
171 void _swab (const char* caFrom
, char* caTo
, size_t sizeToCopy
);
173 unsigned int _rotl( unsigned int value
, int shift
);
174 unsigned int _rotr( unsigned int value
, int shift
);
175 unsigned long _lrotl( unsigned long value
, int shift
);
176 unsigned long _lrotr( unsigned long value
, int shift
);
183 #define seterrormode _seterrormode
185 #define putenv _putenv
186 #define searchenv _searchenv
187 #define splitpath _splitpath
197 #endif /* Not _NO_OLDNAMES */
199 #endif /* Not __STRICT_ANSI__ */
202 * Undefine the no return attribute used in some function definitions
204 #undef _ATTRIB_NORETURN
210 #endif /* _STDLIB_H_ */