00001 #ifndef __STUB_PROBE
00002 #pragma once
00003 #ifndef SM_ALLOC_H
00004 #define SM_ALLOC_H
00005
00006 #include <seap-debug.h>
00007
00008 #undef __P
00009 #define __P __attribute__ ((unused)) static
00010
00011 #if defined(NDEBUG)
00012 void *sm_alloc (size_t s);
00013 void *sm_calloc (size_t n, size_t s);
00014 void *sm_realloc (void *p, size_t s);
00015 void *sm_reallocf (void *p, size_t s);
00016 int sm_memalign (void **p, size_t a, size_t s);
00017 void sm_free (void *p);
00018 #else
00019 void * __sm_alloc_dbg (size_t s, const char *f, size_t l);
00020 __P void *sm_alloc (size_t s) { return __sm_alloc_dbg (s, __FUNCTION__, 0); }
00021
00022 void * __sm_calloc_dbg (size_t n, size_t s, const char *f, size_t l);
00023 __P void *sm_calloc (size_t n, size_t s) { return __sm_calloc_dbg (n, s, __FUNCTION__, 0); }
00024
00025 void * __sm_realloc_dbg (void *p, size_t s, const char *f, size_t l);
00026 __P void *sm_realloc (void *p, size_t s) { return __sm_realloc_dbg (p, s, __FUNCTION__, 0); }
00027
00028 void * __sm_reallocf_dbg (void *p, size_t s, const char *f, size_t l);
00029 __P void *sm_reallocf (void *p, size_t s) { return __sm_reallocf_dbg (p, s, __FUNCTION__, 0); }
00030
00031 int __sm_memalign_dbg (void **p, size_t a, size_t s, const char *f, size_t l);
00032 __P int __sm_memalign (void **p, size_t a, size_t s) { return __sm_memalign_dbg (p, a, s, __FUNCTION__, 0); }
00033
00034 void __sm_free_dbg (void *p, const char *f, size_t l);
00035 __P void sm_free (void *p) { __sm_free_dbg (p, __FUNCTION__, 0); }
00036
00037 # define sm_alloc(s) __sm_alloc_dbg (s, __PRETTY_FUNCTION__, __LINE__)
00038 # define sm_calloc(n, s) __sm_calloc_dbg (n, s, __PRETTY_FUNCTION__, __LINE__)
00039 # define sm_realloc(p, s) __sm_realloc_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00040 # define sm_reallocf(p, s) __sm_reallocf_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00041 # define sm_memalign(p, a, s) __sm_memalign_dbg (p, a, s, __PRETTY_FUNCTION__, __LINE__)
00042 # define sm_free(p) __sm_free_dbg ((void *)(p), __PRETTY_FUNCTION__, __LINE__)
00043 #endif
00044
00045 #define sm_talloc(T) ((T *) sm_alloc(sizeof(T)))
00046 #define sm_valloc(v) ((typeof(v) *) sm_alloc(sizeof v))
00047
00048 #include <assert.h>
00049 #ifndef _A
00050 # define _A(x) assert(x)
00051 #endif
00052 #endif
00053 #endif