home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/h/RCS/stdlib,v $
- * $Date: 1996/10/30 21:58:58 $
- * $Revision: 1.2 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: stdlib,v $
- * Revision 1.2 1996/10/30 21:58:58 unixlib
- * Massive changes made by Nick Burret and Peter Burwood.
- *
- * Revision 1.1 1996/04/19 21:02:57 simon
- * Initial revision
- *
- ***************************************************************************/
-
- /* ANSI Standard 4.10: General Utilities <stdlib.h>. */
-
- #ifndef __STDLIB_H
- #define __STDLIB_H
-
- #ifndef __STDDEF_H
- #include <stddef.h>
- #endif
- #ifndef __ERRNO_H
- #include <errno.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /* Returned by `div'. */
- typedef struct
- {
- int quot; /* Quotient. */
- int rem; /* Remainder. */
- } div_t;
-
- /* Returned by `ldiv'. */
- typedef struct
- {
- long int quot; /* Quotient. */
- long int rem; /* Remainder. */
- } ldiv_t;
-
- /* The largest number rand will return (same as INT_MAX). */
- #define RAND_MAX 2147483647
-
-
- /* Successful exit status. */
- #define EXIT_SUCCESS 0
- /* Failing exit status. */
- #define EXIT_FAILURE 1
-
- /* Maximum length of a multibyte character in the current locale. */
- #define MB_CUR_MAX 1
-
- /* Abort execution and generate a core-dump. */
- extern void abort(void);
- extern int atexit(void (*)(void));
- extern void exit(int);
- extern void _exit(int);
- extern char *getenv(const char *);
- extern int system(const char *);
-
- #define __MAX_AXCNT 33
- /* NB ANSI requires 32, C++ requires 1 extra */
-
- extern void (*__ax[__MAX_AXCNT])(void); /* atexit() functions */
- extern int __axcnt; /* atexit() function count */
-
- extern void *calloc(size_t,size_t);
- extern void free(void *);
- extern void *malloc(size_t);
- extern void *realloc(void *,size_t);
-
- /* src.c.alloc thinks these are in stdio.h, but that feels wrong ... */
- extern void *memalign(size_t alignment, size_t bytes);
- extern void cfree(void *mem);
- extern size_t malloc_usable_size(void* mem);
- extern void malloc_stats(void);
-
- #define rand() ((int)lrand())
- #define lrand48() lrand()
- #define srand48(s) srand(s)
-
- extern int (rand)(void);
- extern long lrand(void);
- extern void srand(long);
- extern long (lrand48)(void);
- extern void (srand48)(long);
- extern long (random)(void);
- extern void (srandom)(long);
-
- extern int abs(int);
- extern long int labs(long int);
- extern div_t div(int,int);
- extern ldiv_t ldiv(long,long);
-
- #define atof(s) strtod(s,0)
- #define atoi(s) ((int)strtol(s,0,10))
- #define atol(s) strtol(s,0,10)
-
- extern double (atof)(const char *);
- extern int (atoi)(const char *);
- extern long (atol)(const char *);
- extern double strtod(const char *,char **);
- extern long strtol(const char *,char **,int);
- extern unsigned long strtoul(const char *,char **,int);
-
- extern void *bsearch(const void *,const void *,size_t,size_t,
- int (*)(const void *,const void *));
- extern void qsort(void *,size_t,size_t,
- int (*)(const void *,const void *));
-
- #if 0
- extern int mblen(const char *,size_t);
- extern size_t mbstowcs(wchar_t *,const char *,size_t);
- extern int mbtowc(wchar_t *,const char *,size_t);
- extern size_t wcstombs(char *,const wchar_t *,size_t);
- extern int wctomb(char *,wchar_t);
- #endif
-
- /* BSD enhancements. */
-
- #ifndef __ALLOCA_H
- #include <alloca.h>
- #endif
-
- #define random() lrand()
- #define srandom(s) srand(s)
- /* Allocate size bytes on a page boundary. The storage cannot be freed. */
- extern void *valloc (size_t bytes);
-
- #if 0
- /* Set NAME to VALUE in the environment.
- If REPLACE is nonzero, overwrite an existing value. */
- extern int setenv (const char *name, const char *value, int replace);
- #endif
-
- /* System V enhancements. */
-
- /* Put string, which is of the form "NAME=VALUE" in the environment. */
- extern int putenv (char *string);
-
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-