PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
papi_memory.h
Go to the documentation of this file.
1 #ifndef _PAPI_MALLOC
2 #define _PAPI_MALLOC
3 
4 #include <stdlib.h>
5 
6 #define DEBUG_FILE_LEN 20
7 
8 typedef struct pmem
9 {
10  void *ptr;
11  int size;
12 #ifdef DEBUG
13  char file[DEBUG_FILE_LEN];
14  int line;
15 #endif
16  struct pmem *next;
17  struct pmem *prev;
18 } pmem_t;
19 
20 #ifndef IN_MEM_FILE
21 #ifdef PAPI_NO_MEMORY_MANAGEMENT
22 #define papi_malloc(a) malloc(a)
23 #define papi_free(a) free(a)
24 #define papi_realloc(a,b) realloc(a,b)
25 #define papi_calloc(a,b) calloc(a,b)
26 #define papi_valid_free(a) 1
27 #define papi_strdup(a) strdup(a)
28 #define papi_mem_cleanup_all() ;
29 #define papi_mem_print_info(a) ;
30 #define papi_mem_print_stats() ;
31 #define papi_mem_overhead(a) ;
32 #define papi_mem_check_all_overflow() ;
33 #else
34 #define papi_malloc(a) _papi_malloc(__FILE__,__LINE__, a)
35 #define papi_free(a) _papi_free(__FILE__,__LINE__, a)
36 #define papi_realloc(a,b) _papi_realloc(__FILE__,__LINE__,a,b)
37 #define papi_calloc(a,b) _papi_calloc(__FILE__,__LINE__,a,b)
38 #define papi_valid_free(a) _papi_valid_free(__FILE__,__LINE__,a)
39 #define papi_strdup(a) _papi_strdup(__FILE__,__LINE__,a)
40 #define papi_mem_cleanup_all _papi_mem_cleanup_all
41 #define papi_mem_print_info(a) _papi_mem_print_info(a)
42 #define papi_mem_print_stats _papi_mem_print_stats
43 #define papi_mem_overhead(a) _papi_mem_overhead(a)
44 #define papi_mem_check_all_overflow _papi_mem_check_all_overflow
45 #endif
46 #endif
47 
48 void *_papi_malloc( char *, int, size_t );
49 void _papi_free( char *, int, void * );
50 void *_papi_realloc( char *, int, void *, size_t );
51 void *_papi_calloc( char *, int, size_t, size_t );
52 int _papi_valid_free( char *, int, void * );
53 char *_papi_strdup( char *, int, const char *s );
54 void _papi_mem_cleanup_all( );
55 void _papi_mem_print_info( void *ptr );
56 void _papi_mem_print_stats( );
57 int _papi_mem_overhead( int );
59 
60 #define PAPI_MEM_LIB_OVERHEAD 1 /* PAPI Library Overhead */
61 #define PAPI_MEM_OVERHEAD 2 /* Memory Overhead */
62 #endif
int line
Definition: papi_memory.h:14
void _papi_free(char *file, int line, void *ptr)
Definition: papi_memory.c:226
#define DEBUG_FILE_LEN
Definition: papi_memory.h:6
struct pmem * next
Definition: papi_memory.h:16
int size
Definition: papi_memory.h:11
void * _papi_realloc(char *file, int line, void *ptr, size_t size)
Definition: papi_memory.c:77
int _papi_mem_overhead(int type)
Definition: papi_memory.c:280
void _papi_mem_cleanup_all()
Definition: papi_memory.c:303
void * _papi_calloc(char *file, int line, size_t nmemb, size_t size)
Definition: papi_memory.c:113
s
Definition: iozone.c:20289
void * _papi_malloc(char *file, int line, size_t size)
Definition: papi_memory.c:124
void _papi_mem_print_stats()
Definition: papi_memory.c:262
void _papi_mem_print_info(void *ptr)
Definition: papi_memory.c:247
void * ptr
Definition: papi_memory.h:10
struct pmem * prev
Definition: papi_memory.h:17
int _papi_mem_check_all_overflow()
Definition: papi_memory.c:470
char * _papi_strdup(char *file, int line, const char *s)
Definition: papi_memory.c:169
int _papi_valid_free(char *file, int line, void *ptr)
Definition: papi_memory.c:191
char * ptr
Definition: iozone.c:23586