home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / ansi / stdlib.h < prev    next >
C/C++ Source or Header  |  1993-01-07  |  5KB  |  174 lines

  1. /* Copyright (c) 1988,1992 NeXT, Inc. - 9/8/88 CCH */
  2.  
  3. #ifndef _ANSI_STDLIB_H
  4. #define _ANSI_STDLIB_H
  5.  
  6. #include <standards.h>
  7.  
  8. #ifdef __STRICT_BSD__
  9. #error This file should not be in a strictly BSD program
  10. #endif
  11.  
  12. #ifdef __STRICT_ANSI__
  13. #ifndef NULL
  14. #define NULL    ((void *)0)
  15. #endif    /* NULL */
  16.  
  17. #ifndef _SIZE_T
  18. #define _SIZE_T
  19. typedef unsigned long    size_t;
  20. #endif    /* _SIZE_T */
  21.  
  22. #ifndef _WCHAR_T
  23. #define _WCHAR_T
  24. typedef unsigned short    wchar_t;
  25. #endif    /* _WCHAR_T */
  26.  
  27. #else    /* !__STRICT_ANSI__ */
  28. #include <stddef.h> /* get size_t, NULL, etc. */
  29. #endif    /* !__STRICT_ANSI__ */
  30.  
  31. #ifndef ERANGE
  32. /* Match definition in <sys/errno.h>. */
  33. #define ERANGE 34        /* Result too large */
  34. #endif    /* ERANGE */
  35.  
  36. #ifndef HUGE_VAL
  37. /* Match definition in <math.h>. */
  38. #define HUGE_VAL (1e999)
  39. #endif    /* HUGE_VAL */
  40.  
  41. #if defined(__STRICT_ANSI__) || defined(_NEXT_SOURCE) 
  42. #define EXIT_FAILURE (1)
  43. #define EXIT_SUCCESS (0)
  44. #define RAND_MAX (2147483647)
  45. #define MB_CUR_MAX (1)
  46.  
  47. typedef struct {int quot, rem;} div_t;
  48. typedef struct {long int quot, rem;} ldiv_t;
  49.  
  50. #ifdef __STDC__
  51. extern double atof(const char *nptr);
  52. #define atof(nptr) strtod(nptr, (char **)NULL)
  53. extern int atoi(const char *nptr);
  54. extern long int atol(const char *nptr);
  55. extern double strtod(const char *nptr, char **endptr);
  56. extern long int strtol(const char *nptr, char **endptr, int base);
  57. extern unsigned long int strtoul(const char *nptr, char **endptr, int base);
  58. extern int rand(void);
  59. extern void srand(unsigned int seed);
  60. extern void *calloc(size_t nmemb, size_t size);
  61. extern void free(void *ptr);
  62. extern void *malloc(size_t size);
  63. extern void *realloc(void *ptr, size_t size);
  64. #ifdef    __GNUC__
  65. extern volatile void abort(void);
  66. #else    /* !__GNUC__ */
  67. extern void abort(void);
  68. #endif    /* !__GNUC__ */
  69. extern char *getenv(const char *name);
  70. extern int system(const char *string);
  71. extern void *bsearch(const void *key, const void *base,
  72.     size_t nmemb, size_t size,
  73.     int (*compar)(const void *, const void *));
  74. #ifdef __STRICT_ANSI__
  75. extern void qsort(void *base, size_t nmemb, size_t size,
  76.     int (*compar)(const void *, const void *));
  77. #else    /* !__STRICT_ANSI__ */
  78. extern void *qsort(void *base, size_t nmemb, size_t size,
  79.     int (*compar)(const void *, const void *));
  80. #endif    /* !__STRICT_ANSI__ */
  81. extern int abs(int j);
  82. extern div_t div(int numer, int denom);
  83. extern long int labs(long int j);
  84. extern ldiv_t ldiv(long int numer, long int denom);
  85. extern int mblen(const char *s, size_t n);
  86. extern int mbtowc(wchar_t *pwc, const char *s, size_t n);
  87. extern int wctomb(char *s, wchar_t wchar);
  88. extern size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n);
  89. extern size_t wcstombs(char *s, const wchar_t *pwcs, size_t n);
  90. #else    /* !__STDC__ */
  91. extern double atof();
  92. #define atof(nptr) strtod(nptr, (char **)NULL)
  93. extern int atoi();
  94. extern long int atol();
  95. extern double strtod();
  96. extern long int strtol();
  97. extern unsigned long int strtoul();
  98. extern int rand();
  99. extern void srand();
  100. extern void *calloc();
  101. extern void free();
  102. extern void *malloc();
  103. extern void *realloc();
  104. #ifdef    __GNUC__
  105. extern volatile void abort()
  106. #else    /* !__GNUC__ */
  107. extern void abort();
  108. #endif    /* !__GNUC__ */
  109. extern char *getenv();
  110. extern int system();
  111. extern void *bsearch();
  112. #ifdef __STRICT_ANSI__
  113. extern void qsort();
  114. #else    /* !__STRICT_ANSI__ */
  115. extern void *qsort();
  116. #endif    /* !__STRICT_ANSI__ */
  117. extern int abs();
  118. extern div_t div();
  119. extern long int labs();
  120. extern ldiv_t ldiv();
  121. extern int mblen();
  122. extern int mbtowc();
  123. extern int wctomb();
  124. extern size_t mbstowcs();
  125. extern size_t wcstombs();
  126. #endif /* !__STDC__ */
  127. #endif /* __STRICT_ANSI__ || _NEXT_SOURCE */
  128.  
  129. #ifdef    __cplusplus
  130. typedef void (*_cplus_fcn_void)(void);
  131. extern int atexit(_cplus_fcn_void);
  132. #else    /* !__cplusplus */
  133. #ifdef __STDC__
  134. extern int atexit(void (*fcn)(void));
  135. #else    /* !__STDC__ */
  136. extern int atexit();
  137. #endif    /* !__STDC__ */
  138. #endif    /* !__cplusplus */
  139.  
  140. #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
  141. extern volatile void exit(int status);
  142. #else    /* !__GNUC__ || __STRICT_ANSI__ */
  143. #ifdef __STDC__
  144. extern void exit(int status);
  145. #else    /* !__STDC__ */
  146. extern void exit();
  147. #endif    /* !__STDC__ */
  148. #endif    /* !__GNUC__ || __STRICT_ANSI__ */
  149.  
  150. #ifndef __STRICT_ANSI__
  151. extern void *valloc(size_t size);
  152. extern void *alloca(size_t size);
  153.  
  154. #undef     alloca
  155. #define    alloca(x)    __builtin_alloca(x)
  156.  
  157. extern void cfree(void *ptr);
  158. extern void vfree(void *ptr);
  159. extern size_t malloc_size(void *ptr);
  160. extern size_t malloc_good_size(size_t byteSize);
  161. extern int malloc_debug(int level);
  162.  
  163. #ifdef    __cplusplus
  164. typedef void (*_cplus_fcn_int)(int);
  165. extern void (*malloc_error(_cplus_fcn_int))(int);
  166. #else    /* !__cplusplus */
  167. extern void (*malloc_error(void (*fcn)(int)))(int);
  168. #endif    /* !__cplusplus */
  169.  
  170. extern size_t mstats(void);
  171. #endif    /* !__STRICT_ANSI__ */
  172.  
  173. #endif    /* _ANSI_STDLIB_H */
  174.