Skip to content

Commit

Permalink
Merge pull request ghaerr#2120 from ghaerr/c86
Browse files Browse the repository at this point in the history
[c86] Allow C86 to compile using most all ELKS libc header files
  • Loading branch information
ghaerr authored Nov 29, 2024
2 parents 0fbe1d2 + b85f6a2 commit 2fe82a8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
14 changes: 14 additions & 0 deletions elks/include/arch/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,19 @@
#define __wcnear __near
#endif

#ifdef __C86__
#define __HAS_NO_FLOATS__
#define __far
#define noreturn
#define stdcall
#define restrict
#define printfesque(n)
#define noinstrument
#define CONSTRUCTOR(fn,pri) void fn(void)
#define DESTRUCTOR(fn,pri) void fn(void)
#define __attribute__(n)
#define __wcfar
#define __wcnear
#endif

#endif
6 changes: 3 additions & 3 deletions elks/include/linuxmt/errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */ //linenoise
#define ETXTBSY 26 /* Text file busy */ //ash
#define ENOTTY 25 /* Not a typewriter */ /*linenoise*/
#define ETXTBSY 26 /* Text file busy */ /*ash*/
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
Expand All @@ -61,7 +61,7 @@
#define EADDRINUSE 98 /* Address already in use */
#define ENETDOWN 100 /* Network is down */
#define ENETUNREACH 101 /* Network is unreachable */
#define ENOBUFS 105 /* No buffer space available */ //regex
#define ENOBUFS 105 /* No buffer space available */ /*regex*/
#define EISCONN 106 /* Transport endpoint is already connected */
#define ETIMEDOUT 110 /* Connection timed out */
#define ECONNREFUSED 111 /* Connection refused */
Expand Down
3 changes: 2 additions & 1 deletion elks/include/linuxmt/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ typedef stdcall __far void (*__kern_sighandler_t)(int);
#pragma GCC diagnostic pop
#endif

#ifdef __WATCOMC__
#if defined(__WATCOMC__) || defined(__C86__)
/* FIXME broken for C86 w/o stdcall and __far */
typedef void stdcall (__far *__kern_sighandler_t)(int);
#endif

Expand Down
13 changes: 3 additions & 10 deletions elks/tools/bin/ecc
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ add_path "$TOPDIR/elks/tools/bin"
# C86
add_path "$C86DIR/host-bin"

INCLUDES="-I$TOPDIR/libc/include -I$TOPDIR/elks/include"
DEFINES="-D__C86__ -Drestrict="
INCLUDES="-I$TOPDIR/libc/include -I$TOPDIR/elks/include -I$C86DIR/libc/include"
DEFINES="-D__C86__ -D__STDC__"
C86FLAGS="-O -warn=4 -lang=c99 -align=yes -stackopt=minimum -peep=all -stackcheck=no"
CPPFLAGS="$INCLUDES $DEFINES"
CFLAGS="$C86FLAGS"
ASFLAGS="-f as86"
ARFLAGS="q"
LDFLAGS="-0 -i"
LDFLAGS="-0 -i -L$C86DIR/libc"

# preprocessor
echo cpp86 $CPPFLAGS $1.c $1.i
Expand All @@ -68,13 +68,6 @@ echo nasm $ASFLAGS -l $1.lst -o $1.o $1.asm
nasm $ASFLAGS -l $1.lst -o $1.o $1.asm
objdump86 -s $1.o

# create libc86.a
nasm $ASFLAGS lib/c86lib.asm -o c86lib.o
nasm $ASFLAGS lib/syscall.asm -o syscall.o
rm -f libc86.a
echo ar86 $ARFLAGS libc86.a c86lib.o syscall.o
ar86 $ARFLAGS libc86.a c86lib.o syscall.o

# link executable
echo ld86 $LDFLAGS $1.o -o $1 -lc86
ld86 $LDFLAGS $1.o -o $1 -lc86
Expand Down

0 comments on commit 2fe82a8

Please sign in to comment.