epoc32/include/stdapis/stdlib.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 stdlib.h
     1 /*-
       
     2  * Copyright (c) 1990, 1993
       
     3  * © Portions copyright (c) 2006 Symbian Software Ltd. All rights reserved.
       
     4 
       
     5  *	The Regents of the University of California.  All rights reserved.
       
     6  *
       
     7  * Redistribution and use in source and binary forms, with or without
       
     8  * modification, are permitted provided that the following conditions
       
     9  * are met:
       
    10  * 1. Redistributions of source code must retain the above copyright
       
    11  *    notice, this list of conditions and the following disclaimer.
       
    12  * 2. Redistributions in binary form must reproduce the above copyright
       
    13  *    notice, this list of conditions and the following disclaimer in the
       
    14  *    documentation and/or other materials provided with the distribution.
       
    15  * 4. Neither the name of the University nor the names of its contributors
       
    16  *    may be used to endorse or promote products derived from this software
       
    17  *    without specific prior written permission.
       
    18  *
       
    19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
       
    20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       
    22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
       
    23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
       
    24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
       
    25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
       
    26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
       
    27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
       
    28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
       
    29  * SUCH DAMAGE.
       
    30  *
       
    31  *	@(#)stdlib.h	8.5 (Berkeley) 5/19/95
       
    32  * $FreeBSD: src/include/stdlib.h,v 1.57 2005/01/09 03:55:12 tjr Exp $
       
    33  * © Portions copyright (c) 2007 Symbian Software Ltd. All rights reserved.
       
    34  * © Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
       
    35  */
       
    36 
       
    37 #ifndef _STDLIB_H_
       
    38 #define	_STDLIB_H_
       
    39 
       
    40 //---
       
    41 #ifdef __cplusplus
       
    42 #include <e32def.h>
       
    43 
       
    44 extern "C" {
       
    45 #endif
       
    46 
       
    47 //---
       
    48 #include <sys/cdefs.h>
       
    49 #include <sys/_null.h>
       
    50 #include <sys/_types.h>
       
    51 
       
    52 #include <_ansi.h>
       
    53 
       
    54 #if __BSD_VISIBLE
       
    55 #ifndef _RUNE_T_DECLARED
       
    56 typedef	__rune_t	rune_t;
       
    57 #define	_RUNE_T_DECLARED
       
    58 #endif
       
    59 #endif
       
    60 
       
    61 #ifndef _SIZE_T_DECLARED
       
    62 typedef	__size_t	size_t;
       
    63 #define	_SIZE_T_DECLARED
       
    64 #endif
       
    65 
       
    66 #ifndef __SYMBIAN32__
       
    67 #ifndef	__cplusplus
       
    68 #ifndef _WCHAR_T_DECLARED
       
    69 typedef	__wchar_t	wchar_t;
       
    70 #define	_WCHAR_T_DECLARED
       
    71 #endif //_WCHAR_T_DECLARED
       
    72 #endif //__cplusplus
       
    73 #else
       
    74 //C++ built-in wchar data type which doesn't clash with the definition of wchar
       
    75 #if !defined _WCHAR_T_DECLARED && defined __cplusplus && defined __WINSCW__
       
    76 #if __option(wchar_type)
       
    77 #define	_WCHAR_T_DECLARED
       
    78 #endif //__option (wchar_type)
       
    79 #endif //__WINSCW__
       
    80 
       
    81 #if !defined _WCHAR_T_DECLARED && !defined __wchar_t_defined
       
    82 #if defined __cplusplus
       
    83 #if defined __WINSCW__
       
    84 typedef unsigned short int wchar_t;
       
    85 #define	_WCHAR_T_DECLARED
       
    86 #endif // __WINSCW__
       
    87 #else
       
    88 typedef unsigned short int wchar_t;
       
    89 #define	_WCHAR_T_DECLARED
       
    90 #endif // __cplusplus 
       
    91 #endif // __wchar_t_defined
       
    92 #endif //__SYMBIAN32__
       
    93 
       
    94 typedef struct {
       
    95 	int	quot;		/* quotient */
       
    96 	int	rem;		/* remainder */
       
    97 } div_t;
       
    98 
       
    99 typedef struct {
       
   100 	long	quot;
       
   101 	long	rem;
       
   102 } ldiv_t;
       
   103 
       
   104 #define	EXIT_FAILURE	1
       
   105 #define	EXIT_SUCCESS	0
       
   106 
       
   107 #define	RAND_MAX	0x7fffffff
       
   108 
       
   109 #ifndef __SYMBIAN32__
       
   110 extern int __mb_cur_max;
       
   111 #define	MB_CUR_MAX	__mb_cur_max
       
   112 #else
       
   113 #define	MB_CUR_MAX 4
       
   114 #endif
       
   115 
       
   116 //for armv5
       
   117 #define inline __inline
       
   118 
       
   119 __BEGIN_DECLS
       
   120 IMPORT_C void	 abort(void) __dead2;
       
   121 IMPORT_C int	 abs(int) __pure2;
       
   122 IMPORT_C int	 atexit(void (*)(void));
       
   123 IMPORT_C double	 atof(const char *);
       
   124 IMPORT_C int	 atoi(const char *);
       
   125 IMPORT_C long	 atol(const char *);
       
   126 IMPORT_C void	*bsearch(const void *, const void *, size_t,
       
   127 	    size_t, int (*)(const void *, const void *));
       
   128 IMPORT_C void	*calloc(size_t, size_t);
       
   129 IMPORT_C div_t	 div(int, int) __pure2;
       
   130 IMPORT_C void	 exit(int) __dead2;
       
   131 IMPORT_C void	 free(void *);
       
   132 IMPORT_C char	*getenv(const char *);
       
   133 IMPORT_C long	 labs(long) __pure2;
       
   134 IMPORT_C ldiv_t	 ldiv(long, long) __pure2;
       
   135 IMPORT_C void	*malloc(size_t);
       
   136 IMPORT_C int	 mblen(const char *, size_t);
       
   137 IMPORT_C size_t	 mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
       
   138 IMPORT_C int	 mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
       
   139 IMPORT_C void	 qsort(void *, size_t, size_t,
       
   140 	    int (*)(const void *, const void *));
       
   141 IMPORT_C int	 rand(void);
       
   142 IMPORT_C void	*realloc(void *, size_t);
       
   143 IMPORT_C void	 srand(unsigned);
       
   144 IMPORT_C double	 strtod(const char * __restrict, char ** __restrict);
       
   145 
       
   146 IMPORT_C 
       
   147 float	 strtof(const char * __restrict, char ** __restrict);
       
   148 
       
   149 IMPORT_C long	 strtol(const char * __restrict, char ** __restrict, int);
       
   150 
       
   151 IMPORT_C 
       
   152 long double
       
   153 	 strtold(const char * __restrict, char ** __restrict);
       
   154 
       
   155 IMPORT_C
       
   156 unsigned long
       
   157 	 strtoul(const char * __restrict, char ** __restrict, int);
       
   158 
       
   159 IMPORT_C int	 system(const char *);
       
   160 IMPORT_C int	 wctomb(char *, wchar_t);
       
   161 IMPORT_C size_t	 wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
       
   162 
       
   163 /*
       
   164  * Functions added in C99 which we make conditionally available in the
       
   165  * BSD^C89 namespace if the compiler supports `long long'.
       
   166  * The #if test is more complicated than it ought to be because
       
   167  * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
       
   168  * is not supported in the compilation environment (which therefore means
       
   169  * that it can't really be ISO C99).
       
   170  *
       
   171  * (The only other extension made by C99 in thie header is _Exit().)
       
   172  */
       
   173 #if __ISO_C_VISIBLE >= 1999
       
   174 #ifdef __LONG_LONG_SUPPORTED
       
   175 /* LONGLONG */
       
   176 typedef struct {
       
   177 	long long quot;
       
   178 	long long rem;
       
   179 } lldiv_t;
       
   180 
       
   181 /* LONGLONG */
       
   182 IMPORT_C
       
   183 long long
       
   184 	 atoll(const char *);
       
   185 
       
   186 /* LONGLONG */
       
   187 IMPORT_C
       
   188 long long
       
   189 	 llabs(long long) __pure2;
       
   190 
       
   191 /* LONGLONG */
       
   192 IMPORT_C lldiv_t	 lldiv(long long, long long) __pure2;
       
   193 
       
   194 /* LONGLONG */
       
   195 IMPORT_C 
       
   196 long long
       
   197 	 strtoll(const char * __restrict, char ** __restrict, int);
       
   198 
       
   199 /* LONGLONG */
       
   200 IMPORT_C 
       
   201 unsigned long long
       
   202 	 strtoull(const char * __restrict, char ** __restrict, int);
       
   203 #endif /* __LONG_LONG_SUPPORTED */
       
   204 
       
   205 IMPORT_C void	 _Exit(int) __dead2;
       
   206 #endif /* __ISO_C_VISIBLE >= 1999 */
       
   207 
       
   208 /*
       
   209  * Extensions made by POSIX relative to C.  We don't know yet which edition
       
   210  * of POSIX made these extensions, so assume they've always been there until
       
   211  * research can be done.
       
   212  */
       
   213 #if __POSIX_VISIBLE /* >= ??? */
       
   214 IMPORT_C int	 setenv(const char *, const char *, int);
       
   215 IMPORT_C void	 unsetenv(const char *);
       
   216 #endif
       
   217 
       
   218 /*
       
   219  * The only changes to the XSI namespace in revision 6 were the deletion
       
   220  * of the ttyslot() and valloc() functions, which FreeBSD never declared
       
   221  * in this header.  For revision 7, ecvt(), fcvt(), and gcvt(), which
       
   222  * FreeBSD also does not have, and mktemp(), are to be deleted.
       
   223  */
       
   224 #if __XSI_VISIBLE
       
   225 /* XXX XSI requires pollution from <sys/wait.h> here.  We'd rather not. */
       
   226 /* long	 a64l(const char *); */
       
   227 #ifndef _MKSTEMP_DECLARED
       
   228 IMPORT_C int	 mkstemp(char *);
       
   229 #define	_MKSTEMP_DECLARED
       
   230 #endif
       
   231 IMPORT_C int	 putenv(const char *);
       
   232 IMPORT_C long	 random(void);
       
   233 IMPORT_C void	 srandom(unsigned long);
       
   234 IMPORT_C char	*realpath(const char *, char resolved_path[]);
       
   235 IMPORT_C char	*setstate(/* const */ char *);
       
   236 IMPORT_C char	*initstate(unsigned long /* XSI requires u_int */, char *, long);
       
   237 #ifndef _SETKEY_DECLARED
       
   238 int	 setkey(const char *);
       
   239 #define	_SETKEY_DECLARED
       
   240 #endif
       
   241 #endif /* __XSI_VISIBLE */
       
   242 
       
   243 #if __BSD_VISIBLE
       
   244 extern const char *_malloc_options;
       
   245 extern void (*_malloc_message)(const char *, const char *, const char *,
       
   246 	    const char *);
       
   247 
       
   248 
       
   249 __uint32_t
       
   250 	 arc4random(void);
       
   251 IMPORT_C const char *	 getprogname(void);
       
   252 IMPORT_C void    *reallocf(void *, size_t);
       
   253 IMPORT_C void	 setprogname(const char *);
       
   254 
       
   255 #ifdef __SYMBIAN_COMPILE_UNUSED__
       
   256 void	 sranddev(void);
       
   257 void	 srandomdev(void);
       
   258 #endif
       
   259 /* Deprecated interfaces, to be removed in FreeBSD 6.0. */
       
   260 IMPORT_C
       
   261 __int64_t
       
   262 	 strtoq(const char *, char **, int);
       
   263 IMPORT_C
       
   264 __uint64_t
       
   265 	 strtouq(const char *, char **, int);
       
   266 
       
   267 extern char *suboptarg;			/* getsubopt(3) external variable */
       
   268 #endif /* __BSD_VISIBLE */
       
   269 
       
   270 #ifdef __SYMBIAN32__ /* For libcrypt library */
       
   271 #ifndef _SETKEY_DECLARED
       
   272 void setkey(const char *key);
       
   273 #endif
       
   274 #endif
       
   275 __END_DECLS
       
   276 
       
   277 //---
       
   278 #ifdef __cplusplus
       
   279 }
       
   280 #endif
       
   281 //---
       
   282 
       
   283 #endif /* !_STDLIB_H_ */