From 741cc42271630470662c8ceab37201623a51937d Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Tue, 17 Dec 2024 18:29:32 -0700 Subject: [PATCH] [libc] Minor updates for 8086 toolchain commit --- elks/tools/objtools/ecc | 6 +++--- libc/include/malloc.h | 6 ++++-- libc/malloc/amalloc.c | 6 ++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/elks/tools/objtools/ecc b/elks/tools/objtools/ecc index 3dd318e39..ef11e581f 100755 --- a/elks/tools/objtools/ecc +++ b/elks/tools/objtools/ecc @@ -1,6 +1,6 @@ # ecc - ELKS cc compiler wrapper for C86 (8086-toolchain) # -# This script runs cpp86, c86, nasm and ld86 on the input file. +# This script runs cpp86, c86, nasm86 and ld86 on the input file. # The input file must be specified without its .c extension for now, # and the script must be run in the 8086-toolchain/ directory, # as it also builds the libc86.a C86 library. @@ -91,8 +91,8 @@ echo c86 $CFLAGS $1.c $1.asm c86 $CFLAGS $1.i $1.asm # assembler -echo nasm $ASFLAGS -l $1.lst -o $1.o $1.asm -nasm $ASFLAGS -l $1.lst -o $1.o $1.asm +echo nasm86 $ASFLAGS -l $1.lst -o $1.o $1.asm +nasm86 $ASFLAGS -l $1.lst -o $1.o $1.asm objdump86 -s $1.o # link executable diff --git a/libc/include/malloc.h b/libc/include/malloc.h index 2c98a3499..1c3a0f755 100644 --- a/libc/include/malloc.h +++ b/libc/include/malloc.h @@ -21,6 +21,8 @@ int __amalloc_add_heap(char __far *start, size_t size); void *__arealloc(void *, size_t); /* not implemented */ void __afree(void *); size_t __amalloc_usable_size(void *); +extern unsigned int malloc_arena_size; +extern unsigned int malloc_arena_thresh; /* usable with all mallocs */ void *calloc(size_t elm, size_t sz); @@ -32,7 +34,7 @@ int fmemfree(void __far *ptr); int _fmemalloc(int paras, unsigned short *pseg); /* syscall */ int _fmemfree(unsigned short seg); /* syscall */ -extern unsigned int malloc_arena_size; -extern unsigned int malloc_arena_thresh; +/* debug output */ +int __dprintf(const char *fmt, ...); #endif diff --git a/libc/malloc/amalloc.c b/libc/malloc/amalloc.c index e10a358dc..201008f3a 100644 --- a/libc/malloc/amalloc.c +++ b/libc/malloc/amalloc.c @@ -92,9 +92,7 @@ static int debug_level = DEBUG; /* add size bytes to arena malloc heap, must be done before first malloc */ int __amalloc_add_heap(char __far *start, size_t size) { - if (size < 16) - return 0; - + ASSERT(start != NULL && size >= 16); allocs = (FPTR)start; allocseg = FP_SEG(start); allocsize = size / sizeof(union store); @@ -254,7 +252,7 @@ size_t __amalloc_usable_size(void *ptr) { NPTR p = (NPTR)ptr; - if (p == NULL) /* NOTE this allows fmemalloc pointers to return 0 here */ + if (ptr == NULL) return 0; ASSERT(FP_SEG(ptr)==allocseg); ASSERT(p>clearbusy(allocs[allocsize-1].ptr)&&p<=alloct);