[syslinux:elflink] elflink: malloc cleanup

syslinux-bot for Feng Tang feng.tang at intel.com
Thu Aug 12 21:03:30 PDT 2010


Commit-ID:  387d33fbfcdbe2d039ba719d487359b205181873
Gitweb:     http://syslinux.zytor.com/commit/387d33fbfcdbe2d039ba719d487359b205181873
Author:     Feng Tang <feng.tang at intel.com>
AuthorDate: Mon, 28 Jun 2010 15:14:37 +0800
Committer:  Feng Tang <feng.tang at intel.com>
CommitDate: Tue, 20 Jul 2010 11:10:04 +0800

elflink: malloc cleanup

* remove com32/lib/malloc.h
* remove com32/elflink/test_memalign.c


---
 com32/elflink/Makefile          |    3 +-
 com32/elflink/test_memalign.c   |   48 ----------------------------------
 com32/lib/malloc.h              |   55 ---------------------------------------
 com32/lib/sys/module/elfutils.c |    4 +-
 core/hello.c                    |    9 ------
 core/mem/malloc.c               |   20 --------------
 6 files changed, 3 insertions(+), 136 deletions(-)

diff --git a/com32/elflink/Makefile b/com32/elflink/Makefile
index 9e6cc4a..39266de 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 1bd5ba5..0000000
--- 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 bf75432..0000000
--- 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 0e65317..64be077 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 0f1a3a4..45bdf57 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 6704af2..d27fc27 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;
-
-}



More information about the Syslinux-commits mailing list