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