aboutsummaryrefslogtreecommitdiffstats
path: root/dos
diff options
context:
space:
mode:
authorhpa <hpa>2004-12-18 22:56:01 +0000
committerhpa <hpa>2004-12-18 22:56:01 +0000
commitc854c3a8224da9dfa30d583edef6bc1b92b17aeb (patch)
treed67234518bef4e3a0d4b5913eaf124b9d3b3197f /dos
parent5e9b05475246cd32b5c6d4a79b3f1817b92b7bce (diff)
downloadsyslinux-devel-c854c3a8224da9dfa30d583edef6bc1b92b17aeb.tar.gz
syslinux-devel-c854c3a8224da9dfa30d583edef6bc1b92b17aeb.tar.xz
syslinux-devel-c854c3a8224da9dfa30d583edef6bc1b92b17aeb.zip
Fix handling of alignment issues
Diffstat (limited to 'dos')
-rw-r--r--dos/malloc.c6
-rw-r--r--dos/malloc.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/dos/malloc.c b/dos/malloc.c
index 8d37b5d3..499d551a 100644
--- a/dos/malloc.c
+++ b/dos/malloc.c
@@ -24,8 +24,8 @@ const size_t __stack_size = 4096;
static inline size_t sp(void)
{
- uint16_t sp;
- asm volatile("movw %%sp,%0" : "=rm" (sp));
+ uint32_t sp;
+ asm volatile("movl %%esp,%0" : "=rm" (sp));
return sp;
}
@@ -99,7 +99,7 @@ void *malloc(size_t size)
return NULL;
/* Add the obligatory arena header, and round up */
- size = (size+2*sizeof(struct arena_header)-1) & ARENA_SIZE_MASK;
+ size = (size+2*sizeof(struct arena_header)-1) & ~ARENA_SIZE_MASK;
for ( fp = __malloc_head.next_free ; fp->a.type != ARENA_TYPE_HEAD ;
fp = fp->next_free ) {
diff --git a/dos/malloc.h b/dos/malloc.h
index 57b76526..70d0e635 100644
--- a/dos/malloc.h
+++ b/dos/malloc.h
@@ -37,10 +37,10 @@ struct arena_header {
#define ARENA_TYPE_HEAD 2
#endif
-#define ARENA_SIZE_MASK (~(sizeof(struct arena_header)-1))
+#define ARENA_SIZE_MASK (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))
+#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