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