aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-06-28 15:14:37 +0800
committerFeng Tang <feng.tang@intel.com>2010-07-20 11:10:04 +0800
commit387d33fbfcdbe2d039ba719d487359b205181873 (patch)
tree51a6cca06e34eb1a2904c4650ce330aabcf6294e
parent7badd550c3823c6772f36ecaeade2b57538b6e46 (diff)
downloadsyslinux-387d33fbfcdbe2d039ba719d487359b205181873.tar.gz
syslinux-387d33fbfcdbe2d039ba719d487359b205181873.tar.xz
syslinux-387d33fbfcdbe2d039ba719d487359b205181873.zip
elflink: malloc cleanup
* remove com32/lib/malloc.h * remove com32/elflink/test_memalign.c
-rw-r--r--com32/elflink/Makefile3
-rw-r--r--com32/elflink/test_memalign.c48
-rw-r--r--com32/lib/malloc.h55
-rw-r--r--com32/lib/sys/module/elfutils.c4
-rw-r--r--core/hello.c9
-rw-r--r--core/mem/malloc.c20
6 files changed, 3 insertions, 136 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
diff --git a/core/hello.c b/core/hello.c
index 0f1a3a49..45bdf57c 100644
--- a/core/hello.c
+++ b/core/hello.c
@@ -48,15 +48,6 @@ void hexdump(void *buf, int bytelen, const char *str)
printf("\n\n");
}
-/*
-void mydump(void)
-{
- printf("append buf at %x\n", AppendBuf);
-
- hexdump(AppendBuf, 60, "appendbuf");
-}
-*/
-
static inline void myprint(int num)
{
uint32_t i;
diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index 6704af2f..d27fc270 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -212,23 +212,3 @@ void *zalloc(size_t size)
return ptr;
}
-
-/* need to revisit this later */
-int posix_memalign(void **memptr, size_t align, size_t size)
-{
- void *ptr;
- unsigned long tmp;
-
- ptr = malloc(size + align - 1);
- if (!ptr)
- return -ENOMEM;
-
- /* do the alignment */
- tmp = (unsigned long)ptr;
- tmp = (tmp + align -1) & ~(align - 1);
- ptr = (void *)tmp;
-
- *memptr = ptr;
- return 0;
-
-}