home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / INCLUDE.ZIP / STDLIB.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  5.5 KB  |  184 lines

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