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 __P void *sm_alloc (size_t s) { return __sm_alloc (s); }
00014
00015 void * __sm_calloc (size_t n, size_t s);
00016 __P void *sm_calloc (size_t n, size_t s) { return __sm_calloc (n, s); }
00017
00018 void * __sm_realloc (void *p, size_t s);
00019 __P void *sm_realloc (void *p, size_t s) { return __sm_realloc (p, s); }
00020
00021 void * __sm_reallocf (void *p, size_t s);
00022 __P void *sm_reallocf (void *p, size_t s) { return __sm_reallocf (p, s); }
00023
00024 int __sm_memalign (void **p, size_t a, size_t s);
00025 __P int __sm_memalign (void **p, size_t a, size_t s) { return __sm_memalign (p, a, s); }
00026
00027 void __sm_free (void *p);
00028 __P void sm_free (void *p) { __sm_free (p); }
00029
00030 # define sm_alloc(s) __sm_alloc (s)
00031 # define sm_calloc(n, s) __sm_calloc (n, s);
00032 # define sm_realloc(p, s) __sm_realloc ((void *)(p), s)
00033 # define sm_reallocf(p, s) __sm_reallocf((void *)(p), s)
00034 # define sm_memalign(p, a, s) __sm_memalign (p, a, s)
00035 # define sm_free(p) __sm_free ((void *)(p))
00036 #else
00037 void * __sm_alloc_dbg (size_t s, const char *f, size_t l);
00038 __P void *sm_alloc (size_t s) { return __sm_alloc_dbg (s, __FUNCTION__, 0); }
00039
00040 void * __sm_calloc_dbg (size_t n, size_t s, const char *f, size_t l);
00041 __P void *sm_calloc (size_t n, size_t s) { return __sm_calloc_dbg (n, s, __FUNCTION__, 0); }
00042
00043 void * __sm_realloc_dbg (void *p, size_t s, const char *f, size_t l);
00044 __P void *sm_realloc (void *p, size_t s) { return __sm_realloc_dbg (p, s, __FUNCTION__, 0); }
00045
00046 void * __sm_reallocf_dbg (void *p, size_t s, const char *f, size_t l);
00047 __P void *sm_reallocf (void *p, size_t s) { return __sm_reallocf_dbg (p, s, __FUNCTION__, 0); }
00048
00049 int __sm_memalign_dbg (void **p, size_t a, size_t s, const char *f, size_t l);
00050 __P int __sm_memalign (void **p, size_t a, size_t s) { return __sm_memalign_dbg (p, a, s, __FUNCTION__, 0); }
00051
00052 void __sm_free_dbg (void **p, const char *f, size_t l);
00053 __P void sm_free (void *p) { __sm_free_dbg (&p, __FUNCTION__, 0); }
00054
00055 # define sm_alloc(s) __sm_alloc_dbg (s, __PRETTY_FUNCTION__, __LINE__)
00056 # define sm_calloc(n, s) __sm_calloc_dbg (n, s, __PRETTY_FUNCTION__, __LINE__)
00057 # define sm_realloc(p, s) __sm_realloc_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00058 # define sm_reallocf(p, s) __sm_reallocf_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00059 # define sm_memalign(p, a, s) __sm_memalign_dbg (p, a, s, __PRETTY_FUNCTION__, __LINE__)
00060 # define sm_free(p) __sm_free_dbg ((void **)((void *)&(p)), __PRETTY_FUNCTION__, __LINE__)
00061 #endif
00062
00063 #define sm_talloc(T) ((T *) sm_alloc(sizeof(T)))
00064 #define sm_valloc(v) ((typeof(v) *) sm_alloc(sizeof v))
00065
00066 #include <assert.h>
00067 #ifndef _A
00068 # define _A(x) assert(x)
00069 #endif
00070 #endif
00071 #endif