From 8261f21ea9676bccccf9d03dd0ad72d841bd1ec3 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 27 Feb 2019 19:52:24 -0500 Subject: make final call in infinite loop so _Noreturn holds true --- src/stdlib/_Exit.c | 6 ++++-- src/stdlib/abort.c | 5 +++-- src/stdlib/exit.c | 6 ++++-- src/unistd/_exit.c | 6 ++++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/stdlib/_Exit.c b/src/stdlib/_Exit.c index a90d4a24..e1f9d192 100644 --- a/src/stdlib/_Exit.c +++ b/src/stdlib/_Exit.c @@ -4,8 +4,10 @@ /** cause normal program termination without handlers **/ _Noreturn void _Exit(int status) { - __syscall("_exit", status); - for (;;); + long scno = ((syscall_lookup_t)__libc(SYSCALL_LOOKUP))("exit"); + for (;;) { + __syscall(scno, status); + } } /*** diff --git a/src/stdlib/abort.c b/src/stdlib/abort.c index d079bdf1..4c5fd8a4 100644 --- a/src/stdlib/abort.c +++ b/src/stdlib/abort.c @@ -8,8 +8,9 @@ _Noreturn void abort(void) { - raise(SIGABRT); - for(;;); /* silence gcc warning about returning */ + for (;;) { + raise(SIGABRT); + } } /*** diff --git a/src/stdlib/exit.c b/src/stdlib/exit.c index 8207fd81..f7ce5325 100644 --- a/src/stdlib/exit.c +++ b/src/stdlib/exit.c @@ -7,6 +7,7 @@ /** cause normal program termination **/ _Noreturn void exit(int status) { + long scno = ((syscall_lookup_t)__libc(SYSCALL_LOOKUP))("exit"); struct atexit *ae = __libc(ATEXIT); /* execute all atexit() registered functions in reverse order */ @@ -26,8 +27,9 @@ _Noreturn void exit(int status) */ (void)status; - __syscall(((long (*)(char*))__libc(SYSCALL_LOOKUP))("exit"), status); - for (;;); /* quiet _Noreturn functions returns warning */ + for (;;) { + __syscall(scno, status); + } } /*** diff --git a/src/unistd/_exit.c b/src/unistd/_exit.c index 4f1ef7e6..618b839c 100644 --- a/src/unistd/_exit.c +++ b/src/unistd/_exit.c @@ -5,8 +5,10 @@ void _exit(int status) { - __syscall(((syscall_lookup_t)__libc(SYSCALL_LOOKUP))("exit"), status); - for (;;); + long scno = ((syscall_lookup_t)__libc(SYSCALL_LOOKUP))("exit"); + for (;;) { + __syscall(scno, status); + } } /* POSIX(1) -- cgit v1.2.1