diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2015-05-12 18:12:20 +0800 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-05-21 14:37:16 +1000 |
commit | 48a3a132ec5f47951a103ad317d383204fa41d38 (patch) | |
tree | 43e4b87a6dae454c7d368593b792967dd45050e3 /core | |
parent | 1861dc5a68ba3d250bdbaf59f062b3adb309288f (diff) | |
download | blackbird-skiboot-48a3a132ec5f47951a103ad317d383204fa41d38.tar.gz blackbird-skiboot-48a3a132ec5f47951a103ad317d383204fa41d38.zip |
core/test: Use skiboot's own malloc for mem_region tests
Comments in the run-mem_region test imply that it uses skiboot's own
malloc for the malloc implementation, but this isn't true; a malloc
inside the mem_region code itself will use the glibc malloc.
This change implements the intention of the test, and uses skiboot
malloc for the file-under-test. real_malloc() is available for actual
glibc mallocs.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/test/run-mem_region.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/core/test/run-mem_region.c b/core/test/run-mem_region.c index d1cc3dd1..7164f093 100644 --- a/core/test/run-mem_region.c +++ b/core/test/run-mem_region.c @@ -28,33 +28,26 @@ struct cpu_thread { #include <string.h> /* Use these before we override definitions below. */ -static void *__malloc(size_t size, const char *location __attribute__((unused))) +static void *real_malloc(size_t size) { return malloc(size); } -static void *__realloc(void *ptr, size_t size, const char *location __attribute__((unused))) -{ - return realloc(ptr, size); -} - -static inline void __free(void *p, const char *location __attribute__((unused))) +static inline void real_free(void *p) { return free(p); } -static void *__zalloc(size_t size, const char *location __attribute__((unused))) -{ - void *ptr = malloc(size); - memset(ptr, 0, size); - return ptr; -} +#undef malloc +#undef free +#undef realloc #include <skiboot.h> #define is_rodata(p) true #include "../mem_region.c" +#include "../malloc.c" #include "../device.c" #include <assert.h> @@ -96,7 +89,7 @@ int main(void) struct mem_region *r; /* Use malloc for the heap, so valgrind can find issues. */ - test_heap = __malloc(TEST_HEAP_SIZE, __location__); + test_heap = real_malloc(TEST_HEAP_SIZE); skiboot_heap.start = (unsigned long)test_heap; skiboot_heap.len = TEST_HEAP_SIZE; @@ -261,6 +254,6 @@ int main(void) } unlock(&mem_region_lock); assert(skiboot_heap.free_list_lock.lock_val == 0); - __free(test_heap, ""); + real_free(test_heap); return 0; } |