2  * Copyright (c) 1990, 1993
 
     3  * © Portions copyright (c) 2006 Symbian Software Ltd. All rights reserved.
 
     5  *	The Regents of the University of California.  All rights reserved.
 
     7  * Redistribution and use in source and binary forms, with or without
 
     8  * modification, are permitted provided that the following conditions
 
    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.
 
    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
 
    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.
 
    48 #include <sys/cdefs.h>
 
    49 #include <sys/_null.h>
 
    50 #include <sys/_types.h>
 
    55 #ifndef _RUNE_T_DECLARED
 
    56 typedef	__rune_t	rune_t;
 
    57 #define	_RUNE_T_DECLARED
 
    61 #ifndef _SIZE_T_DECLARED
 
    62 typedef	__size_t	size_t;
 
    63 #define	_SIZE_T_DECLARED
 
    68 #ifndef _WCHAR_T_DECLARED
 
    69 typedef	__wchar_t	wchar_t;
 
    70 #define	_WCHAR_T_DECLARED
 
    71 #endif //_WCHAR_T_DECLARED
 
    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)
 
    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
 
    88 typedef unsigned short int wchar_t;
 
    89 #define	_WCHAR_T_DECLARED
 
    91 #endif // __wchar_t_defined
 
    92 #endif //__SYMBIAN32__
 
    95 	int	quot;		/* quotient */
 
    96 	int	rem;		/* remainder */
 
   104 #define	EXIT_FAILURE	1
 
   105 #define	EXIT_SUCCESS	0
 
   107 #define	RAND_MAX	0x7fffffff
 
   109 #ifndef __SYMBIAN32__
 
   110 extern int __mb_cur_max;
 
   111 #define	MB_CUR_MAX	__mb_cur_max
 
   117 #define inline __inline
 
   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);
 
   147 float	 strtof(const char * __restrict, char ** __restrict);
 
   149 IMPORT_C long	 strtol(const char * __restrict, char ** __restrict, int);
 
   153 	 strtold(const char * __restrict, char ** __restrict);
 
   157 	 strtoul(const char * __restrict, char ** __restrict, int);
 
   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);
 
   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).
 
   171  * (The only other extension made by C99 in thie header is _Exit().)
 
   173 #if __ISO_C_VISIBLE >= 1999
 
   174 #ifdef __LONG_LONG_SUPPORTED
 
   189 	 llabs(long long) __pure2;
 
   192 IMPORT_C lldiv_t	 lldiv(long long, long long) __pure2;
 
   197 	 strtoll(const char * __restrict, char ** __restrict, int);
 
   202 	 strtoull(const char * __restrict, char ** __restrict, int);
 
   203 #endif /* __LONG_LONG_SUPPORTED */
 
   205 IMPORT_C void	 _Exit(int) __dead2;
 
   206 #endif /* __ISO_C_VISIBLE >= 1999 */
 
   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.
 
   213 #if __POSIX_VISIBLE /* >= ??? */
 
   214 IMPORT_C int	 setenv(const char *, const char *, int);
 
   215 IMPORT_C void	 unsetenv(const char *);
 
   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.
 
   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
 
   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
 
   241 #endif /* __XSI_VISIBLE */
 
   244 extern const char *_malloc_options;
 
   245 extern void (*_malloc_message)(const char *, const char *, const char *,
 
   251 IMPORT_C const char *	 getprogname(void);
 
   252 IMPORT_C void    *reallocf(void *, size_t);
 
   253 IMPORT_C void	 setprogname(const char *);
 
   255 #ifdef __SYMBIAN_COMPILE_UNUSED__
 
   257 void	 srandomdev(void);
 
   259 /* Deprecated interfaces, to be removed in FreeBSD 6.0. */
 
   262 	 strtoq(const char *, char **, int);
 
   265 	 strtouq(const char *, char **, int);
 
   267 extern char *suboptarg;			/* getsubopt(3) external variable */
 
   268 #endif /* __BSD_VISIBLE */
 
   270 #ifdef __SYMBIAN32__ /* For libcrypt library */
 
   271 #ifndef _SETKEY_DECLARED
 
   272 void setkey(const char *key);
 
   283 #endif /* !_STDLIB_H_ */