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