home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 2.ddi / INCLUDE.ZIP / STDLIB.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  6.6 KB  |  232 lines

  1. /*      stdlib.h
  2.  
  3.         Definitions for common types, variables, and functions.
  4.  
  5.         Copyright (c) Borland International 1987,1988,1990,1991
  6.         All Rights Reserved.
  7. */
  8.  
  9. #ifndef __STDLIB_H
  10. #define __STDLIB_H
  11.  
  12. #ifdef __DLL__
  13. #define _FAR far
  14. #else
  15. #define _FAR
  16. #endif
  17.  
  18. #if __STDC__
  19. #define _Cdecl
  20. #else
  21. #define _Cdecl  cdecl
  22. #endif
  23.  
  24. #ifndef __PAS__
  25. #define _CType _Cdecl
  26. #else
  27. #define _CType pascal
  28. #endif
  29.  
  30. #ifndef _SIZE_T
  31. #define _SIZE_T
  32. typedef unsigned size_t;
  33. #endif
  34.  
  35. #ifndef _DIV_T
  36. #define _DIV_T
  37. typedef struct {
  38.         int     quot;
  39.         int     rem;
  40. } div_t;
  41. #endif
  42.  
  43. #ifndef _LDIV_T
  44. #define _LDIV_T
  45. typedef struct {
  46.         long    quot;
  47.         long    rem;
  48. } ldiv_t;
  49. #endif
  50.  
  51. #ifndef _WCHAR_T
  52. #define _WCHAR_T
  53. typedef char wchar_t;
  54. #endif
  55.  
  56. #ifndef NULL
  57. #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  58. #define NULL    0
  59. #else
  60. #define NULL    0L
  61. #endif
  62. #endif
  63.  
  64. typedef void _Cdecl (* atexit_t)(void);
  65.  
  66. /* Maximum value returned by "rand" function
  67. */
  68. #define RAND_MAX 0x7FFFU
  69.  
  70. #define EXIT_SUCCESS 0
  71. #define EXIT_FAILURE 1
  72.  
  73. #define MB_CUR_MAX 1
  74.  
  75. #ifdef __cplusplus
  76. extern "C" {
  77. #endif
  78. void    _Cdecl abort(void);
  79. int     _Cdecl atexit(atexit_t __func);
  80. double  _Cdecl atof(const char _FAR *__s);
  81. int     _Cdecl atoi(const char _FAR *__s);
  82. long    _CType atol(const char _FAR *__s);
  83. void   _FAR *_CType bsearch(const void _FAR *__key, const void _FAR *__base, 
  84.                 size_t __nelem, size_t __width,
  85.                 int _Cdecl(*fcmp)(const void _FAR *, const void _FAR *));
  86. void   _FAR *_Cdecl calloc(size_t __nitems, size_t __size);
  87. div_t   _Cdecl div(int __numer, int __denom);
  88. void    _Cdecl exit(int __status);
  89. void    _Cdecl free(void _FAR *__block);
  90. char   _FAR *_Cdecl getenv(const char _FAR *__name);
  91. int     _Cdecl abs(int __x);
  92. long    _Cdecl labs(long __x);
  93. ldiv_t  _Cdecl ldiv(long __numer, long __denom);
  94. void   _FAR *_Cdecl malloc(size_t __size);
  95. int     _Cdecl mblen(const char _FAR *__s, size_t __n);
  96. size_t  _Cdecl mbstowcs(wchar_t _FAR *__pwcs, const char _FAR *__s,
  97.                         size_t __n);
  98. int     _Cdecl mbtowc(wchar_t _FAR *__pwc, const char _FAR *__s, size_t __n);
  99. void    _Cdecl qsort(void _FAR *__base, size_t __nelem, size_t __width,
  100.                 int _Cdecl(*__fcmp)(const void _FAR *, const void _FAR *));
  101. int     _Cdecl rand(void);
  102. void   _FAR *_Cdecl realloc(void _FAR *__block, size_t __size);
  103. void    _Cdecl srand(unsigned __seed);
  104. double  _Cdecl strtod(const char _FAR *__s, char _FAR *_FAR *__endptr);
  105. long    _Cdecl strtol(const char _FAR *__s, char _FAR *_FAR *__endptr,
  106.                       int __radix);
  107. unsigned long _Cdecl strtoul(const char _FAR *__s, char _FAR *_FAR *__endptr,
  108.                              int __radix);
  109. int     _Cdecl system(const char _FAR *__command);
  110. size_t  _Cdecl wcstombs(char _FAR *__s, const wchar_t _FAR *__pwcs,
  111.                         size_t __n);
  112. int     _Cdecl wctomb(char _FAR *__s, wchar_t __wc);
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116.  
  117. #if !__STDC__
  118.  
  119. /* Variables */
  120. extern  int             _Cdecl _doserrno;
  121. extern  int             _Cdecl errno;
  122.  
  123. /*
  124.   These 2 constants are defined in MS's stdlib.h.  Rather than defining them
  125.   all the time and invading the ANSI programmers name space we'll only make
  126.   them visible when __STDC__ is *off*.  Anybody using these constants ain't
  127.   writing standard C anyway!
  128. */
  129. #define DOS_MODE  0
  130. #define OS2_MODE  1
  131.  
  132. extern  char          **_Cdecl environ;
  133. extern  int             _Cdecl _fmode;
  134. extern  unsigned char   _Cdecl _osmajor;
  135. extern  unsigned char   _Cdecl _osminor;
  136. extern  unsigned        _Cdecl _psp;
  137. extern  char           _FAR *_Cdecl sys_errlist[];
  138. extern  int             _Cdecl sys_nerr;
  139. extern  unsigned int    _Cdecl _version;
  140.  
  141. #define atoi(s)((int) atol(s))
  142.  
  143. #ifdef __cplusplus
  144. inline int  _Cdecl random(int __num)
  145.     { return(int)(((long)rand()*__num)/(RAND_MAX+1)); }
  146. extern "C" long _Cdecl time(long _FAR *);  /* need prototype of time() for C++ randomize() */
  147. inline void _Cdecl randomize(void) { srand((unsigned) time(NULL)); }
  148. #else
  149. #define random(num)(int)(((long)rand()*(num))/(RAND_MAX+1))
  150. #define randomize()     srand((unsigned)time(NULL))
  151. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  152. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  153. #endif
  154.  
  155. #ifdef __cplusplus
  156. extern "C" {
  157. #endif
  158. char   _FAR *_Cdecl ecvt(double __value, int __ndig, int _FAR *__dec,
  159.                     int _FAR *__sign);
  160. void    _Cdecl _exit(int __status);
  161. char   _FAR *_Cdecl fcvt(double __value, int __ndig, int _FAR *__dec,
  162.                     int _FAR *__sign);
  163. char   _FAR *_Cdecl gcvt(double __value, int __ndec, char _FAR *__buf);
  164. char   _FAR *_CType itoa(int __value, char _FAR *__string, int __radix);
  165. void   _FAR *_Cdecl lfind(const void _FAR *__key, const void _FAR *__base, 
  166.                  size_t _FAR *__num, size_t __width,
  167.                  int _Cdecl(*fcmp)(const void _FAR *, const void _FAR *));
  168.  
  169. unsigned long _Cdecl _lrotl(unsigned long __val, int __count);
  170. unsigned long _Cdecl _lrotr(unsigned long __val, int __count);
  171.  
  172. void   _FAR *_Cdecl lsearch(const void _FAR *__key, void _FAR *__base, 
  173.                  size_t _FAR *__num, size_t __width, 
  174.                  int _Cdecl(*fcmp)(const void _FAR *, const void _FAR *));
  175. char   _FAR *_Cdecl ltoa(long __value, char _FAR *__string, int __radix);
  176. int     _Cdecl putenv(const char _FAR *__name);
  177.  
  178. unsigned _Cdecl _rotl(unsigned __value, int __count);
  179. unsigned _Cdecl _rotr(unsigned __value, int __count);
  180.  
  181. void    _Cdecl swab(char _FAR *__from, char _FAR *__to, int __nbytes);
  182. char   _FAR *_Cdecl ultoa(unsigned long __value, char _FAR *__string,
  183.                           int __radix);
  184.  
  185. #ifdef __MSC
  186.  
  187. /* Prototypes needed for MSC macros */
  188.  
  189. int         _CType fnsplit( const char _FAR *__path,
  190.                             char *__drive, char *__dir, 
  191.                             char _FAR *__name,
  192.                             char _FAR *__ext );
  193. #endif    /* __MSC */
  194.  
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198.  
  199.  
  200. #endif  /* !__STDC__ */
  201.  
  202. #ifdef __MSC
  203.  
  204. /* MSC variables */
  205.  
  206. extern  unsigned      _Cdecl _version;
  207. #define _osversion _version
  208.  
  209. /* Constants for MSC functions */
  210.  
  211. #define _MAX_PATH    80
  212. #define _MAX_DRIVE    3
  213. #define _MAX_DIR    66
  214. #define _MAX_FNAME    9
  215. #define _MAX_EXT    5
  216.  
  217. /* Macros for MSC functions */
  218.  
  219. #define _splitpath(path,drive,dir,fname,ext) \
  220.   (void)fnsplit(path,drive,dir,fname,ext)
  221.  
  222. #endif    /* __MSC */
  223.  
  224. int _Cdecl __abs__(int);
  225. #ifdef __cplusplus
  226. inline int _Cdecl abs(int __x) { return __abs__(__x); }
  227. #else
  228. #define abs(x)          __abs__(x)
  229. #endif
  230.  
  231. #endif
  232.