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

  1. /*  stdlib.h
  2.  
  3.     Definitions for common types, variables, and functions.
  4.  
  5.     Copyright (c) 1987, 1991 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 *__s);
  73. int         _CType atoi(const char *__s);
  74. long        _CType atol(const char *__s);
  75. void * _CType bsearch(const void *__key, const void *__base,
  76.                size_t __nelem, size_t __width,
  77.                int (_CType *fcmp)(const void *,
  78.                const void *));
  79. void * _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 *__block);
  83. char * _CType getenv(const char *__name);
  84. long        _Cdecl labs(long __x);
  85. ldiv_t      _Cdecl ldiv(long __numer, long __denom);
  86. void * _Cdecl malloc(size_t __size);
  87. int         _Cdecl mblen(const char *__s, size_t __n);
  88. size_t      _Cdecl mbstowcs(wchar_t *__pwcs, const char *__s,
  89.             size_t __n);
  90. int     _Cdecl mbtowc(wchar_t *__pwc, const char *__s, size_t __n);
  91. void    _CType qsort(void *__base, size_t __nelem, size_t __width,
  92.         int _CType (*__fcmp)(const void *, const void *));
  93. int     _Cdecl rand(void);
  94. void *_Cdecl realloc(void *__block, size_t __size);
  95. void    _Cdecl srand(unsigned __seed);
  96. double  _Cdecl strtod(const char *__s, char **__endptr);
  97. long    _Cdecl strtol(const char *__s, char **__endptr,
  98.               int __radix);
  99. long double _Cdecl _strtold(const char *__s, char **__endptr);
  100. unsigned long _Cdecl strtoul(const char *__s, char **__endptr,
  101.                  int __radix);
  102. int     _Cdecl system(const char *__command);
  103. size_t  _Cdecl wcstombs(char *__s, const wchar_t *__pwcs,
  104.             size_t __n);
  105. int     _Cdecl wctomb(char *__s, wchar_t __wc);
  106.  
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110.  
  111. #if !__STDC__
  112.  
  113. /* Variables */
  114.  
  115. extern  int   _Cdecl _doserrno;
  116. extern  int   _Cdecl errno;
  117.  
  118. /*
  119.   These 2 constants are defined in MS's stdlib.h.  Rather than defining them
  120.   all the time and invading the ANSI programmers name space we'll only make
  121.   them visible when __STDC__ is *off*.  Anybody using these constants ain't
  122.   writing standard C anyway!
  123. */
  124. #define DOS_MODE  0
  125. #define OS2_MODE  1
  126.  
  127. extern  unsigned        _Cdecl _psp;
  128.  
  129. extern  char          **_Cdecl environ;
  130. extern  int             _Cdecl _fmode;
  131. extern  unsigned char   _Cdecl _osmajor;
  132. extern  unsigned char   _Cdecl _osminor;
  133. extern  unsigned int    _Cdecl _version;
  134.  
  135. extern  char           *_Cdecl sys_errlist[];
  136. extern  int             _Cdecl sys_nerr;
  137.  
  138. /* Constants for MSC pathname functions */
  139.  
  140. #define _MAX_PATH       80
  141. #define _MAX_DRIVE      3
  142. #define _MAX_DIR        66
  143. #define _MAX_FNAME      9
  144. #define _MAX_EXT        5
  145.  
  146. #ifdef __cplusplus
  147. inline int _Cdecl random(int __num)
  148.                  { return(int)(((long)rand()*__num)/(RAND_MAX+1)); }
  149. /* need prototype of time() for C++ randomize() */
  150. extern "C" long _Cdecl time(long *);  
  151. inline void _Cdecl randomize(void) { srand((unsigned) time(NULL)); }
  152. inline int  _Cdecl atoi(const char *__s) { return (int) atol(__s); }
  153. #else
  154. #define random(num)(int)(((long)rand()*(num))/(RAND_MAX+1))
  155. #define randomize()     srand((unsigned)time(NULL))
  156. #define max(a,b)    (((a) > (b)) ? (a) : (b))
  157. #define min(a,b)    (((a) < (b)) ? (a) : (b))
  158. #define atoi(s)     ((int) atol(s))
  159. #endif
  160.  
  161. #ifdef __cplusplus
  162. extern "C" {
  163. #endif
  164.  
  165. long double _Cdecl _atold(const char *__s);
  166. char   *_Cdecl ecvt(double __value, int __ndig, int *__dec,
  167.              int *__sign);
  168. void    _Cdecl _exit(int __status);
  169. char   *_Cdecl fcvt(double __value, int __ndig, int *__dec,
  170.             int *__sign);
  171. char * _CType _fullpath( char *__buf,
  172.                   const char *__path,
  173.                   size_t __maxlen );
  174. char   *_Cdecl gcvt(double __value, int __ndec, char *__buf);
  175. char   *_CType itoa(int __value, char *__string, int __radix);
  176. void   *_Cdecl lfind(const void *__key, const void *__base,
  177.          size_t *__num, size_t __width,
  178.          int _Cdecl(*__fcmp)(const void *, const void *));
  179.  
  180. unsigned long _Cdecl _lrotl(unsigned long __val, int __count);
  181. unsigned long _Cdecl _lrotr(unsigned long __val, int __count);
  182.  
  183. void   *_Cdecl lsearch(const void *__key, void *__base,
  184.          size_t *__num, size_t __width,
  185.          int _Cdecl(*__fcmp)(const void *, const void *));
  186. char * _CType ltoa(long __value, char *__string, int __radix);
  187. void _Cdecl _makepath( char *__path,
  188.                   const char *__drive,
  189.                   const char *__dir,
  190.                   const char *__name,
  191.                   const char *__ext );
  192. int     _Cdecl putenv(const char *__name);
  193.  
  194. unsigned    _Cdecl _rotl(unsigned __value, int __count);
  195. unsigned    _Cdecl _rotr(unsigned __value, int __count);
  196.  
  197. unsigned    _Cdecl __rotl__(unsigned __value, int __count);     /* intrinsic */
  198. unsigned    _Cdecl __rotr__(unsigned __value, int __count);     /* intrinsic */
  199.  
  200. void        _Cdecl _searchenv(const char *__file,
  201.                   const char *__varname,
  202.                   char *__pathname);
  203. void _Cdecl _splitpath( const char *__path,
  204.                    char *__drive,
  205.                    char *__dir,
  206.                    char *__name,
  207.                    char *__ext );
  208. void    _Cdecl swab(char *__from, char *__to, int __nbytes);
  209. char *_CType ultoa(unsigned long __value, char *__string,
  210.               int __radix);
  211.  
  212.  
  213. #ifdef __cplusplus
  214. }
  215. #endif
  216.  
  217. #endif  /* !__STDC__ */
  218.  
  219. #endif  /* __STDLIB_H */
  220.