diff options
author | Feng Tang <feng.tang@intel.com> | 2010-06-28 15:14:37 +0800 |
---|---|---|
committer | Feng Tang <feng.tang@intel.com> | 2010-07-20 11:10:04 +0800 |
commit | 387d33fbfcdbe2d039ba719d487359b205181873 (patch) | |
tree | 51a6cca06e34eb1a2904c4650ce330aabcf6294e /com32 | |
parent | 7badd550c3823c6772f36ecaeade2b57538b6e46 (diff) | |
download | syslinux-387d33fbfcdbe2d039ba719d487359b205181873.tar.gz syslinux-387d33fbfcdbe2d039ba719d487359b205181873.tar.xz syslinux-387d33fbfcdbe2d039ba719d487359b205181873.zip |
elflink: malloc cleanup
* remove com32/lib/malloc.h
* remove com32/elflink/test_memalign.c
Diffstat (limited to 'com32')
-rw-r--r-- | com32/elflink/Makefile | 3 | ||||
-rw-r--r-- | com32/elflink/test_memalign.c | 48 | ||||
-rw-r--r-- | com32/lib/malloc.h | 55 | ||||
-rw-r--r-- | com32/lib/sys/module/elfutils.c | 4 |
4 files changed, 3 insertions, 107 deletions
diff --git a/com32/elflink/Makefile b/com32/elflink/Makefile index 9e6cc4af..39266ded 100644 --- a/com32/elflink/Makefile +++ b/com32/elflink/Makefile @@ -13,8 +13,7 @@ topdir = ../.. include ../MCONFIG -MODULES = test_memalign.c32 # test_com32.c32 - +MODULES = TESTFILES = all: $(MODULES) $(TESTFILES) diff --git a/com32/elflink/test_memalign.c b/com32/elflink/test_memalign.c deleted file mode 100644 index 1bd5ba5d..00000000 --- a/com32/elflink/test_memalign.c +++ /dev/null @@ -1,48 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <console.h> -#include <errno.h> - -void perform_allocation(size_t align) -{ - int res = 0; - int size = 100; - void *ptr; - - printf("Allocation aligned at %#zx bytes: ", align); - res = posix_memalign(&ptr, align, size); - - switch (res) { - case 0: - printf("address %p\n", ptr); - break; - case EINVAL: - printf("EINVAL\n"); - break; - case ENOMEM: - printf("ENOMEM\n"); - break; - } -} - -int main(void) -{ - size_t align = 0x10000; - - // Open a standard r/w console - openconsole(&dev_stdcon_r, &dev_stdcon_w); - - while (align >= sizeof(void *)) { - perform_allocation(align); - align /= 2; - } - - printf("\n"); - - while (align <= 0x10000) { - perform_allocation(align); - align *= 2; - } - - return 0; -} diff --git a/com32/lib/malloc.h b/com32/lib/malloc.h deleted file mode 100644 index bf754326..00000000 --- a/com32/lib/malloc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * malloc.h - * - * Internals for the memory allocator - */ - -#include <stdint.h> -#include <stddef.h> - -/* - * This is the minimum chunk size we will ask the kernel for; this should - * be a multiple of the page size on all architectures. - */ -#define MALLOC_CHUNK_SIZE 65536 -#define MALLOC_CHUNK_MASK (MALLOC_CHUNK_SIZE-1) - -/* - * This structure should be a power of two. This becomes the - * alignment unit. - */ -struct free_arena_header; - -struct arena_header { - size_t type; - size_t size; /* Also gives the location of the next entry */ - struct free_arena_header *next, *prev; -}; - -#ifdef DEBUG_MALLOC -#define ARENA_TYPE_USED 0x64e69c70 -#define ARENA_TYPE_FREE 0x012d610a -#define ARENA_TYPE_HEAD 0x971676b5 -#define ARENA_TYPE_DEAD 0xeeeeeeee -#else -#define ARENA_TYPE_USED 0 -#define ARENA_TYPE_FREE 1 -#define ARENA_TYPE_HEAD 2 -#endif - -#define ARENA_SIZE_MASK (~(uintptr_t)(sizeof(struct arena_header)-1)) - -#define ARENA_ALIGN_UP(p) ((char *)(((uintptr_t)(p) + ~ARENA_SIZE_MASK) & ARENA_SIZE_MASK)) -#define ARENA_ALIGN_DOWN(p) ((char *)((uintptr_t)(p) & ARENA_SIZE_MASK)) - -/* - * This structure should be no more than twice the size of the - * previous structure. - */ -struct free_arena_header { - struct arena_header a; - struct free_arena_header *next_free, *prev_free; -}; - -extern struct free_arena_header __malloc_head; -void __inject_free_block(struct free_arena_header *ah); diff --git a/com32/lib/sys/module/elfutils.c b/com32/lib/sys/module/elfutils.c index 0e653171..64be0770 100644 --- a/com32/lib/sys/module/elfutils.c +++ b/com32/lib/sys/module/elfutils.c @@ -29,7 +29,7 @@ unsigned long elf_gnu_hash(const unsigned char *name) { return h & 0xFFFFFFFF; } -#ifdef ELF_NO_POSIX_MEMALIGN +#ifndef HAVE_ELF_POSIX_MEMALIGN struct memalign_info { void *start_addr; @@ -86,4 +86,4 @@ void elf_free(void *memptr) { free(memptr); } -#endif //ELF_NO_POSIX_MEMALIGN +#endif //HAVE_ELF_POSIX_MEMALIGN |