home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 1.ddi / INCLUDE.ZIP / STDLIB.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  7.9 KB  |  266 lines

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