about summary refs log tree commit diff stats
path: root/src/include/debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/debug.h')
-rw-r--r--src/include/debug.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/include/debug.h b/src/include/debug.h
index a17e76a4..9fb183b4 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -177,4 +177,30 @@ extern char* box_strdup(const char* s);
 extern char* box_realpath(const char* path, char* ret);
 #endif
 
+//use actual_XXXX for internal memory that should be in 32bits space when box32 is active
+//use box_XXX for internal memory that doesn't need anything special
+#ifdef BOX32
+int isCustomAddr(void* p);
+void* box32_calloc(size_t n, size_t s);
+void* box32_malloc(size_t s);
+void* box32_realloc(void* p, size_t s);
+void box32_free(void* p);
+void* box32_memalign(size_t align, size_t s);
+size_t box32_malloc_usable_size(void* p);
+
+#define actual_calloc(A, B)             (box64_is32bits?box32_calloc(A, B):box_calloc(A, B))
+#define actual_malloc(A)                (box64_is32bits?box32_malloc(A):box_malloc(A))
+#define actual_realloc(A, B)            (box64_is32bits?box32_realloc(A, B):box_realloc(A, B))
+#define actual_free(A)                  (box64_is32bits?box32_free(A):box_free(A))
+#define actual_memalign(A, B)           (box64_is32bits?box32_memalign(A, B):box_memalign(A, B))
+#define actual_malloc_usable_size(A)    (box64_is32bits?box32_malloc_usable_size(A):box_malloc_usable_size(A))
+#else
+#define actual_calloc(A, B)             box_calloc(A, B)
+#define actual_malloc(A)                box_malloc(A)
+#define actual_realloc(A, B)            box_realloc(A, B)
+#define actual_free(A)                  box_free(A)
+#define actual_memalign(A, B)           box_memalign(A, B)
+#define actual_malloc_usable_size(A)    box_malloc_usable_size(A)
+#endif
+
 #endif //__DEBUG_H_