OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

vt_memhook.h
1 /**
2 * VampirTrace
3 * http://www.tu-dresden.de/zih/vampirtrace
4 *
5 * Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
6 *
7 * Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
8 * Centre, Federal Republic of Germany
9 *
10 * See the file COPYING in the package base directory for details
11 **/
12
13 #ifndef _VT_MEMHOOK_H
14 #define _VT_MEMHOOK_H
15
16 #ifdef __cplusplus
17 # define EXTERN extern "C"
18 #else
19 # define EXTERN extern
20 #endif
21
22 #if (defined(VT_MEMHOOK))
23
24 #include "vt_inttypes.h"
25 #include <stdlib.h>
26 #include <malloc.h>
27
28 #define VT_MEMHOOKS_OFF() \
29 if ( vt_memhook_is_initialized && vt_memhook_is_enabled ) { \
30 __malloc_hook = vt_malloc_hook_org; \
31 __realloc_hook = vt_realloc_hook_org; \
32 __free_hook = vt_free_hook_org; \
33 vt_memhook_is_enabled = 0; }
34 #define VT_MEMHOOKS_ON() \
35 if ( vt_memhook_is_initialized && !vt_memhook_is_enabled ) { \
36 __malloc_hook = vt_malloc_hook; \
37 __realloc_hook = vt_realloc_hook; \
38 __free_hook = vt_free_hook; \
39 vt_memhook_is_enabled = 1; }
40 #define VT_MEMHOOKS_ENABLED() vt_memhook_is_enabled
41
42 /* memory hooks initialization */
43 EXTERN void vt_memhook_init(void);
44
45 /* memory hooks finalization */
46 EXTERN void vt_memhook_finalize(void);
47
48 /* Prototypes for our hooks */
49 EXTERN void* vt_malloc_hook(size_t size, const void* caller);
50 EXTERN void* vt_realloc_hook(void* ptr, size_t size, const void* caller);
51 EXTERN void vt_free_hook(void* ptr, const void* caller);
52
53 /* Variables to save original hooks */
54 EXTERN void* (*vt_malloc_hook_org)(size_t, const void *);
55 EXTERN void* (*vt_realloc_hook_org)(void* ptr, size_t size, const void* caller);
56 EXTERN void (*vt_free_hook_org)(void* ptr, const void* caller);
57
58 EXTERN uint8_t vt_memhook_is_initialized;
59 EXTERN uint8_t vt_memhook_is_enabled;
60
61 #else /* VT_MEMHOOK */
62
63 #define VT_MEMHOOKS_OFF()
64 #define VT_MEMHOOKS_ON()
65 #define VT_MEMHOOKS_ENABLED() 0
66
67 #endif /* VT_MEMHOOK */
68
69 #endif /* _VT_MEMHOOK_H */
70