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