--- mstools/h/stdlib.h 2018/08/09 18:20:01 1.1 +++ mstools/h/stdlib.h 2018/08/09 18:22:55 1.1.1.4 @@ -1,7 +1,7 @@ /*** *stdlib.h - declarations/definitions for commonly used library functions * -* Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved. +* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved. * *Purpose: * This include file contains the function declarations for @@ -19,10 +19,29 @@ extern "C" { #endif -#if (_MSC_VER <= 600) -#define __cdecl _cdecl +/* + * Conditional macro definition for function calling type and variable type + * qualifiers. + */ +#if ( (_MSC_VER >= 800) && (_M_IX86 >= 300) ) + +/* + * Definitions for MS C8-32 (386/486) compiler + */ +#define _CRTAPI1 __cdecl +#define _CRTAPI2 __cdecl + +#else + +/* + * Other compilers (e.g., MIPS) + */ +#define _CRTAPI1 +#define _CRTAPI2 + #endif + #ifndef _SIZE_T_DEFINED typedef unsigned int size_t; #define _SIZE_T_DEFINED @@ -53,7 +72,7 @@ typedef unsigned short wchar_t; #ifndef _ONEXIT_T_DEFINED -typedef int (* _onexit_t)(void); +typedef int (_CRTAPI1 * _onexit_t)(void); #if !__STDC__ /* Non-ANSI name for compatibility */ #define onexit_t _onexit_t @@ -83,8 +102,19 @@ typedef struct _ldiv_t { #define RAND_MAX 0x7fff -extern unsigned short __mb_cur_max; /* max mb-len for current locale */ -#define MB_CUR_MAX __mb_cur_max +#ifndef _MB_CUR_MAX_DEFINED +/* max mb-len for current locale */ +/* also defined in ctype.h */ +#ifdef _DLL +#define __mb_cur_max (*__mb_cur_max_dll) +#define MB_CUR_MAX (*__mb_cur_max_dll) +extern unsigned short *__mb_cur_max_dll; +#else +#define MB_CUR_MAX __mb_cur_max +extern unsigned short __mb_cur_max; +#endif +#define _MB_CUR_MAX_DEFINED +#endif /* _MB_CUR_MAX_DEFINED */ /* min and max macros */ @@ -113,29 +143,99 @@ extern unsigned short __mb_cur_max; /* m /* external variable declarations */ #ifdef _MT -extern int * _errno(void); -extern unsigned long * __doserrno(void); +extern int * _CRTAPI1 _errno(void); +extern unsigned long * _CRTAPI1 __doserrno(void); #define errno (*_errno()) #define _doserrno (*__doserrno()) #else /* ndef _MT */ extern int errno; /* XENIX style error number */ extern unsigned long _doserrno; /* OS system error value */ #endif /* _MT */ -extern char * _sys_errlist[]; /* perror error message table */ -extern int _sys_nerr; /* # of entries in sys_errlist table */ +#ifdef _DLL + +extern char ** _sys_errlist; /* perror error message table */ + +#define _sys_nerr (*_sys_nerr_dll) +#define __argc (*__argc_dll) +#define __argv (*__argv_dll) +#define _environ (*_environ_dll) +#define _fmode (*_fmode_dll) +#define _fileinfo (*_fileinfo_dll) + +extern int * _sys_nerr_dll; /* # of entries in sys_errlist table */ +extern int * __argc_dll; /* count of cmd line args */ +extern char *** __argv_dll; /* pointer to table of cmd line args */ +extern char *** _environ_dll; /* pointer to environment table */ +extern int * _fmode_dll; /* default file translation mode */ +extern int * _fileinfo_dll; /* open file info mode (for spawn) */ + +#define _pgmptr (*_pgmptr_dll) + +#define _osver (*_osver_dll) +#define _winver (*_winver_dll) +#define _winmajor (*_winmajor_dll) +#define _winminor (*_winminor_dll) + +extern char ** _pgmptr_dll; + +extern unsigned int * _osver_dll; +extern unsigned int * _winver_dll; +extern unsigned int * _winmajor_dll; +extern unsigned int * _winminor_dll; + +/* --------- The following block is OBSOLETE --------- */ + +/* DOS major/minor version numbers */ + +#define _osmajor (*_osmajor_dll) +#define _osminor (*_osminor_dll) + +extern unsigned int * _osmajor_dll; +extern unsigned int * _osminor_dll; + +/* --------- The preceding block is OBSOLETE --------- */ + +#else + + +extern char * _sys_errlist[]; /* perror error message table */ +extern int _sys_nerr; /* # of entries in sys_errlist table */ + +extern int __argc; /* count of cmd line args */ +extern char ** __argv; /* pointer to table of cmd line args */ + +#ifdef _POSIX_ +extern char ** environ; /* pointer to environment table */ +#else extern char ** _environ; /* pointer to environment table */ +#endif + extern int _fmode; /* default file translation mode */ -extern int _fileinfo; /* open file info mode (for spawn) */ +extern int _fileinfo; /* open file info mode (for spawn) */ -extern unsigned int _psp; /* Program Segment Prefix */ +extern char * _pgmptr; /* points to the module (EXE) name */ +/* Windows major/minor and O.S. version numbers */ + +extern unsigned int _osver; +extern unsigned int _winver; +extern unsigned int _winmajor; +extern unsigned int _winminor; + +/* --------- The following block is OBSOLETE --------- */ /* DOS major/minor version numbers */ extern unsigned int _osmajor; extern unsigned int _osminor; +/* --------- The preceding block is OBSOLETE --------- */ + +#endif + +/* --------- The following block is OBSOLETE --------- */ + /* OS API mode */ #define _DOS_MODE 0 /* DOS */ @@ -143,8 +243,14 @@ extern unsigned int _osminor; #define _WIN_MODE 2 /* Windows */ #define _OS2_20_MODE 3 /* OS/2 2.0 */ #define _DOSX32_MODE 4 /* DOSX32 */ +#define _POSIX_MODE_ 5 /* POSIX */ +#ifdef _DLL +#define _osmode (*_osmode_dll) +extern unsigned char * _osmode_dll; +#else extern unsigned char _osmode; +#endif /* CPU addressing mode */ @@ -152,80 +258,94 @@ extern unsigned char _osmode; #define _PROT_MODE 1 /* protect mode */ #define _FLAT_MODE 2 /* flat mode */ +#ifdef _DLL +#define _cpumode (*_cpumode_dll) +extern unsigned char * _cpumode_dll; +#else extern unsigned char _cpumode; +#endif +/* --------- The preceding block is OBSOLETE --------- */ /* function prototypes */ -void abort(void); -int abs(int); -int atexit(void (*)(void)); -double atof(const char *); -int atoi(const char *); -long atol(const char *); -#if defined(i386) -long double _atold(const char *); -#endif -void * bsearch(const void *, const void *, size_t, size_t, - int (*)(const void *, const void *)); -void * calloc(size_t, size_t); -div_t div(int, int); -char * _ecvt(double, int, int *, int *); -void exit(int); -void _exit(int); -char * _fcvt(double, int, int *, int *); -void free(void *); -char * _fullpath(char *, const char *, size_t); -char * _gcvt(double, int, char *); -char * getenv(const char *); -char * _itoa(int, char *, int); -long labs(long); -ldiv_t ldiv(long, long); -unsigned long _lrotl(unsigned long, int); -unsigned long _lrotr(unsigned long, int); -char * _ltoa(long, char *, int); -void _makepath(char *, const char *, const char *, const char *, - const char *); -void * malloc(size_t); -_onexit_t _onexit(_onexit_t); -void perror(const char *); -int _putenv(const char *); -void qsort(void *, size_t, size_t, int (*) +void _CRTAPI1 abort(void); +int _CRTAPI1 abs(int); +int _CRTAPI1 atexit(void (_CRTAPI1 *)(void)); +double _CRTAPI1 atof(const char *); +int _CRTAPI1 atoi(const char *); +long _CRTAPI1 atol(const char *); +void * _CRTAPI1 bsearch(const void *, const void *, size_t, size_t, + int (_CRTAPI1 *)(const void *, const void *)); +void * _CRTAPI1 calloc(size_t, size_t); +div_t _CRTAPI1 div(int, int); +void _CRTAPI1 exit(int); +void _CRTAPI1 free(void *); +char * _CRTAPI1 getenv(const char *); +char * _CRTAPI1 _itoa(int, char *, int); +long _CRTAPI1 labs(long); +ldiv_t _CRTAPI1 ldiv(long, long); +char * _CRTAPI1 _ltoa(long, char *, int); +void * _CRTAPI1 malloc(size_t); +int _CRTAPI1 mblen(const char *, size_t); +size_t _CRTAPI1 _mbstrlen(const char *s); +int _CRTAPI1 mbtowc(wchar_t *, const char *, size_t); +size_t _CRTAPI1 mbstowcs(wchar_t *, const char *, size_t); +void _CRTAPI1 qsort(void *, size_t, size_t, int (_CRTAPI1 *) (const void *, const void *)); -unsigned int _rotl(unsigned int, int); -unsigned int _rotr(unsigned int, int); -int rand(void); -void * realloc(void *, size_t); -void _searchenv(const char *, const char *, char *); -void _splitpath(const char *, char *, char *, char *, char *); -void srand(unsigned int); -double strtod(const char *, char **); -long strtol(const char *, char **, int); -#if defined(i386) -long double _strtold(const char *, char **); -#endif -unsigned long strtoul(const char *, char **, int); -void _swab(char *, char *, int); -int system(const char *); -char * _ultoa(unsigned long, char *, int); -int mblen(const char *, size_t); -int mbtowc(wchar_t *, const char *, size_t); -int wctomb(char *, wchar_t); -size_t mbstowcs(wchar_t *, const char *, size_t); -size_t wcstombs(char *, const wchar_t *, size_t); -void _seterrormode(int); -void _beep(unsigned, unsigned); -void _sleep(unsigned long); +int _CRTAPI1 rand(void); +void * _CRTAPI1 realloc(void *, size_t); +void _CRTAPI1 srand(unsigned int); +double _CRTAPI1 strtod(const char *, char **); +long _CRTAPI1 strtol(const char *, char **, int); +unsigned long _CRTAPI1 strtoul(const char *, char **, int); +int _CRTAPI1 system(const char *); +char * _CRTAPI1 _ultoa(unsigned long, char *, int); +int _CRTAPI1 wctomb(char *, wchar_t); +size_t _CRTAPI1 wcstombs(char *, const wchar_t *, size_t); +#if !__STDC__ +#ifndef _WSTDLIB_DEFINED +/* defined in wchar.h officially */ +double _CRTAPI1 wcstod(const wchar_t *, wchar_t **); +long _CRTAPI1 wcstol(const wchar_t *, wchar_t **, int); +unsigned long _CRTAPI1 wcstoul(const wchar_t *, wchar_t **, int); +#define _WSTDLIB_DEFINED +#endif +#endif /* !__STDC__ */ + +#ifndef _POSIX_ +char * _CRTAPI1 _ecvt(double, int, int *, int *); +void _CRTAPI1 _exit(int); +char * _CRTAPI1 _fcvt(double, int, int *, int *); +char * _CRTAPI1 _fullpath(char *, const char *, size_t); +char * _CRTAPI1 _gcvt(double, int, char *); +unsigned long _CRTAPI1 _lrotl(unsigned long, int); +unsigned long _CRTAPI1 _lrotr(unsigned long, int); +void _CRTAPI1 _makepath(char *, const char *, const char *, const char *, + const char *); +_onexit_t _CRTAPI1 _onexit(_onexit_t); +void _CRTAPI1 perror(const char *); +int _CRTAPI1 _putenv(const char *); +unsigned int _CRTAPI1 _rotl(unsigned int, int); +unsigned int _CRTAPI1 _rotr(unsigned int, int); +void _CRTAPI1 _searchenv(const char *, const char *, char *); +void _CRTAPI1 _splitpath(const char *, char *, char *, char *, char *); +void _CRTAPI1 _swab(char *, char *, int); +void _CRTAPI1 _seterrormode(int); +void _CRTAPI1 _beep(unsigned, unsigned); +void _CRTAPI1 _sleep(unsigned long); +#endif #ifndef tolower /* tolower has been undefined - use function */ -int tolower(int); +int _CRTAPI1 tolower(int); #endif /* tolower */ #ifndef toupper /* toupper has been undefined - use function */ -int toupper(int); +int _CRTAPI1 toupper(int); #endif /* toupper */ -#if !__STDC__ + +#if (!__STDC__ && !defined(_POSIX_)) /* Non-ANSI names for compatibility */ #ifndef __cplusplus @@ -250,7 +370,7 @@ int toupper(int); #define swab _swab #define ultoa _ultoa -#endif /* __STDC__ */ +#endif /* !__STDC__ && !_POSIX_ */ #ifdef __cplusplus }