epoc32/include/libc/stdlib_r.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * 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
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 * Extension of <stdlib.h> with reentrant functions.
    16 * 
    17 *
    18 */
    19 
    20 
    21 
    22 
    23 
    24 
    25 
    26 /**
    27  @file
    28  @publishedAll
    29  @released
    30 */
    31 
    32 
    33 #ifndef _STDLIB_R_H_
    34 #define _STDLIB_R_H_
    35 
    36 #ifdef __cplusplus
    37 extern "C" {
    38 #endif
    39 
    40 #include <stdlib.h>
    41 #include <sys/reent.h>
    42 
    43 /**
    44 EPOC32 malloc uses the thread heap, so it is already thread-safe
    45 and no _malloc_r variants are needed.
    46 */
    47 #define _malloc_r(x,n)		malloc(n)
    48 #define _calloc_r(x,n,m)	calloc(n,m)
    49 #define _realloc_r(x,p,n)	realloc(p,n)
    50 #define _free_r(x,p)		free(p)
    51 
    52 IMPORT_C char*	_dtoa_r		(struct _reent *, double, int, int, int *, int*, char**);
    53 IMPORT_C void	_mstats_r	(struct _reent *, char *);
    54 IMPORT_C int	_system_r	(struct _reent *, const char *);
    55 IMPORT_C int	_wsystem_r	(struct _reent *, const wchar_t *);
    56 IMPORT_C int	_rand_r		(struct _reent *);
    57 IMPORT_C void	_srand_r	(struct _reent *, unsigned);
    58 IMPORT_C int	_setenv_r	(struct _reent *, const char *, const char *, int);
    59 IMPORT_C void	_unsetenv_r	(struct _reent *, const char *);
    60 IMPORT_C char*	_getenv_r	(struct _reent *, const char *);
    61 IMPORT_C int	_wsetenv_r	(struct _reent *, const wchar_t *, const wchar_t *, int);
    62 IMPORT_C void	_wunsetenv_r	(struct _reent *, const wchar_t *);
    63 IMPORT_C wchar_t*	_wgetenv_r	(struct _reent *, const wchar_t *);
    64 IMPORT_C unsigned long _strtoul_r(struct _reent *,const char *, char **, int);
    65 
    66 /**
    67 It's possible to override exit() by supplying abort(), exit() and _exit()
    68 The generic exit() and abort() routines look like
    69 
    70 void exit(int code) _ATTRIBUTE((noreturn))
    71 {
    72 	_atexit_processing_r(_REENT);
    73  	_exit(code);
    74 }
    75 void abort(void) _ATTRIBUTE((noreturn))
    76 {
    77 	_exit(1);
    78 }
    79 
    80 which then allows your _exit() to capture all exits from ESTLIB, 
    81 except for __assert() which calls abort().
    82 */
    83 IMPORT_C void _atexit_processing_r (struct _reent *);
    84 
    85 #ifdef __cplusplus
    86 }
    87 #endif
    88 #endif /* _STDLIB_R_H_ */