home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / unix / unixlib_1 / !UnixLib37_src_clib_h_stdlib < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-09  |  3.8 KB  |  154 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/h/RCS/stdlib,v $
  4.  * $Date: 1996/10/30 21:58:58 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: stdlib,v $
  10.  * Revision 1.2  1996/10/30 21:58:58  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.1  1996/04/19 21:02:57  simon
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. /* ANSI Standard 4.10: General Utilities <stdlib.h>.  */
  19.  
  20. #ifndef __STDLIB_H
  21. #define __STDLIB_H
  22.  
  23. #ifndef __STDDEF_H
  24. #include <stddef.h>
  25. #endif
  26. #ifndef __ERRNO_H
  27. #include <errno.h>
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. /* Returned by `div'.  */
  35. typedef struct
  36.   {
  37.     int quot;            /* Quotient.  */
  38.     int rem;            /* Remainder.  */
  39.   } div_t;
  40.  
  41. /* Returned by `ldiv'.  */
  42. typedef struct
  43.   {
  44.     long int quot;        /* Quotient.  */
  45.     long int rem;        /* Remainder.  */
  46.   } ldiv_t;
  47.  
  48. /* The largest number rand will return (same as INT_MAX).  */
  49. #define    RAND_MAX    2147483647
  50.  
  51.  
  52. /* Successful exit status.  */
  53. #define EXIT_SUCCESS 0
  54. /* Failing exit status.  */
  55. #define EXIT_FAILURE 1
  56.  
  57. /* Maximum length of a multibyte character in the current locale.  */
  58. #define    MB_CUR_MAX    1
  59.  
  60. /* Abort execution and generate a core-dump.  */
  61. extern    void        abort(void);
  62. extern    int        atexit(void (*)(void));
  63. extern    void        exit(int);
  64. extern    void        _exit(int);
  65. extern    char        *getenv(const char *);
  66. extern    int        system(const char *);
  67.  
  68. #define __MAX_AXCNT 33
  69. /* NB ANSI requires 32, C++ requires 1 extra */
  70.  
  71. extern void (*__ax[__MAX_AXCNT])(void);    /* atexit() functions */
  72. extern int __axcnt;        /* atexit() function count */
  73.  
  74. extern    void        *calloc(size_t,size_t);
  75. extern    void        free(void *);
  76. extern    void        *malloc(size_t);
  77. extern    void        *realloc(void *,size_t);
  78.  
  79. /* src.c.alloc thinks these are in stdio.h, but that feels wrong ... */
  80. extern void        *memalign(size_t alignment, size_t bytes);
  81. extern void        cfree(void *mem);
  82. extern size_t        malloc_usable_size(void* mem);
  83. extern void        malloc_stats(void);
  84.  
  85. #define rand() ((int)lrand())
  86. #define lrand48() lrand()
  87. #define srand48(s) srand(s)
  88.  
  89. extern    int        (rand)(void);
  90. extern    long        lrand(void);
  91. extern    void        srand(long);
  92. extern    long        (lrand48)(void);
  93. extern    void        (srand48)(long);
  94. extern    long        (random)(void);
  95. extern    void        (srandom)(long);
  96.  
  97. extern    int        abs(int);
  98. extern    long int    labs(long int);
  99. extern    div_t        div(int,int);
  100. extern    ldiv_t        ldiv(long,long);
  101.  
  102. #define atof(s) strtod(s,0)
  103. #define atoi(s) ((int)strtol(s,0,10))
  104. #define atol(s) strtol(s,0,10)
  105.  
  106. extern    double        (atof)(const char *);
  107. extern    int        (atoi)(const char *);
  108. extern    long        (atol)(const char *);
  109. extern    double        strtod(const char *,char **);
  110. extern    long        strtol(const char *,char **,int);
  111. extern    unsigned long    strtoul(const char *,char **,int);
  112.  
  113. extern    void        *bsearch(const void *,const void *,size_t,size_t,
  114.     int (*)(const void *,const void *));
  115. extern    void        qsort(void *,size_t,size_t,
  116.     int (*)(const void *,const void *));
  117.  
  118. #if 0
  119. extern    int        mblen(const char *,size_t);
  120. extern    size_t        mbstowcs(wchar_t *,const char *,size_t);
  121. extern    int        mbtowc(wchar_t *,const char *,size_t);
  122. extern    size_t        wcstombs(char *,const wchar_t *,size_t);
  123. extern    int        wctomb(char *,wchar_t);
  124. #endif
  125.  
  126. /* BSD enhancements.  */
  127.  
  128. #ifndef __ALLOCA_H
  129. #include <alloca.h>
  130. #endif
  131.  
  132. #define random() lrand()
  133. #define srandom(s) srand(s)
  134. /* Allocate size bytes on a page boundary. The storage cannot be freed.  */
  135. extern void *valloc (size_t bytes);
  136.  
  137. #if 0
  138. /* Set NAME to VALUE in the environment.
  139.    If REPLACE is nonzero, overwrite an existing value.  */
  140. extern int setenv (const char *name, const char *value, int replace);
  141. #endif
  142.  
  143. /* System V enhancements.  */
  144.  
  145. /* Put string, which is of the form "NAME=VALUE" in the environment.  */
  146. extern int putenv (char *string);
  147.  
  148.  
  149. #ifdef __cplusplus
  150.     }
  151. #endif
  152.  
  153. #endif
  154.