PAPI  5.0.1.0
papi_memory.h
Go to the documentation of this file.
00001 #ifndef _PAPI_MALLOC
00002 #define _PAPI_MALLOC
00003 
00004 #include <stdlib.h>
00005 
00006 #define DEBUG_FILE_LEN  20
00007 
00008 typedef struct pmem
00009 {
00010     void *ptr;
00011     int size;
00012 #ifdef DEBUG
00013     char file[DEBUG_FILE_LEN];
00014     int line;
00015 #endif
00016     struct pmem *next;
00017     struct pmem *prev;
00018 } pmem_t;
00019 
00020 #ifndef IN_MEM_FILE
00021 #ifdef PAPI_NO_MEMORY_MANAGEMENT
00022 #define papi_malloc(a) malloc(a)
00023 #define papi_free(a)   free(a)
00024 #define papi_realloc(a,b) realloc(a,b)
00025 #define papi_calloc(a,b) calloc(a,b)
00026 #define papi_valid_free(a) 1
00027 #define papi_strdup(a) strdup(a)
00028 #define papi_mem_cleanup_all() ;
00029 #define papi_mem_print_info(a) ;
00030 #define papi_mem_print_stats() ;
00031 #define papi_mem_overhead(a) ;
00032 #define papi_mem_check_all_overflow() ;
00033 #else
00034 #define papi_malloc(a) _papi_malloc(__FILE__,__LINE__, a)
00035 #define papi_free(a) _papi_free(__FILE__,__LINE__, a)
00036 #define papi_realloc(a,b) _papi_realloc(__FILE__,__LINE__,a,b)
00037 #define papi_calloc(a,b) _papi_calloc(__FILE__,__LINE__,a,b)
00038 #define papi_valid_free(a) _papi_valid_free(__FILE__,__LINE__,a)
00039 #define papi_strdup(a) _papi_strdup(__FILE__,__LINE__,a)
00040 #define papi_mem_cleanup_all _papi_mem_cleanup_all
00041 #define papi_mem_print_info(a) _papi_mem_print_info(a)
00042 #define papi_mem_print_stats _papi_mem_print_stats
00043 #define papi_mem_overhead(a) _papi_mem_overhead(a)
00044 #define papi_mem_check_all_overflow _papi_mem_check_all_overflow
00045 #endif
00046 #endif
00047 
00048 void *_papi_malloc( char *, int, size_t );
00049 void _papi_free( char *, int, void * );
00050 void *_papi_realloc( char *, int, void *, size_t );
00051 void *_papi_calloc( char *, int, size_t, size_t );
00052 int _papi_valid_free( char *, int, void * );
00053 char *_papi_strdup( char *, int, const char *s );
00054 void _papi_mem_cleanup_all(  );
00055 void _papi_mem_print_info( void *ptr );
00056 void _papi_mem_print_stats(  );
00057 int _papi_mem_overhead( int );
00058 int _papi_mem_check_all_overflow(  );
00059 
00060 #define PAPI_MEM_LIB_OVERHEAD   1   /* PAPI Library Overhead */
00061 #define PAPI_MEM_OVERHEAD   2   /* Memory Overhead */
00062 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines