home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / c / sozobon / sozlib15.zoo / sozdistr / include / xdlibs / stdlib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-28  |  3.2 KB  |  132 lines

  1. /* 
  2.  * @(#)stdlib.h, SozobonX, 1994/11/20, XdLibs include file   
  3.  *
  4.  * stdlib.h replaces malloc.h and contains some more standard functions
  5.  * from xdlibs; it is an ANSI compatible header file.
  6.  * See chapter stdlib in xdlibs.txt.
  7.  *
  8.  * IT IS INCLUDED by stdio.h, so have to include it only
  9.  * if you don't use stdio.h
  10.  * -jerry-
  11.  * last changes by 
  12.  *  -VS: 1995/08/28
  13.  */
  14.  
  15. #ifndef _STDLIB_H
  16. #define    _STDLIB_H
  17. #define    _STDLIB    "XDLIBS"
  18.  
  19. #ifndef _TYPES_H
  20. #include <types.h>
  21. #endif /* _TYPES_H */
  22.  
  23. #ifndef _STDDEF_H
  24. #include <stddef.h>
  25. #endif /* _STDDEF_H */
  26.  
  27. #ifndef _SUPPORT_H
  28. #include <support.h>
  29. #endif /* _SUPPORT_H */
  30.  
  31. /*
  32.  * some standard macros
  33.  */
  34. #define EXIT_FAILURE    (1)        /* failure return value for exit() */
  35. #define EXIT_SUCCESS    (0)         /* success return value for exit() */
  36.  
  37. #ifdef __MSHORT__
  38. # define RAND_MAX    (0x7FFF)    /* maximum value from rand() */
  39. #else
  40. # define RAND_MAX    (0x7FFFFFFF)    /* maximum value from rand() */
  41. #endif /* __MSHORT__ */
  42.  
  43. /* some library dependent stuff:
  44.  *   these variables are evaluated usually by startup code
  45.  */
  46. extern    int    errno;
  47.  
  48. extern    char    *etext;
  49. extern    char    *edata;
  50. extern    char    *end;
  51.  
  52. extern    short    _argc;
  53. extern    char    **_argv;
  54. extern    short    _ARGV;
  55. extern    short    _intsize;    /* sizeof(int) */
  56.  
  57. extern    short    _app;        /* app or acc ? */
  58. extern    short    _mint;        /* mintvers or 0 */
  59. extern    short    _magx;        /* MagiC version or 0 */
  60. extern    short    _geneva;    /* ??? */
  61.  
  62. /* some compatibility macros are included */
  63. #define sync()            /* sync() not possible, no operation */
  64.  
  65. extern    double    atof(const char *s);
  66. extern    int    atoi(const char *s);
  67. extern    long    atol(const char *s);
  68. /* missing ??:*/
  69. extern  double    strtod(char *number, char **nptr);
  70. /* of course double won't work but float would */
  71.  
  72. extern  long    strtol(char *number, char **nptr, int base);
  73. extern  unsigned long   strtoul(char *number, char **nptr, int base);
  74.  
  75. extern    int    rand(void);
  76. /* extern    void    srand(); */
  77. #define srand(seed)         /* no random seeding required */
  78.  
  79. extern    void    *calloc(size_t nobj, size_t size);
  80. extern    void    *malloc(size_t size);
  81. extern    void    *realloc(void *p, size_t size);
  82. #ifdef __MSHORT__
  83. extern    void    *lalloc(long size);
  84. extern    void    *lrealloc(void *p, long size);
  85. #else
  86. #define lalloc    malloc
  87. #define lrealloc realloc
  88. #endif
  89. extern    void    free(void *p);
  90.  
  91. extern    long    msize(void *block);
  92. extern    long    memavail(void);
  93.  
  94. extern    void    *alloca(size_t size);
  95.  
  96. extern    void    *sbrk(int amount);
  97. extern    int    brk(void *address);
  98.  
  99. extern    void    abort(void);
  100. extern    void    exit(int status);
  101. extern    void    atexit( void (*fnc)());
  102.  
  103. extern    int    system(const char *s);
  104. extern    char    *getenv(const char *name);
  105. extern    int    putenv(const char *name);
  106.  
  107. extern    void    *bsearch(const void *key, const void *base, size_t num, size_t size,
  108.                     int (*cmp)(const void * keyval, const void *datum));
  109. extern    void    qsort(void *base, size_t num, size_t size,
  110.                     int (*cmp)(const void * keyval, const void *datum));
  111. extern    int    abs(int x);
  112. extern    long    labs(long x);
  113.  
  114. #define    _abs(x)        ((x)<0?(-(x)):(x))
  115. #define _labs(x)    _abs(x)
  116.  
  117. typedef struct {
  118.     int        quot;    /* quotient    */
  119.     int        rem;    /* remainder     */
  120. } div_t;
  121.  
  122. typedef struct {
  123.     long    quot;    /* quotient    */
  124.     long    rem;    /* remainder     */
  125. } ldiv_t;
  126.  
  127. extern    div_t    div(int num, int denom);
  128. extern    ldiv_t    ldiv(long num, long denom);
  129.  
  130.  
  131. #endif /* _STDLIB_H */
  132.