From 2395c7a871339827be7b21b00940df5e90974cb5 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 15 Oct 2022 14:02:10 +0200 Subject: [PATCH] libc: Implement _Exit Exactly the same as _exit, but in stdlib.h instead of unistd.h --- libs/libc/include/stdlib.h | 3 +++ libs/libc/src/stdlib.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/libc/include/stdlib.h b/libs/libc/include/stdlib.h index 16e4053c..99de9f34 100644 --- a/libs/libc/include/stdlib.h +++ b/libs/libc/include/stdlib.h @@ -15,6 +15,9 @@ extern "C" /* Normally exits the program with the specified status code. */ __lc_noreturn void exit(int status); + /* Abnormally exits the program with the specified status code. */ + __lc_noreturn void _Exit(int status); + /* Registers a handler function to be run at normal program termination. */ int atexit(void (*handler)(void)); diff --git a/libs/libc/src/stdlib.cpp b/libs/libc/src/stdlib.cpp index eb5261f7..cd872434 100644 --- a/libs/libc/src/stdlib.cpp +++ b/libs/libc/src/stdlib.cpp @@ -7,7 +7,7 @@ extern "C" { __lc_noreturn void abort() { - _exit(-1); + _Exit(-1); } int atoi(const char*) @@ -19,4 +19,10 @@ extern "C" { NOT_IMPLEMENTED("getenv"); } + + __lc_noreturn void _Exit(int status) + { + syscall(SYS_exit, status); + __lc_unreachable(); + } } \ No newline at end of file