1.1 --- a/epoc32/include/libc/stdlib_r.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/libc/stdlib_r.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,88 @@
1.4 -stdlib_r.h
1.5 +/*
1.6 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description:
1.19 +* Extension of <stdlib.h> with reentrant functions.
1.20 +*
1.21 +*
1.22 +*/
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +
1.28 +
1.29 +
1.30 +/**
1.31 + @file
1.32 + @publishedAll
1.33 + @released
1.34 +*/
1.35 +
1.36 +
1.37 +#ifndef _STDLIB_R_H_
1.38 +#define _STDLIB_R_H_
1.39 +
1.40 +#ifdef __cplusplus
1.41 +extern "C" {
1.42 +#endif
1.43 +
1.44 +#include <stdlib.h>
1.45 +#include <sys/reent.h>
1.46 +
1.47 +/**
1.48 +EPOC32 malloc uses the thread heap, so it is already thread-safe
1.49 +and no _malloc_r variants are needed.
1.50 +*/
1.51 +#define _malloc_r(x,n) malloc(n)
1.52 +#define _calloc_r(x,n,m) calloc(n,m)
1.53 +#define _realloc_r(x,p,n) realloc(p,n)
1.54 +#define _free_r(x,p) free(p)
1.55 +
1.56 +IMPORT_C char* _dtoa_r (struct _reent *, double, int, int, int *, int*, char**);
1.57 +IMPORT_C void _mstats_r (struct _reent *, char *);
1.58 +IMPORT_C int _system_r (struct _reent *, const char *);
1.59 +IMPORT_C int _wsystem_r (struct _reent *, const wchar_t *);
1.60 +IMPORT_C int _rand_r (struct _reent *);
1.61 +IMPORT_C void _srand_r (struct _reent *, unsigned);
1.62 +IMPORT_C int _setenv_r (struct _reent *, const char *, const char *, int);
1.63 +IMPORT_C void _unsetenv_r (struct _reent *, const char *);
1.64 +IMPORT_C char* _getenv_r (struct _reent *, const char *);
1.65 +IMPORT_C int _wsetenv_r (struct _reent *, const wchar_t *, const wchar_t *, int);
1.66 +IMPORT_C void _wunsetenv_r (struct _reent *, const wchar_t *);
1.67 +IMPORT_C wchar_t* _wgetenv_r (struct _reent *, const wchar_t *);
1.68 +IMPORT_C unsigned long _strtoul_r(struct _reent *,const char *, char **, int);
1.69 +
1.70 +/**
1.71 +It's possible to override exit() by supplying abort(), exit() and _exit()
1.72 +The generic exit() and abort() routines look like
1.73 +
1.74 +void exit(int code) _ATTRIBUTE((noreturn))
1.75 +{
1.76 + _atexit_processing_r(_REENT);
1.77 + _exit(code);
1.78 +}
1.79 +void abort(void) _ATTRIBUTE((noreturn))
1.80 +{
1.81 + _exit(1);
1.82 +}
1.83 +
1.84 +which then allows your _exit() to capture all exits from ESTLIB,
1.85 +except for __assert() which calls abort().
1.86 +*/
1.87 +IMPORT_C void _atexit_processing_r (struct _reent *);
1.88 +
1.89 +#ifdef __cplusplus
1.90 +}
1.91 +#endif
1.92 +#endif /* _STDLIB_R_H_ */