From 9595704c19d3ffd0b876d988a062da32dd5fb5fc Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 6 Aug 2020 09:31:05 +0200 Subject: removed playing with noreturn attribute --- ecomp-c/asm-i386.c | 5 +++-- ecomp-c/build.sh | 2 -- ecomp-c/builtin_unreachable.c | 11 ----------- ecomp-c/ec.c | 2 +- ecomp-c/libc-freestanding.c | 17 ++--------------- 5 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 ecomp-c/builtin_unreachable.c diff --git a/ecomp-c/asm-i386.c b/ecomp-c/asm-i386.c index 9b303c8..61f0ff0 100644 --- a/ecomp-c/asm-i386.c +++ b/ecomp-c/asm-i386.c @@ -146,12 +146,12 @@ static void Err( char *s, va_list args ) fflush( stderr ); } -__attribute__((noreturn)) static void Halt( int code ) +static void Halt( int code ) { exit( code ); } -__attribute__((noreturn)) static void Abort( char *s, ... ) +static void Abort( char *s, ... ) { va_list args; va_start( args, s ); @@ -1197,6 +1197,7 @@ static int evaluateExpression( ExpressionNode *node, int ORG, int LC ) num = left - right; break; default: + num = 0; /* make clang happy */ Abort( "Unknown operation '%s' in expression", symname[node->op] ); } return num; diff --git a/ecomp-c/build.sh b/ecomp-c/build.sh index 1d7551e..e4d41ec 100755 --- a/ecomp-c/build.sh +++ b/ecomp-c/build.sh @@ -62,12 +62,10 @@ case "${COMPILER}:${MODE}" in ;; pcc:freestanding) CFLAGS+=" -ffreestanding -nostdlib -Wl,-emain" - MODULES+=("builtin_unreachable.c") ;; tcc:freestanding) CFLAGS+=" -fno-bultin -nostdlib" MODULES+=("_start-stub.c") - MODULES+=("builtin_unreachable.c") ;; *:hosted) CFLAGS+=" -lbsd" diff --git a/ecomp-c/builtin_unreachable.c b/ecomp-c/builtin_unreachable.c deleted file mode 100644 index 0da44f0..0000000 --- a/ecomp-c/builtin_unreachable.c +++ /dev/null @@ -1,11 +0,0 @@ -/* - * __builtin_unreachable for pcc/tcc marking exit in - * libc-freestanding.c syscall1noret - */ - -/* break in pcc (is eliminated?!), disable gcc compatibility in pcc - * OTOH breaks in "i386/code.c:374:36: error: 'GCC_ATYP_STDCALL' undeclared" - */ -void __builtin_unreachable( void ) -{ -} diff --git a/ecomp-c/ec.c b/ecomp-c/ec.c index 82775e0..bc0944e 100644 --- a/ecomp-c/ec.c +++ b/ecomp-c/ec.c @@ -133,7 +133,7 @@ static void Err( char *s, va_list args ) fflush( stderr ); } -__attribute__((noreturn)) static void Halt( int code ) +static void Halt( int code ) { exit( code ); } diff --git a/ecomp-c/libc-freestanding.c b/ecomp-c/libc-freestanding.c index 35f2e02..f37aa83 100644 --- a/ecomp-c/libc-freestanding.c +++ b/ecomp-c/libc-freestanding.c @@ -138,19 +138,6 @@ static __attribute__((noinline)) int syscall1( int id, int arg0 ) return retval; } -void __builtin_unreachable( void ); - -static __attribute__((noinline)) __attribute__((noreturn)) void syscall1noret( int id, int arg0 ) -{ - __asm__ volatile( "\ - push %%ebx\n\ - mov %0, %%eax\n\ - mov %1, %%ebx\n\ - int $0x80\n\ - pop %%ebx\n" : : "m"( id ), "m"( arg0 ) ); - __builtin_unreachable( ); -} - static __attribute__((noinline)) int syscall3( int id, int arg0, int arg1, int arg2 ) { int retval; @@ -177,9 +164,9 @@ static __attribute__((noinline)) int syscall3( int id, int arg0, int arg1, int a return retval; } -__attribute__((noreturn)) void exit( int status ) +void exit( int status ) { - syscall1noret( SYSCALL_EXIT, status ); + syscall1( SYSCALL_EXIT, status ); } static void strreverse( char *s ) -- cgit v1.2.3-54-g00ecf