2 * Copyright (c) 1990, 1993
4 * The Regents of the University of California. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 4. Neither the name of the University nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
31 * $FreeBSD: src/include/stdlib.h,v 1.57 2005/01/09 03:55:12 tjr Exp $
32 * Portions Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).All rights reserved.
46 #include <sys/cdefs.h>
47 #include <sys/_null.h>
48 #include <sys/_types.h>
53 #ifndef _RUNE_T_DECLARED
54 typedef __rune_t rune_t;
55 #define _RUNE_T_DECLARED
59 #ifndef _SIZE_T_DECLARED
60 typedef __size_t size_t;
61 #define _SIZE_T_DECLARED
66 #ifndef _WCHAR_T_DECLARED
67 typedef __wchar_t wchar_t;
68 #define _WCHAR_T_DECLARED
69 #endif //_WCHAR_T_DECLARED
72 //C++ built-in wchar data type which doesn't clash with the definition of wchar
73 #if !defined _WCHAR_T_DECLARED && defined __cplusplus && defined __WINSCW__
74 #if __option(wchar_type)
75 #define _WCHAR_T_DECLARED
76 #endif //__option (wchar_type)
79 #if !defined _WCHAR_T_DECLARED && !defined __wchar_t_defined
80 #if defined __cplusplus
81 #if defined __WINSCW__
82 typedef unsigned short int wchar_t;
83 #define _WCHAR_T_DECLARED
86 typedef unsigned short int wchar_t;
87 #define _WCHAR_T_DECLARED
89 #endif // __wchar_t_defined
90 #endif //__SYMBIAN32__
93 int quot; /* quotient */
94 int rem; /* remainder */
102 #define EXIT_FAILURE 1
103 #define EXIT_SUCCESS 0
105 #define RAND_MAX 0x7fffffff
107 #ifndef __SYMBIAN32__
108 extern int __mb_cur_max;
109 #define MB_CUR_MAX __mb_cur_max
115 #define inline __inline
118 IMPORT_C void abort(void) __dead2;
119 IMPORT_C int abs(int) __pure2;
120 IMPORT_C int atexit(void (*)(void));
121 IMPORT_C double atof(const char *);
122 IMPORT_C int atoi(const char *);
123 IMPORT_C long atol(const char *);
124 IMPORT_C void *bsearch(const void *, const void *, size_t,
125 size_t, int (*)(const void *, const void *));
126 IMPORT_C void *calloc(size_t, size_t);
127 IMPORT_C div_t div(int, int) __pure2;
128 IMPORT_C void exit(int) __dead2;
129 IMPORT_C void free(void *);
130 IMPORT_C char *getenv(const char *);
131 IMPORT_C long labs(long) __pure2;
132 IMPORT_C ldiv_t ldiv(long, long) __pure2;
133 IMPORT_C void *malloc(size_t);
134 IMPORT_C int mblen(const char *, size_t);
135 IMPORT_C size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
136 IMPORT_C int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
137 IMPORT_C void qsort(void *, size_t, size_t,
138 int (*)(const void *, const void *));
139 IMPORT_C int rand(void);
140 IMPORT_C void *realloc(void *, size_t);
141 IMPORT_C void srand(unsigned);
142 IMPORT_C double strtod(const char * __restrict, char ** __restrict);
145 float strtof(const char * __restrict, char ** __restrict);
147 IMPORT_C long strtol(const char * __restrict, char ** __restrict, int);
151 strtold(const char * __restrict, char ** __restrict);
155 strtoul(const char * __restrict, char ** __restrict, int);
157 IMPORT_C int system(const char *);
158 IMPORT_C int wctomb(char *, wchar_t);
159 IMPORT_C size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
162 * Functions added in C99 which we make conditionally available in the
163 * BSD^C89 namespace if the compiler supports `long long'.
164 * The #if test is more complicated than it ought to be because
165 * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
166 * is not supported in the compilation environment (which therefore means
167 * that it can't really be ISO C99).
169 * (The only other extension made by C99 in thie header is _Exit().)
171 #if __ISO_C_VISIBLE >= 1999
172 #ifdef __LONG_LONG_SUPPORTED
187 llabs(long long) __pure2;
190 IMPORT_C lldiv_t lldiv(long long, long long) __pure2;
195 strtoll(const char * __restrict, char ** __restrict, int);
200 strtoull(const char * __restrict, char ** __restrict, int);
201 #endif /* __LONG_LONG_SUPPORTED */
203 IMPORT_C void _Exit(int) __dead2;
204 #endif /* __ISO_C_VISIBLE >= 1999 */
207 * Extensions made by POSIX relative to C. We don't know yet which edition
208 * of POSIX made these extensions, so assume they've always been there until
209 * research can be done.
211 #if __POSIX_VISIBLE /* >= ??? */
212 IMPORT_C int setenv(const char *, const char *, int);
213 IMPORT_C void unsetenv(const char *);
217 * The only changes to the XSI namespace in revision 6 were the deletion
218 * of the ttyslot() and valloc() functions, which FreeBSD never declared
219 * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
220 * FreeBSD also does not have, and mktemp(), are to be deleted.
223 /* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
224 /* long a64l(const char *); */
225 #ifndef _MKSTEMP_DECLARED
226 IMPORT_C int mkstemp(char *);
228 #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
229 #define mkstemp64 mkstemp
230 #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
232 #define _MKSTEMP_DECLARED
234 IMPORT_C int putenv(const char *);
235 IMPORT_C long random(void);
236 IMPORT_C void srandom(unsigned long);
237 IMPORT_C char *realpath(const char *, char resolved_path[]);
238 IMPORT_C char *setstate(/* const */ char *);
239 IMPORT_C char *initstate(unsigned long /* XSI requires u_int */, char *, long);
240 #ifndef _SETKEY_DECLARED
241 int setkey(const char *);
242 #define _SETKEY_DECLARED
244 #endif /* __XSI_VISIBLE */
247 extern const char *_malloc_options;
248 extern void (*_malloc_message)(const char *, const char *, const char *,
254 IMPORT_C const char * getprogname(void);
255 IMPORT_C void *reallocf(void *, size_t);
256 IMPORT_C void setprogname(const char *);
258 #ifdef __SYMBIAN_COMPILE_UNUSED__
260 void srandomdev(void);
262 /* Deprecated interfaces, to be removed in FreeBSD 6.0. */
265 strtoq(const char *, char **, int);
268 strtouq(const char *, char **, int);
270 extern char *suboptarg; /* getsubopt(3) external variable */
271 #endif /* __BSD_VISIBLE */
273 #ifdef __SYMBIAN32__ /* For libcrypt library */
274 #ifndef _SETKEY_DECLARED
275 void setkey(const char *key);
286 #endif /* !_STDLIB_H_ */