1.1 --- a/epoc32/include/stdapis/stdlib.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stdlib.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,283 @@
1.4 -stdlib.h
1.5 +/*-
1.6 + * Copyright (c) 1990, 1993
1.7 + * © Portions copyright (c) 2006 Symbian Software Ltd. All rights reserved.
1.8 +
1.9 + * The Regents of the University of California. All rights reserved.
1.10 + *
1.11 + * Redistribution and use in source and binary forms, with or without
1.12 + * modification, are permitted provided that the following conditions
1.13 + * are met:
1.14 + * 1. Redistributions of source code must retain the above copyright
1.15 + * notice, this list of conditions and the following disclaimer.
1.16 + * 2. Redistributions in binary form must reproduce the above copyright
1.17 + * notice, this list of conditions and the following disclaimer in the
1.18 + * documentation and/or other materials provided with the distribution.
1.19 + * 4. Neither the name of the University nor the names of its contributors
1.20 + * may be used to endorse or promote products derived from this software
1.21 + * without specific prior written permission.
1.22 + *
1.23 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1.24 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.25 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.26 + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1.27 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.28 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.29 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.30 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.31 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.32 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.33 + * SUCH DAMAGE.
1.34 + *
1.35 + * @(#)stdlib.h 8.5 (Berkeley) 5/19/95
1.36 + * $FreeBSD: src/include/stdlib.h,v 1.57 2005/01/09 03:55:12 tjr Exp $
1.37 + * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
1.38 + * © Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
1.39 + */
1.40 +
1.41 +#ifndef _STDLIB_H_
1.42 +#define _STDLIB_H_
1.43 +
1.44 +//---
1.45 +#ifdef __cplusplus
1.46 +#include <e32def.h>
1.47 +
1.48 +extern "C" {
1.49 +#endif
1.50 +
1.51 +//---
1.52 +#include <sys/cdefs.h>
1.53 +#include <sys/_null.h>
1.54 +#include <sys/_types.h>
1.55 +
1.56 +#include <_ansi.h>
1.57 +
1.58 +#if __BSD_VISIBLE
1.59 +#ifndef _RUNE_T_DECLARED
1.60 +typedef __rune_t rune_t;
1.61 +#define _RUNE_T_DECLARED
1.62 +#endif
1.63 +#endif
1.64 +
1.65 +#ifndef _SIZE_T_DECLARED
1.66 +typedef __size_t size_t;
1.67 +#define _SIZE_T_DECLARED
1.68 +#endif
1.69 +
1.70 +#ifndef __SYMBIAN32__
1.71 +#ifndef __cplusplus
1.72 +#ifndef _WCHAR_T_DECLARED
1.73 +typedef __wchar_t wchar_t;
1.74 +#define _WCHAR_T_DECLARED
1.75 +#endif //_WCHAR_T_DECLARED
1.76 +#endif //__cplusplus
1.77 +#else
1.78 +//C++ built-in wchar data type which doesn't clash with the definition of wchar
1.79 +#if !defined _WCHAR_T_DECLARED && defined __cplusplus && defined __WINSCW__
1.80 +#if __option(wchar_type)
1.81 +#define _WCHAR_T_DECLARED
1.82 +#endif //__option (wchar_type)
1.83 +#endif //__WINSCW__
1.84 +
1.85 +#if !defined _WCHAR_T_DECLARED && !defined __wchar_t_defined
1.86 +#if defined __cplusplus
1.87 +#if defined __WINSCW__
1.88 +typedef unsigned short int wchar_t;
1.89 +#define _WCHAR_T_DECLARED
1.90 +#endif // __WINSCW__
1.91 +#else
1.92 +typedef unsigned short int wchar_t;
1.93 +#define _WCHAR_T_DECLARED
1.94 +#endif // __cplusplus
1.95 +#endif // __wchar_t_defined
1.96 +#endif //__SYMBIAN32__
1.97 +
1.98 +typedef struct {
1.99 + int quot; /* quotient */
1.100 + int rem; /* remainder */
1.101 +} div_t;
1.102 +
1.103 +typedef struct {
1.104 + long quot;
1.105 + long rem;
1.106 +} ldiv_t;
1.107 +
1.108 +#define EXIT_FAILURE 1
1.109 +#define EXIT_SUCCESS 0
1.110 +
1.111 +#define RAND_MAX 0x7fffffff
1.112 +
1.113 +#ifndef __SYMBIAN32__
1.114 +extern int __mb_cur_max;
1.115 +#define MB_CUR_MAX __mb_cur_max
1.116 +#else
1.117 +#define MB_CUR_MAX 4
1.118 +#endif
1.119 +
1.120 +//for armv5
1.121 +#define inline __inline
1.122 +
1.123 +__BEGIN_DECLS
1.124 +IMPORT_C void abort(void) __dead2;
1.125 +IMPORT_C int abs(int) __pure2;
1.126 +IMPORT_C int atexit(void (*)(void));
1.127 +IMPORT_C double atof(const char *);
1.128 +IMPORT_C int atoi(const char *);
1.129 +IMPORT_C long atol(const char *);
1.130 +IMPORT_C void *bsearch(const void *, const void *, size_t,
1.131 + size_t, int (*)(const void *, const void *));
1.132 +IMPORT_C void *calloc(size_t, size_t);
1.133 +IMPORT_C div_t div(int, int) __pure2;
1.134 +IMPORT_C void exit(int) __dead2;
1.135 +IMPORT_C void free(void *);
1.136 +IMPORT_C char *getenv(const char *);
1.137 +IMPORT_C long labs(long) __pure2;
1.138 +IMPORT_C ldiv_t ldiv(long, long) __pure2;
1.139 +IMPORT_C void *malloc(size_t);
1.140 +IMPORT_C int mblen(const char *, size_t);
1.141 +IMPORT_C size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
1.142 +IMPORT_C int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
1.143 +IMPORT_C void qsort(void *, size_t, size_t,
1.144 + int (*)(const void *, const void *));
1.145 +IMPORT_C int rand(void);
1.146 +IMPORT_C void *realloc(void *, size_t);
1.147 +IMPORT_C void srand(unsigned);
1.148 +IMPORT_C double strtod(const char * __restrict, char ** __restrict);
1.149 +
1.150 +IMPORT_C
1.151 +float strtof(const char * __restrict, char ** __restrict);
1.152 +
1.153 +IMPORT_C long strtol(const char * __restrict, char ** __restrict, int);
1.154 +
1.155 +IMPORT_C
1.156 +long double
1.157 + strtold(const char * __restrict, char ** __restrict);
1.158 +
1.159 +IMPORT_C
1.160 +unsigned long
1.161 + strtoul(const char * __restrict, char ** __restrict, int);
1.162 +
1.163 +IMPORT_C int system(const char *);
1.164 +IMPORT_C int wctomb(char *, wchar_t);
1.165 +IMPORT_C size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
1.166 +
1.167 +/*
1.168 + * Functions added in C99 which we make conditionally available in the
1.169 + * BSD^C89 namespace if the compiler supports `long long'.
1.170 + * The #if test is more complicated than it ought to be because
1.171 + * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
1.172 + * is not supported in the compilation environment (which therefore means
1.173 + * that it can't really be ISO C99).
1.174 + *
1.175 + * (The only other extension made by C99 in thie header is _Exit().)
1.176 + */
1.177 +#if __ISO_C_VISIBLE >= 1999
1.178 +#ifdef __LONG_LONG_SUPPORTED
1.179 +/* LONGLONG */
1.180 +typedef struct {
1.181 + long long quot;
1.182 + long long rem;
1.183 +} lldiv_t;
1.184 +
1.185 +/* LONGLONG */
1.186 +IMPORT_C
1.187 +long long
1.188 + atoll(const char *);
1.189 +
1.190 +/* LONGLONG */
1.191 +IMPORT_C
1.192 +long long
1.193 + llabs(long long) __pure2;
1.194 +
1.195 +/* LONGLONG */
1.196 +IMPORT_C lldiv_t lldiv(long long, long long) __pure2;
1.197 +
1.198 +/* LONGLONG */
1.199 +IMPORT_C
1.200 +long long
1.201 + strtoll(const char * __restrict, char ** __restrict, int);
1.202 +
1.203 +/* LONGLONG */
1.204 +IMPORT_C
1.205 +unsigned long long
1.206 + strtoull(const char * __restrict, char ** __restrict, int);
1.207 +#endif /* __LONG_LONG_SUPPORTED */
1.208 +
1.209 +IMPORT_C void _Exit(int) __dead2;
1.210 +#endif /* __ISO_C_VISIBLE >= 1999 */
1.211 +
1.212 +/*
1.213 + * Extensions made by POSIX relative to C. We don't know yet which edition
1.214 + * of POSIX made these extensions, so assume they've always been there until
1.215 + * research can be done.
1.216 + */
1.217 +#if __POSIX_VISIBLE /* >= ??? */
1.218 +IMPORT_C int setenv(const char *, const char *, int);
1.219 +IMPORT_C void unsetenv(const char *);
1.220 +#endif
1.221 +
1.222 +/*
1.223 + * The only changes to the XSI namespace in revision 6 were the deletion
1.224 + * of the ttyslot() and valloc() functions, which FreeBSD never declared
1.225 + * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which
1.226 + * FreeBSD also does not have, and mktemp(), are to be deleted.
1.227 + */
1.228 +#if __XSI_VISIBLE
1.229 +/* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
1.230 +/* long a64l(const char *); */
1.231 +#ifndef _MKSTEMP_DECLARED
1.232 +IMPORT_C int mkstemp(char *);
1.233 +#define _MKSTEMP_DECLARED
1.234 +#endif
1.235 +IMPORT_C int putenv(const char *);
1.236 +IMPORT_C long random(void);
1.237 +IMPORT_C void srandom(unsigned long);
1.238 +IMPORT_C char *realpath(const char *, char resolved_path[]);
1.239 +IMPORT_C char *setstate(/* const */ char *);
1.240 +IMPORT_C char *initstate(unsigned long /* XSI requires u_int */, char *, long);
1.241 +#ifndef _SETKEY_DECLARED
1.242 +int setkey(const char *);
1.243 +#define _SETKEY_DECLARED
1.244 +#endif
1.245 +#endif /* __XSI_VISIBLE */
1.246 +
1.247 +#if __BSD_VISIBLE
1.248 +extern const char *_malloc_options;
1.249 +extern void (*_malloc_message)(const char *, const char *, const char *,
1.250 + const char *);
1.251 +
1.252 +
1.253 +__uint32_t
1.254 + arc4random(void);
1.255 +IMPORT_C const char * getprogname(void);
1.256 +IMPORT_C void *reallocf(void *, size_t);
1.257 +IMPORT_C void setprogname(const char *);
1.258 +
1.259 +#ifdef __SYMBIAN_COMPILE_UNUSED__
1.260 +void sranddev(void);
1.261 +void srandomdev(void);
1.262 +#endif
1.263 +/* Deprecated interfaces, to be removed in FreeBSD 6.0. */
1.264 +IMPORT_C
1.265 +__int64_t
1.266 + strtoq(const char *, char **, int);
1.267 +IMPORT_C
1.268 +__uint64_t
1.269 + strtouq(const char *, char **, int);
1.270 +
1.271 +extern char *suboptarg; /* getsubopt(3) external variable */
1.272 +#endif /* __BSD_VISIBLE */
1.273 +
1.274 +#ifdef __SYMBIAN32__ /* For libcrypt library */
1.275 +#ifndef _SETKEY_DECLARED
1.276 +void setkey(const char *key);
1.277 +#endif
1.278 +#endif
1.279 +__END_DECLS
1.280 +
1.281 +//---
1.282 +#ifdef __cplusplus
1.283 +}
1.284 +#endif
1.285 +//---
1.286 +
1.287 +#endif /* !_STDLIB_H_ */