sl@0: /* sl@0: * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Extension of with reentrant functions. sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef _STDLIB_R_H_ sl@0: #define _STDLIB_R_H_ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: EPOC32 malloc uses the thread heap, so it is already thread-safe sl@0: and no _malloc_r variants are needed. sl@0: */ sl@0: #define _malloc_r(x,n) malloc(n) sl@0: #define _calloc_r(x,n,m) calloc(n,m) sl@0: #define _realloc_r(x,p,n) realloc(p,n) sl@0: #define _free_r(x,p) free(p) sl@0: sl@0: IMPORT_C char* _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); sl@0: IMPORT_C void _mstats_r (struct _reent *, char *); sl@0: IMPORT_C int _system_r (struct _reent *, const char *); sl@0: IMPORT_C int _wsystem_r (struct _reent *, const wchar_t *); sl@0: IMPORT_C int _rand_r (struct _reent *); sl@0: IMPORT_C void _srand_r (struct _reent *, unsigned); sl@0: IMPORT_C int _setenv_r (struct _reent *, const char *, const char *, int); sl@0: IMPORT_C void _unsetenv_r (struct _reent *, const char *); sl@0: IMPORT_C char* _getenv_r (struct _reent *, const char *); sl@0: IMPORT_C int _wsetenv_r (struct _reent *, const wchar_t *, const wchar_t *, int); sl@0: IMPORT_C void _wunsetenv_r (struct _reent *, const wchar_t *); sl@0: IMPORT_C wchar_t* _wgetenv_r (struct _reent *, const wchar_t *); sl@0: IMPORT_C unsigned long _strtoul_r(struct _reent *,const char *, char **, int); sl@0: sl@0: /** sl@0: It's possible to override exit() by supplying abort(), exit() and _exit() sl@0: The generic exit() and abort() routines look like sl@0: sl@0: void exit(int code) _ATTRIBUTE((noreturn)) sl@0: { sl@0: _atexit_processing_r(_REENT); sl@0: _exit(code); sl@0: } sl@0: void abort(void) _ATTRIBUTE((noreturn)) sl@0: { sl@0: _exit(1); sl@0: } sl@0: sl@0: which then allows your _exit() to capture all exits from ESTLIB, sl@0: except for __assert() which calls abort(). sl@0: */ sl@0: IMPORT_C void _atexit_processing_r (struct _reent *); sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: #endif /* _STDLIB_R_H_ */