1 | /* The <stdlib.h> header defines certain common macros, types, and functions.*/
|
---|
2 |
|
---|
3 | #ifndef _STDLIB_H
|
---|
4 | #define _STDLIB_H
|
---|
5 |
|
---|
6 | #ifndef _ANSI_H
|
---|
7 | #include <ansi.h>
|
---|
8 | #endif
|
---|
9 |
|
---|
10 | /* The macros are NULL, EXIT_FAILURE, EXIT_SUCCESS, RAND_MAX, and MB_CUR_MAX.*/
|
---|
11 | #define NULL ((void *)0)
|
---|
12 |
|
---|
13 | #define EXIT_FAILURE 1 /* standard error return using exit() */
|
---|
14 | #define EXIT_SUCCESS 0 /* successful return using exit() */
|
---|
15 | #define RAND_MAX 32767 /* largest value generated by rand() */
|
---|
16 | #define MB_CUR_MAX 1 /* max value of multibyte character in MINIX */
|
---|
17 |
|
---|
18 | typedef struct { int quot, rem; } div_t;
|
---|
19 | typedef struct { long quot, rem; } ldiv_t;
|
---|
20 |
|
---|
21 | /* The types are size_t, wchar_t, div_t, and ldiv_t. */
|
---|
22 | #ifndef _SIZE_T
|
---|
23 | #define _SIZE_T
|
---|
24 | typedef unsigned int size_t; /* type returned by sizeof */
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | #ifndef _WCHAR_T
|
---|
28 | #define _WCHAR_T
|
---|
29 | typedef char wchar_t; /* type expanded character set */
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | /* Function Prototypes. */
|
---|
33 | _PROTOTYPE( void abort, (void) );
|
---|
34 | _PROTOTYPE( int abs, (int _j) );
|
---|
35 | _PROTOTYPE( int atexit, (void (*_func)(void)) );
|
---|
36 | _PROTOTYPE( double atof, (const char *_nptr) );
|
---|
37 | _PROTOTYPE( int atoi, (const char *_nptr) );
|
---|
38 | _PROTOTYPE( long atol, (const char *_nptr) );
|
---|
39 | _PROTOTYPE( void *calloc, (size_t _nmemb, size_t _size) );
|
---|
40 | _PROTOTYPE( div_t div, (int _numer, int _denom) );
|
---|
41 | _PROTOTYPE( void exit, (int _status) );
|
---|
42 | _PROTOTYPE( void free, (void *_ptr) );
|
---|
43 | _PROTOTYPE( char *getenv, (const char *_name) );
|
---|
44 | _PROTOTYPE( long labs, (long _j) );
|
---|
45 | _PROTOTYPE( ldiv_t ldiv, (long _numer, long _denom) );
|
---|
46 | _PROTOTYPE( void *malloc, (size_t _size) );
|
---|
47 | _PROTOTYPE( int mblen, (const char *_s, size_t _n) );
|
---|
48 | _PROTOTYPE( size_t mbstowcs, (wchar_t *_pwcs, const char *_s, size_t _n));
|
---|
49 | _PROTOTYPE( int mbtowc, (wchar_t *_pwc, const char *_s, size_t _n) );
|
---|
50 | _PROTOTYPE( int rand, (void) );
|
---|
51 | _PROTOTYPE( void *realloc, (void *_ptr, size_t _size) );
|
---|
52 | _PROTOTYPE( void srand, (unsigned int _seed) );
|
---|
53 | _PROTOTYPE( double strtod, (const char *_nptr, char **_endptr) );
|
---|
54 | _PROTOTYPE( long strtol, (const char *_nptr, char **_endptr, int _base) );
|
---|
55 | _PROTOTYPE( int system, (const char *_string) );
|
---|
56 | _PROTOTYPE( size_t wcstombs, (char *_s, const wchar_t *_pwcs, size_t _n));
|
---|
57 | _PROTOTYPE( int wctomb, (char *_s, wchar_t _wchar) );
|
---|
58 | _PROTOTYPE( void *bsearch, (const void *_key, const void *_base,
|
---|
59 | size_t _nmemb, size_t _size,
|
---|
60 | int (*compar) (const void *, const void *)) );
|
---|
61 | _PROTOTYPE( void qsort, (void *_base, size_t _nmemb, size_t _size,
|
---|
62 | int (*compar) (const void *, const void *)) );
|
---|
63 | _PROTOTYPE( unsigned long int strtoul,
|
---|
64 | (const char *_nptr, char **_endptr, int _base) );
|
---|
65 |
|
---|
66 | #ifdef _POSIX_SOURCE
|
---|
67 | /* Open Group Base Specifications Issue 6 */
|
---|
68 | _PROTOTYPE( int mkstemp, (char *_fmt) );
|
---|
69 | _PROTOTYPE( char *initstate, (unsigned _seed, char *_state,
|
---|
70 | size_t _size) );
|
---|
71 | _PROTOTYPE( long random, (void) );
|
---|
72 | _PROTOTYPE( char *setstate, (const char *state) );
|
---|
73 | _PROTOTYPE( void srandom, (unsigned seed) );
|
---|
74 | _PROTOTYPE( int getloadavg, (double *, int) );
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | #ifdef _MINIX
|
---|
78 | _PROTOTYPE( int putenv, (char *_name) );
|
---|
79 | _PROTOTYPE( int setenv, (const char *name, const char *val, const int f));
|
---|
80 |
|
---|
81 | /* According to POSIX, getopt should be in unistd.h. What do we do with
|
---|
82 | * this?
|
---|
83 | */
|
---|
84 | _PROTOTYPE(int getopt, (int _argc, char * const _argv[], const char *_opts));
|
---|
85 | extern char *optarg;
|
---|
86 | extern int optind, opterr, optopt;
|
---|
87 | #endif /* _MINIX */
|
---|
88 |
|
---|
89 | #endif /* STDLIB_H */
|
---|