epoc32/include/stdapis/stdlib.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*-
     2  * Copyright (c) 1990, 1993
     3 
     4  *	The Regents of the University of California.  All rights reserved.
     5  *
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions
     8  * are met:
     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.
    17  *
    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
    28  * SUCH DAMAGE.
    29  *
    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.
    33  */
    34 
    35 #ifndef _STDLIB_H_
    36 #define	_STDLIB_H_
    37 
    38 //---
    39 #ifdef __cplusplus
    40 #include <e32def.h>
    41 
    42 extern "C" {
    43 #endif
    44 
    45 //---
    46 #include <sys/cdefs.h>
    47 #include <sys/_null.h>
    48 #include <sys/_types.h>
    49 
    50 #include <_ansi.h>
    51 
    52 #if __BSD_VISIBLE
    53 #ifndef _RUNE_T_DECLARED
    54 typedef	__rune_t	rune_t;
    55 #define	_RUNE_T_DECLARED
    56 #endif
    57 #endif
    58 
    59 #ifndef _SIZE_T_DECLARED
    60 typedef	__size_t	size_t;
    61 #define	_SIZE_T_DECLARED
    62 #endif
    63 
    64 #ifndef __SYMBIAN32__
    65 #ifndef	__cplusplus
    66 #ifndef _WCHAR_T_DECLARED
    67 typedef	__wchar_t	wchar_t;
    68 #define	_WCHAR_T_DECLARED
    69 #endif //_WCHAR_T_DECLARED
    70 #endif //__cplusplus
    71 #else
    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)
    77 #endif //__WINSCW__
    78 
    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
    84 #endif // __WINSCW__
    85 #else
    86 typedef unsigned short int wchar_t;
    87 #define	_WCHAR_T_DECLARED
    88 #endif // __cplusplus 
    89 #endif // __wchar_t_defined
    90 #endif //__SYMBIAN32__
    91 
    92 typedef struct {
    93 	int	quot;		/* quotient */
    94 	int	rem;		/* remainder */
    95 } div_t;
    96 
    97 typedef struct {
    98 	long	quot;
    99 	long	rem;
   100 } ldiv_t;
   101 
   102 #define	EXIT_FAILURE	1
   103 #define	EXIT_SUCCESS	0
   104 
   105 #define	RAND_MAX	0x7fffffff
   106 
   107 #ifndef __SYMBIAN32__
   108 extern int __mb_cur_max;
   109 #define	MB_CUR_MAX	__mb_cur_max
   110 #else
   111 #define	MB_CUR_MAX 4
   112 #endif
   113 
   114 //for armv5
   115 #define inline __inline
   116 
   117 __BEGIN_DECLS
   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);
   143 
   144 IMPORT_C 
   145 float	 strtof(const char * __restrict, char ** __restrict);
   146 
   147 IMPORT_C long	 strtol(const char * __restrict, char ** __restrict, int);
   148 
   149 IMPORT_C 
   150 long double
   151 	 strtold(const char * __restrict, char ** __restrict);
   152 
   153 IMPORT_C
   154 unsigned long
   155 	 strtoul(const char * __restrict, char ** __restrict, int);
   156 
   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);
   160 
   161 /*
   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).
   168  *
   169  * (The only other extension made by C99 in thie header is _Exit().)
   170  */
   171 #if __ISO_C_VISIBLE >= 1999
   172 #ifdef __LONG_LONG_SUPPORTED
   173 /* LONGLONG */
   174 typedef struct {
   175 	long long quot;
   176 	long long rem;
   177 } lldiv_t;
   178 
   179 /* LONGLONG */
   180 IMPORT_C
   181 long long
   182 	 atoll(const char *);
   183 
   184 /* LONGLONG */
   185 IMPORT_C
   186 long long
   187 	 llabs(long long) __pure2;
   188 
   189 /* LONGLONG */
   190 IMPORT_C lldiv_t	 lldiv(long long, long long) __pure2;
   191 
   192 /* LONGLONG */
   193 IMPORT_C 
   194 long long
   195 	 strtoll(const char * __restrict, char ** __restrict, int);
   196 
   197 /* LONGLONG */
   198 IMPORT_C 
   199 unsigned long long
   200 	 strtoull(const char * __restrict, char ** __restrict, int);
   201 #endif /* __LONG_LONG_SUPPORTED */
   202 
   203 IMPORT_C void	 _Exit(int) __dead2;
   204 #endif /* __ISO_C_VISIBLE >= 1999 */
   205 
   206 /*
   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.
   210  */
   211 #if __POSIX_VISIBLE /* >= ??? */
   212 IMPORT_C int	 setenv(const char *, const char *, int);
   213 IMPORT_C void	 unsetenv(const char *);
   214 #endif
   215 
   216 /*
   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.
   221  */
   222 #if __XSI_VISIBLE
   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 *);
   227 
   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 */
   231 
   232 #define	_MKSTEMP_DECLARED
   233 #endif
   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
   243 #endif
   244 #endif /* __XSI_VISIBLE */
   245 
   246 #if __BSD_VISIBLE
   247 extern const char *_malloc_options;
   248 extern void (*_malloc_message)(const char *, const char *, const char *,
   249 	    const char *);
   250 
   251 
   252 __uint32_t
   253 	 arc4random(void);
   254 IMPORT_C const char *	 getprogname(void);
   255 IMPORT_C void    *reallocf(void *, size_t);
   256 IMPORT_C void	 setprogname(const char *);
   257 
   258 #ifdef __SYMBIAN_COMPILE_UNUSED__
   259 void	 sranddev(void);
   260 void	 srandomdev(void);
   261 #endif
   262 /* Deprecated interfaces, to be removed in FreeBSD 6.0. */
   263 IMPORT_C
   264 __int64_t
   265 	 strtoq(const char *, char **, int);
   266 IMPORT_C
   267 __uint64_t
   268 	 strtouq(const char *, char **, int);
   269 
   270 extern char *suboptarg;			/* getsubopt(3) external variable */
   271 #endif /* __BSD_VISIBLE */
   272 
   273 #ifdef __SYMBIAN32__ /* For libcrypt library */
   274 #ifndef _SETKEY_DECLARED
   275 void setkey(const char *key);
   276 #endif
   277 #endif
   278 __END_DECLS
   279 
   280 //---
   281 #ifdef __cplusplus
   282 }
   283 #endif
   284 //---
   285 
   286 #endif /* !_STDLIB_H_ */