os/ossrv/genericopenlibs/openenvcore/include/stdlib.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 #ifdef __SYMBIAN32__
    53 #ifdef __WINSCW__
    54 #ifndef __SOFTFP
    55 #define __SOFTFP
    56 #endif /* __SOFTFP */
    57 #endif//__WINSCW__
    58 #endif//__SYMBIAN32__
    59 
    60 #if __BSD_VISIBLE
    61 #ifndef _RUNE_T_DECLARED
    62 typedef	__rune_t	rune_t;
    63 #define	_RUNE_T_DECLARED
    64 #endif
    65 #endif
    66 
    67 #ifndef _SIZE_T_DECLARED
    68 typedef	__size_t	size_t;
    69 #define	_SIZE_T_DECLARED
    70 #endif
    71 
    72 #ifndef __SYMBIAN32__
    73 #ifndef	__cplusplus
    74 #ifndef _WCHAR_T_DECLARED
    75 typedef	__wchar_t	wchar_t;
    76 #define	_WCHAR_T_DECLARED
    77 #endif //_WCHAR_T_DECLARED
    78 #endif //__cplusplus
    79 #else
    80 //C++ built-in wchar data type which doesn't clash with the definition of wchar
    81 #if !defined _WCHAR_T_DECLARED && defined __cplusplus && defined __WINSCW__
    82 #if __option(wchar_type)
    83 #define	_WCHAR_T_DECLARED
    84 #endif //__option (wchar_type)
    85 #endif //__WINSCW__
    86 
    87 #if !defined _WCHAR_T_DECLARED && !defined __wchar_t_defined
    88 #if defined __cplusplus
    89 #if defined __WINSCW__
    90 typedef unsigned short int wchar_t;
    91 #define	_WCHAR_T_DECLARED
    92 #endif // __WINSCW__
    93 #else
    94 typedef unsigned short int wchar_t;
    95 #define	_WCHAR_T_DECLARED
    96 #endif // __cplusplus 
    97 #endif // __wchar_t_defined
    98 #endif //__SYMBIAN32__
    99 
   100 typedef struct {
   101 	int	quot;		/* quotient */
   102 	int	rem;		/* remainder */
   103 } div_t;
   104 
   105 typedef struct {
   106 	long	quot;
   107 	long	rem;
   108 } ldiv_t;
   109 
   110 #define	EXIT_FAILURE	1
   111 #define	EXIT_SUCCESS	0
   112 
   113 #define	RAND_MAX	0x7fffffff
   114 
   115 #ifndef __SYMBIAN32__
   116 extern int __mb_cur_max;
   117 #define	MB_CUR_MAX	__mb_cur_max
   118 #else
   119 #define	MB_CUR_MAX 4
   120 #endif
   121 
   122 //for armv5
   123 #define inline __inline
   124 
   125 __BEGIN_DECLS
   126 IMPORT_C void	 abort(void) __dead2;
   127 IMPORT_C int	 abs(int) __pure2;
   128 IMPORT_C int	 atexit(void (*)(void));
   129 IMPORT_C double	 atof(const char *) __SOFTFP;
   130 IMPORT_C int	 atoi(const char *);
   131 IMPORT_C long	 atol(const char *);
   132 IMPORT_C void	*bsearch(const void *, const void *, size_t,
   133 	    size_t, int (*)(const void *, const void *));
   134 IMPORT_C void	*calloc(size_t, size_t);
   135 IMPORT_C div_t	 div(int, int) __pure2;
   136 IMPORT_C void	 exit(int) __dead2;
   137 IMPORT_C void	 free(void *);
   138 IMPORT_C char	*getenv(const char *);
   139 IMPORT_C long	 labs(long) __pure2;
   140 IMPORT_C ldiv_t	 ldiv(long, long) __pure2;
   141 IMPORT_C void	*malloc(size_t);
   142 IMPORT_C int	 mblen(const char *, size_t);
   143 IMPORT_C size_t	 mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
   144 IMPORT_C int	 mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
   145 IMPORT_C void	 qsort(void *, size_t, size_t,
   146 	    int (*)(const void *, const void *));
   147 IMPORT_C int	 rand(void);
   148 IMPORT_C void	*realloc(void *, size_t);
   149 IMPORT_C void	 srand(unsigned);
   150 IMPORT_C double	 strtod(const char * __restrict, char ** __restrict) __SOFTFP;
   151 
   152 IMPORT_C 
   153 float	 strtof(const char * __restrict, char ** __restrict) __SOFTFP;
   154 
   155 IMPORT_C long	 strtol(const char * __restrict, char ** __restrict, int);
   156 
   157 IMPORT_C 
   158 long double
   159 	 strtold(const char * __restrict, char ** __restrict) __SOFTFP;
   160 
   161 IMPORT_C
   162 unsigned long
   163 	 strtoul(const char * __restrict, char ** __restrict, int);
   164 
   165 IMPORT_C int	 system(const char *);
   166 IMPORT_C int	 wctomb(char *, wchar_t);
   167 IMPORT_C size_t	 wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
   168 
   169 /*
   170  * Functions added in C99 which we make conditionally available in the
   171  * BSD^C89 namespace if the compiler supports `long long'.
   172  * The #if test is more complicated than it ought to be because
   173  * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long'
   174  * is not supported in the compilation environment (which therefore means
   175  * that it can't really be ISO C99).
   176  *
   177  * (The only other extension made by C99 in thie header is _Exit().)
   178  */
   179 #if __ISO_C_VISIBLE >= 1999
   180 #ifdef __LONG_LONG_SUPPORTED
   181 /* LONGLONG */
   182 typedef struct {
   183 	long long quot;
   184 	long long rem;
   185 } lldiv_t;
   186 
   187 /* LONGLONG */
   188 IMPORT_C
   189 long long
   190 	 atoll(const char *);
   191 
   192 /* LONGLONG */
   193 IMPORT_C
   194 long long
   195 	 llabs(long long) __pure2;
   196 
   197 /* LONGLONG */
   198 IMPORT_C lldiv_t	 lldiv(long long, long long) __pure2;
   199 
   200 /* LONGLONG */
   201 IMPORT_C 
   202 long long
   203 	 strtoll(const char * __restrict, char ** __restrict, int);
   204 
   205 /* LONGLONG */
   206 IMPORT_C 
   207 unsigned long long
   208 	 strtoull(const char * __restrict, char ** __restrict, int);
   209 #endif /* __LONG_LONG_SUPPORTED */
   210 
   211 IMPORT_C void	 _Exit(int) __dead2;
   212 #endif /* __ISO_C_VISIBLE >= 1999 */
   213 
   214 /*
   215  * Extensions made by POSIX relative to C.  We don't know yet which edition
   216  * of POSIX made these extensions, so assume they've always been there until
   217  * research can be done.
   218  */
   219 #if __POSIX_VISIBLE /* >= ??? */
   220 IMPORT_C int	 setenv(const char *, const char *, int);
   221 IMPORT_C void	 unsetenv(const char *);
   222 #endif
   223 
   224 /*
   225  * The only changes to the XSI namespace in revision 6 were the deletion
   226  * of the ttyslot() and valloc() functions, which FreeBSD never declared
   227  * in this header.  For revision 7, ecvt(), fcvt(), and gcvt(), which
   228  * FreeBSD also does not have, and mktemp(), are to be deleted.
   229  */
   230 #if __XSI_VISIBLE
   231 /* XXX XSI requires pollution from <sys/wait.h> here.  We'd rather not. */
   232 /* long	 a64l(const char *); */
   233 #ifndef _MKSTEMP_DECLARED
   234 IMPORT_C int	 mkstemp(char *);
   235 
   236 #if defined(SYMBIAN_OE_LARGE_FILE_SUPPORT) && !defined(SYMBIAN_OE_NO_LFS)
   237 #define mkstemp64 mkstemp
   238 #endif /* SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS */
   239 
   240 #define	_MKSTEMP_DECLARED
   241 #endif
   242 IMPORT_C int	 putenv(const char *);
   243 IMPORT_C long	 random(void);
   244 IMPORT_C void	 srandom(unsigned long);
   245 IMPORT_C char	*realpath(const char *, char resolved_path[]);
   246 IMPORT_C char	*setstate(/* const */ char *);
   247 IMPORT_C char	*initstate(unsigned long /* XSI requires u_int */, char *, long);
   248 #ifndef _SETKEY_DECLARED
   249 int	 setkey(const char *);
   250 #define	_SETKEY_DECLARED
   251 #endif
   252 #endif /* __XSI_VISIBLE */
   253 
   254 #if __BSD_VISIBLE
   255 extern const char *_malloc_options;
   256 extern void (*_malloc_message)(const char *, const char *, const char *,
   257 	    const char *);
   258 
   259 
   260 __uint32_t
   261 	 arc4random(void);
   262 IMPORT_C const char *	 getprogname(void);
   263 IMPORT_C void    *reallocf(void *, size_t);
   264 IMPORT_C void	 setprogname(const char *);
   265 
   266 #ifdef __SYMBIAN_COMPILE_UNUSED__
   267 void	 sranddev(void);
   268 void	 srandomdev(void);
   269 #endif
   270 /* Deprecated interfaces, to be removed in FreeBSD 6.0. */
   271 IMPORT_C
   272 __int64_t
   273 	 strtoq(const char *, char **, int);
   274 IMPORT_C
   275 __uint64_t
   276 	 strtouq(const char *, char **, int);
   277 
   278 extern char *suboptarg;			/* getsubopt(3) external variable */
   279 #endif /* __BSD_VISIBLE */
   280 
   281 #ifdef __SYMBIAN32__ /* For libcrypt library */
   282 #ifndef _SETKEY_DECLARED
   283 void setkey(const char *key);
   284 #endif
   285 #endif
   286 __END_DECLS
   287 
   288 //---
   289 #ifdef __cplusplus
   290 }
   291 #endif
   292 //---
   293 
   294 #endif /* !_STDLIB_H_ */