Skip to content

Commit

Permalink
Merge pull request #2142 from ghaerr/toolchain
Browse files Browse the repository at this point in the history
[libc] Minor updates for 8086 toolchain commit
  • Loading branch information
ghaerr authored Dec 18, 2024
2 parents 880b914 + 741cc42 commit 3bb5ef9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions elks/tools/objtools/ecc
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions libc/include/malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
6 changes: 2 additions & 4 deletions libc/malloc/amalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3bb5ef9

Please sign in to comment.