Updated PCI IDs to latest snapshot.
[tangerine.git] / compiler / clib / include / stdlib.h
blobb8a87a83fd3113ea82bc52f63bca646d14da4a59
1 #ifndef _STDLIB_H_
2 #define _STDLIB_H_
4 /*
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: ANSI-C header file stdlib.h
9 Lang: English
12 #include <sys/cdefs.h>
13 #include <sys/arosc.h>
15 /* It seems that also stdlib.h defines alloca() */
16 #include <alloca.h>
18 /* For wchar_t and size_t */
19 #include <stddef.h>
21 /* Types for div and ldiv */
22 typedef struct div_t {
23 int quot;
24 int rem;
25 } div_t;
27 typedef struct ldiv_t {
28 long int quot;
29 long int rem;
30 } ldiv_t;
32 #if defined AROS_HAVE_LONG_LONG
33 typedef struct lldiv_t {
34 long long int quot;
35 long long int rem;
36 } lldiv_t;
37 #endif
39 #ifndef NULL
40 #define NULL 0
41 #endif
43 #define EXIT_SUCCESS 0 /* Success exit status */
44 #define EXIT_FAILURE 20 /* Failing exit status */
46 /* Gives the largest size of a multibyte character for the current locale */
47 #define MB_CUR_MAX (__get_arosc_userdata()->acud_mb_cur_max)
49 __BEGIN_DECLS
51 /* String conversion functions */
52 double atof(const char *nptr);
53 int atoi(const char *nptr);
54 long int atol(const char *nptr);
55 #if defined AROS_HAVE_LONG_LONG
56 long long int atoll(const char *nptr);
57 #endif
59 double strtod(const char * restrict nptr, char ** restrict endptr);
60 float strtof(const char * restrict nptr, char ** restrict endptr);
61 long double strtold(const char * restrict nptr, char ** restrict endptr);
62 long int strtol(const char * restrict nptr,
63 char ** restrict endptr,
64 int base);
65 unsigned long int strtoul(const char * restrict nptr,
66 char ** restrict endptr,
67 int base);
69 #if defined AROS_HAVE_LONG_LONG
70 long long int strtoll(const char * restrict nptr,
71 char ** restrict endptr,
72 int base);
73 unsigned long long int strtoull(const char * restrict nptr,
74 char ** restrict endptr,
75 int base);
76 #endif
78 /* Pseudo-random number generation functions */
79 int rand (void);
80 void srand (unsigned int seed);
82 /* Max. number returned by rand() */
83 #ifndef RAND_MAX
84 # define RAND_MAX 2147483647
85 #endif
87 /* Unix pseudo-random functions */
88 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
89 #ifndef AROS_NOFPU
90 double drand48(void);
91 double erand48(unsigned short int xsubi[3]);
92 #else
93 void drand48(void);
94 void erand48(unsigned short int xsubi[3]);
95 #endif
96 long int lrand48(void);
97 long int nrand48(unsigned short int xsubi[3]);
98 long int mrand48(void);
99 long int jrand48(unsigned short int xsubi[3]);
100 void srand48(long int seedval);
101 unsigned short int *seed48(unsigned short int seed16v[3]);
102 void lcong48(unsigned short int param[7]);
104 /* Thread safe random */
105 int rand_r(unsigned int *);
107 long random(void);
108 void srandom(unsigned seed);
109 char *initstate(unsigned seed, char *state, int n);
110 char *setstate(char *state);
111 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
113 /* Memory management functions */
114 void *malloc(size_t size);
115 void *calloc(size_t count, size_t size);
116 void *realloc(void *oldmem, size_t newsize);
117 void *realloc_nocopy(void *oldmem, size_t newsize); /* AROS specific */
118 void free(void *memory);
119 int posix_memalign(void **memptr, size_t alignment, size_t size);
121 /* Communication with the environment */
122 void abort (void) __noreturn;
123 int atexit(void (*func)(void));
124 int on_exit(void (*func)(int, void *), void *);
125 void exit (int code) __noreturn;
126 int system(const char *string);
127 char *getenv(const char *name);
129 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
130 int putenv(const char *string);
131 int setenv(const char *name, const char *value, int overwrite);
132 void unsetenv(const char *name);
133 #endif
135 /* Searching and sorting utilities */
136 void qsort(void * array, size_t count, size_t elementsize,
137 int (*comparefunction)(const void * element1, const void * element2));
138 void *bsearch(const void * key, const void * base, size_t count,
139 size_t size, int (*comparefunction)(const void *, const void *));
141 /* Integer arithmetic functions */
142 int abs (int j);
143 long labs (long j);
144 #if defined AROS_HAVE_LONG_LONG
145 long long int llabs(long long int j);
146 #endif
148 div_t div(int numer, int denom);
149 ldiv_t ldiv(long int numer, long int denom);
150 #if defined AROS_HAVE_LONG_LONG
151 lldiv_t lldiv(long long int numer, long long int denom);
152 #endif
154 /* Multibyte character functions */
155 size_t mblen(const char *s, size_t n);
156 int mbtowc(wchar_t * restrict pwc, const char * restrict s, size_t n);
157 int wctomb(char *s, wchar_t wchar);
159 /* Multibyte string functions */
160 size_t mbstowcs(wchar_t * restrict pwcs, const char * restrict s, size_t n);
161 size_t wcstombs(char * restrict s, const wchar_t * restrict pwcs, size_t n);
163 /* Miscellaneous BSD functions */
164 int getloadavg(double loadavg[], int n);
166 /* The following are POSIX/SUS additions */
167 #if !defined(_ANSI_SOURCE)
168 long a64l(const char *);
169 #if 0 /* FIXME: not implemented */
170 char *ecvt(double, int, int *, int *);
171 char *fcvt (double, int, int *, int *);
172 #endif
173 char *gcvt(double, int, char *);
174 int getsubopt(char **, char *const *, char **);
175 int grantpt(int);
176 char *l64a(long);
177 char *mktemp(char *);
178 int mkstemp(char *);
179 char *ptsname(int);
180 char *realpath(const char *, char *);
181 void setkey(const char *);
182 int unlockpt(int);
183 #endif /* _ANSI_SOURCE */
185 __END_DECLS
187 #endif /* _STDLIB_H_ */