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