2 *stdlib.h - declarations/definitions for commonly used library functions
4 * Copyright (c) 1985-1988, Microsoft Corporation. All rights reserved.
7 * This include file contains the function declarations for
8 * commonly used library functions which either don't fit somewhere
9 * else, or, like toupper/tolower, can't be declared in the normal
10 * place (ctype.h in the case of toupper/tolower) for other reasons.
13 *******************************************************************************/
16 #ifndef _SIZE_T_DEFINED
17 typedef unsigned int size_t;
18 #define _SIZE_T_DEFINED
21 #ifndef NO_EXT_KEYS /* extensions enabled */
24 #else /* extensions not enabled */
27 #endif /* NO_EXT_KEYS */
30 /* definition of the return type for the onexit() function */
32 #ifndef _ONEXIT_T_DEFINED
33 typedef int (_CDECL * _CDECL onexit_t)();
34 #define _ONEXIT_T_DEFINED
38 /* Data structure definitions for div and ldiv runtimes. */
40 #ifndef _DIV_T_DEFINED
52 #define _DIV_T_DEFINED
55 /* Maximum value that can be returned by the rand function. */
57 #define RAND_MAX 0x7fff
60 /* min and max macros */
62 #define max(a,b) (((a) > (b)) ? (a) : (b))
63 #define min(a,b) (((a) < (b)) ? (a) : (b))
66 /* sizes for buffers used by the _makepath() and _splitpath() functions.
67 * note that the sizes include space for 0-terminator
70 #define _MAX_PATH 144 /* max. length of full pathname */
71 #define _MAX_DRIVE 3 /* max. length of drive component */
72 #define _MAX_DIR 130 /* max. length of path component */
73 #define _MAX_FNAME 9 /* max. length of file name component */
74 #define _MAX_EXT 5 /* max. length of extension component */
76 /* external variable declarations */
78 extern int _NEAR _CDECL errno; /* XENIX style error number */
79 extern int _NEAR _CDECL _doserrno; /* MS-DOS system error value */
80 extern char * _NEAR _CDECL sys_errlist[]; /* perror error message table */
81 extern int _NEAR _CDECL sys_nerr; /* # of entries in sys_errlist table */
83 extern char ** _NEAR _CDECL environ; /* pointer to environment table */
85 extern unsigned int _NEAR _CDECL _psp; /* Program Segment Prefix */
87 extern int _NEAR _CDECL _fmode; /* default file translation mode */
89 /* DOS major/minor version numbers */
91 extern unsigned char _NEAR _CDECL _osmajor;
92 extern unsigned char _NEAR _CDECL _osminor;
94 #define DOS_MODE 0 /* Real Address Mode */
95 #define OS2_MODE 1 /* Protected Address Mode */
97 extern unsigned char _NEAR _CDECL _osmode;
100 /* function prototypes */
102 double _CDECL atof(const char *);
103 double _CDECL strtod(const char *, char * *);
104 ldiv_t _CDECL ldiv(long, long);
106 void _CDECL abort(void);
108 int _CDECL atexit(void (_CDECL *)(void));
109 int _CDECL atoi(const char *);
110 long _CDECL atol(const char *);
111 void * _CDECL bsearch(const void *, const void *, size_t, size_t, int (_CDECL *)(const void *, const void *));
112 void * _CDECL calloc(size_t, size_t);
113 div_t _CDECL div(int, int);
114 char * _CDECL ecvt(double, int, int *, int *);
115 void _CDECL exit(int);
116 void _CDECL _exit(int);
117 char * _CDECL fcvt(double, int, int *, int *);
118 void _CDECL free(void *);
119 char * _CDECL gcvt(double, int, char *);
120 char * _CDECL getenv(const char *);
121 char * _CDECL itoa(int, char *, int);
122 long _CDECL labs(long);
123 unsigned long _CDECL _lrotl(unsigned long, int);
124 unsigned long _CDECL _lrotr(unsigned long, int);
125 char * _CDECL ltoa(long, char *, int);
126 void _CDECL _makepath(char *, char *, char *, char *, char *);
127 void * _CDECL malloc(size_t);
128 onexit_t _CDECL onexit(onexit_t);
129 void _CDECL perror(const char *);
130 int _CDECL putenv(char *);
131 void _CDECL qsort(void *, size_t, size_t, int (_CDECL *)(const void *, const void *));
132 unsigned int _CDECL _rotl(unsigned int, int);
133 unsigned int _CDECL _rotr(unsigned int, int);
134 int _CDECL rand(void);
135 void * _CDECL realloc(void *, size_t);
136 void _CDECL _searchenv(char *, char *, char *);
137 void _CDECL _splitpath(char *, char *, char *, char *, char *);
138 void _CDECL srand(unsigned int);
139 long _CDECL strtol(const char *, char * *, int);
140 unsigned long _CDECL strtoul(const char *, char * *, int);
141 void _CDECL swab(char *, char *, int);
142 int _CDECL system(const char *);
143 char * _CDECL ultoa(unsigned long, char *, int);
145 #ifndef tolower /* tolower has been undefined - use function */
146 int _CDECL tolower(int);
149 #ifndef toupper /* toupper has been undefined - use function */
150 int _CDECL toupper(int);