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