eo301@0: /* eo301@0: * stdlib.h eo301@0: * eo301@0: * Definitions for common types, variables, and functions. eo301@0: * eo301@0: * This file is part of the Mingw32 package. eo301@0: * eo301@0: * Contributors: eo301@0: * Created by Colin Peters eo301@0: * eo301@0: * THIS SOFTWARE IS NOT COPYRIGHTED eo301@0: * eo301@0: * This source code is offered for use in the public domain. You may eo301@0: * use, modify or distribute it freely. eo301@0: * eo301@0: * This code is distributed in the hope that it will be useful but eo301@0: * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY eo301@0: * DISCLAMED. This includes but is not limited to warranties of eo301@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. eo301@0: * eo301@0: * $Revision: 1.1.1.1 $ eo301@0: * $Author: brandon6684 $ eo301@0: * $Date: 2001/12/18 22:54:00 $ eo301@0: * eo301@0: */ eo301@0: /* Appropriated for Reactos Crtdll by Ariadne */ eo301@0: /* added splitpath */ eo301@0: /* changed definition of environ and argc */ eo301@0: /* moved prototype for swab from string.h to stdlib.h */ eo301@0: #ifndef _STDLIB_H_ eo301@0: #define _STDLIB_H_ eo301@0: eo301@0: #ifdef __cplusplus eo301@0: extern "C" { eo301@0: #endif eo301@0: eo301@0: /* eo301@0: * This seems like a convenient place to declare these variables, which eo301@0: * give programs using WinMain (or main for that matter) access to main-ish eo301@0: * argc and argv. environ is a pointer to a table of environment variables. eo301@0: * NOTE: Strings in _argv and environ are ANSI strings. eo301@0: */ eo301@0: extern int* __argc_dll; eo301@0: extern char*** __argv_dll; eo301@0: extern char*** _environ_dll; eo301@0: #define __argc (*__argc_dll) eo301@0: #define __argv (*__argv_dll) eo301@0: #define _environ (*_environ_dll) eo301@0: eo301@0: eo301@0: #define __need_size_t eo301@0: #define __need_wchar_t eo301@0: #define __need_NULL eo301@0: #include eo301@0: eo301@0: #include eo301@0: eo301@0: #ifndef __ATTRIB_NORETURN eo301@0: #ifdef __GNUC__ eo301@0: #define _ATTRIB_NORETURN __attribute__ ((noreturn)) eo301@0: #else /* Not __GNUC__ */ eo301@0: #define _ATTRIB_NORETURN eo301@0: #endif /* __GNUC__ */ eo301@0: #endif eo301@0: eo301@0: double atof (const char* szNumber); eo301@0: int atoi (const char* szNumber); eo301@0: long atol (const char* szNumber); eo301@0: eo301@0: eo301@0: double strtod (const char* szNumber, char** pszAfterNumber); eo301@0: double wcstod (const wchar_t* wsNumber, wchar_t** pwsAfterNumber); eo301@0: long strtol (const char* szNumber, char** pszAfterNumber, int nBase); eo301@0: long wcstol (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, int nBase); eo301@0: eo301@0: unsigned long strtoul (const char* szNumber, char** pszAfterNumber, eo301@0: int nBase); eo301@0: unsigned long wcstoul (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, eo301@0: int nBase); eo301@0: eo301@0: size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size); eo301@0: int wctomb (char* mbDest, wchar_t wc); eo301@0: eo301@0: int mblen (const char* mbs, size_t sizeString); eo301@0: size_t mbstowcs (wchar_t* wcaDest, const char* mbsConvert, eo301@0: size_t size); eo301@0: int mbtowc (wchar_t* wcDest, const char* mbConvert, size_t size); eo301@0: eo301@0: eo301@0: /* eo301@0: * RAND_MAX is the maximum value that may be returned by rand. eo301@0: * The minimum is zero. eo301@0: */ eo301@0: #define RAND_MAX 0x7FFF eo301@0: eo301@0: int rand (void); eo301@0: void srand (unsigned int nSeed); eo301@0: eo301@0: eo301@0: void* calloc (size_t sizeObjCnt, size_t sizeObject); eo301@0: void* malloc (size_t sizeObject); eo301@0: void* realloc (void* pObject, size_t sizeNew); eo301@0: void free (void* pObject); eo301@0: eo301@0: /* These values may be used as exit status codes. */ eo301@0: #define EXIT_SUCCESS 0 eo301@0: #define EXIT_FAILURE -1 eo301@0: eo301@0: void abort (void) _ATTRIB_NORETURN; eo301@0: void exit (int nStatus) _ATTRIB_NORETURN; eo301@0: int atexit (void (*pfuncExitProcessing)(void)); eo301@0: eo301@0: int system (const char* szCommand); // impl in process eo301@0: char* getenv (const char* szVarName); // impl in stdio eo301@0: eo301@0: typedef int (*_pfunccmp_t)(const void*, const void*); eo301@0: eo301@0: void* bsearch (const void* pKey, const void* pBase, size_t cntObjects, eo301@0: size_t sizeObject, _pfunccmp_t pfuncCmp); eo301@0: void qsort (const void* pBase, size_t cntObjects, size_t sizeObject, eo301@0: _pfunccmp_t pfuncCmp); eo301@0: eo301@0: int abs (int n); eo301@0: long labs (long n); eo301@0: eo301@0: /* eo301@0: * div_t and ldiv_t are structures used to return the results of div and eo301@0: * ldiv. eo301@0: * eo301@0: * NOTE: div and ldiv appear not to work correctly unless eo301@0: * -fno-pcc-struct-return is specified. This is included in the eo301@0: * mingw32 specs file. eo301@0: */ eo301@0: typedef struct { int quot, rem; } div_t; eo301@0: typedef struct { long quot, rem; } ldiv_t; eo301@0: typedef struct { long long quot, rem; } lldiv_t; eo301@0: eo301@0: div_t div (int nNumerator, int nDenominator); eo301@0: ldiv_t ldiv (long lNumerator, long lDenominator); eo301@0: lldiv_t lldiv (long long lNumerator, long long lDenominator); eo301@0: eo301@0: eo301@0: #ifndef __STRICT_ANSI__ eo301@0: eo301@0: /* eo301@0: * NOTE: Officially the three following functions are obsolete. The Win32 API eo301@0: * functions SetErrorMode, Beep and Sleep are their replacements. eo301@0: */ eo301@0: void _beep (unsigned int, unsigned int); eo301@0: void _seterrormode (int nMode); eo301@0: void _sleep (unsigned long ulTime); eo301@0: eo301@0: void _exit (int nStatus) _ATTRIB_NORETURN; eo301@0: eo301@0: int _putenv (const char* szNameEqValue); eo301@0: void _searchenv (const char* szFileName, const char* szVar, eo301@0: char* szFullPathBuf); eo301@0: eo301@0: void _splitpath( const char *path, char *drive, char *dir, eo301@0: char *fname, char *ext ); eo301@0: eo301@0: char* _itoa (int nValue, char* sz, int nRadix); eo301@0: char* _ltoa (long lnValue, char* sz, int nRadix); eo301@0: eo301@0: char* _ecvt (double dValue, int nDig, int* pnDec, int* pnSign); eo301@0: char* _fcvt (double dValue, int nDig, int* pnDec, int* pnSign); eo301@0: char* _gcvt (double dValue, int nDec, char* caBuf); eo301@0: eo301@0: char* _fullpath (char* caBuf, const char* szPath, size_t sizeMax); eo301@0: eo301@0: void _swab (const char* caFrom, char* caTo, size_t sizeToCopy); eo301@0: eo301@0: unsigned int _rotl( unsigned int value, int shift ); eo301@0: unsigned int _rotr( unsigned int value, int shift ); eo301@0: unsigned long _lrotl( unsigned long value, int shift ); eo301@0: unsigned long _lrotr( unsigned long value, int shift ); eo301@0: eo301@0: eo301@0: eo301@0: eo301@0: #ifndef _NO_OLDNAMES eo301@0: #define beep _beep eo301@0: #define seterrormode _seterrormode eo301@0: #define sleep _sleep eo301@0: #define putenv _putenv eo301@0: #define searchenv _searchenv eo301@0: #define splitpath _splitpath eo301@0: eo301@0: #define itoa _itoa eo301@0: #define ltoa _ltoa eo301@0: eo301@0: #define ecvt _ecvt eo301@0: #define fcvt _fcvt eo301@0: #define gcvt _gcvt eo301@0: eo301@0: #define swab _swab eo301@0: #endif /* Not _NO_OLDNAMES */ eo301@0: eo301@0: #endif /* Not __STRICT_ANSI__ */ eo301@0: eo301@0: /* eo301@0: * Undefine the no return attribute used in some function definitions eo301@0: */ eo301@0: #undef _ATTRIB_NORETURN eo301@0: eo301@0: #ifdef __cplusplus eo301@0: } eo301@0: #endif eo301@0: eo301@0: #endif /* _STDLIB_H_ */