1 /* stdlib.h <ndf@linux.mit.edu> */
8 /* Don't overwrite user definitions of NULL */
10 #define NULL ((void *) 0)
13 /* For program termination */
14 #define EXIT_FAILURE 1
15 #define EXIT_SUCCESS 0
17 /* Call all functions registered with `atexit' and `on_exit',
18 * in the reverse of the order in which they were registered
19 * perform stdio cleanup, and terminate program execution with STATUS. */
20 extern void exit __P ((int __status)) __attribute__ ((__noreturn__));
21 /* Register a function to be called when `exit' is called. */
22 extern int atexit __P ((void (*__func) (void)));
23 /* Abort execution and generate a core-dump. */
24 extern void abort __P ((void)) __attribute__ ((__noreturn__));
26 extern void * malloc __P ((size_t));
27 extern void * calloc __P ((size_t, size_t));
28 extern void free __P ((void *));
29 extern void * realloc __P ((void *, size_t));
33 extern void * malloc_dbg __P ((size_t, char* func, char* file, int line));
34 extern void * calloc_dbg __P ((size_t, size_t, char* func, char* file, int line));
35 extern void free_dbg __P ((void *, char* func, char* file, int line));
36 extern void * realloc_dbg __P ((void *, size_t, char* func, char* file, int line));
38 #define malloc(x) malloc_dbg((x),__FUNCTION__,__FILE__,__LINE__)
39 #define calloc(x,y) calloc_dbg((x),(y),__FUNCTION__,__FILE__,__LINE__)
40 #define free(x) free_dbg((x),__FUNCTION__,__FILE__,__LINE__)
41 #define realloc(x) realloc((x),__FUNCTION__,__FILE__,__LINE__)
45 extern int rand __P ((void));
46 extern void srand __P ((unsigned int seed));
48 extern long strtol __P ((const char * nptr, char ** endptr, int base));
49 extern unsigned long strtoul __P ((const char * nptr,
50 char ** endptr, int base));
51 #ifndef __HAS_NO_FLOATS__
52 extern float strtod __P ((const char * nptr, char ** endptr));
55 extern char *getenv __P ((__const char *__name));
57 extern int putenv __P ((__const char *__string));
59 extern int setenv __P ((__const char *__name, __const char *__value,
62 extern int system __P ((__const char *__command));
64 extern char * gcvt __P ((float number, size_t ndigit, char * buf));
66 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
67 /* Return the canonical absolute name of file NAME. The last file name
68 * component need not exist, and may be a symlink to a nonexistent file.
69 * If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
70 * name is PATH_MAX chars or more, returns null with `errno' set to
71 * ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
72 * name in RESOLVED. */
73 extern char *realpath __P ((__const char *__restrict __name,
74 char *__restrict __resolved));
78 /* Shorthand for type of comparison functions. */
79 typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
80 typedef __compar_fn_t comparison_fn_t;
81 /* Sort NMEMB elements of BASE, of SIZE bytes each,
82 using COMPAR to perform the comparisons. */
83 extern void qsort __P ((__ptr_t __base, size_t __nmemb, size_t __size,
84 __compar_fn_t __compar));
87 #define atof(x) strtod((x),(char**)0)
88 #define atoi(x) (int)strtol((x),(char**)0,10)
89 #define atol(x) strtol((x),(char**)0,10)
92 /* Returned by `div'. */
95 int quot; /* Quotient. */
96 int rem; /* Remainder. */
99 /* Returned by `ldiv'. */
102 long int quot; /* Quotient. */
103 long int rem; /* Remainder. */
108 #endif /* __STDLIB_H */