diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt --- a/libc/config/gpu/entrypoints.txt +++ b/libc/config/gpu/entrypoints.txt @@ -59,7 +59,6 @@ libc.src.stdlib.atof libc.src.stdlib.atol libc.src.stdlib.atoll - libc.src.stdlib.atexit libc.src.stdlib.strtod libc.src.stdlib.strtof libc.src.stdlib.strtol @@ -68,6 +67,11 @@ libc.src.stdlib.strtoul libc.src.stdlib.strtoull + # stdlib.h entrypoints + libc.src.stdlib._Exit + libc.src.stdlib.atexit + libc.src.stdlib.exit + # Only implemented in the test suite libc.src.stdlib.malloc libc.src.stdlib.aligned_alloc diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt --- a/libc/src/stdlib/CMakeLists.txt +++ b/libc/src/stdlib/CMakeLists.txt @@ -341,6 +341,7 @@ DEPENDS ._Exit .atexit + libc.src.__support.OSUtil.osutil ) add_entrypoint_object( diff --git a/libc/src/stdlib/exit.cpp b/libc/src/stdlib/exit.cpp --- a/libc/src/stdlib/exit.cpp +++ b/libc/src/stdlib/exit.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "src/stdlib/exit.h" +#include "src/__support/OSUtil/quick_exit.h" #include "src/__support/common.h" -#include "src/stdlib/_Exit.h" namespace __llvm_libc { @@ -18,7 +18,7 @@ LLVM_LIBC_FUNCTION(void, exit, (int status)) { internal::call_exit_callbacks(); - _Exit(status); + quick_exit(status); } } // namespace __llvm_libc diff --git a/libc/src/stdlib/gpu/CMakeLists.txt b/libc/src/stdlib/gpu/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/libc/src/stdlib/gpu/CMakeLists.txt @@ -0,0 +1,10 @@ +add_entrypoint_object( + _Exit + SRCS + _Exit.cpp + HDRS + ../_Exit.h + DEPENDS + libc.include.stdlib + libc.src.__support.OSUtil.osutil +) diff --git a/libc/src/stdlib/exit.cpp b/libc/src/stdlib/gpu/_Exit.cpp copy from libc/src/stdlib/exit.cpp copy to libc/src/stdlib/gpu/_Exit.cpp --- a/libc/src/stdlib/exit.cpp +++ b/libc/src/stdlib/gpu/_Exit.cpp @@ -1,4 +1,4 @@ -//===-- Implementation of exit --------------------------------------------===// +//===------------------- GPU Implementation of _Exit-----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,19 +6,13 @@ // //===----------------------------------------------------------------------===// -#include "src/stdlib/exit.h" +#include "src/__support/OSUtil/quick_exit.h" #include "src/__support/common.h" + #include "src/stdlib/_Exit.h" namespace __llvm_libc { -namespace internal { -void call_exit_callbacks(); -} - -LLVM_LIBC_FUNCTION(void, exit, (int status)) { - internal::call_exit_callbacks(); - _Exit(status); -} +LLVM_LIBC_FUNCTION(void, _Exit, (int status)) { quick_exit(status); } } // namespace __llvm_libc diff --git a/libc/src/stdlib/linux/_Exit.cpp b/libc/src/stdlib/linux/_Exit.cpp --- a/libc/src/stdlib/linux/_Exit.cpp +++ b/libc/src/stdlib/linux/_Exit.cpp @@ -6,19 +6,13 @@ // //===----------------------------------------------------------------------===// -#include "include/sys/syscall.h" // For syscall numbers. -#include "src/__support/OSUtil/syscall.h" // For internal syscall function. +#include "src/__support/OSUtil/quick_exit.h" #include "src/__support/common.h" #include "src/stdlib/_Exit.h" namespace __llvm_libc { -LLVM_LIBC_FUNCTION(void, _Exit, (int status)) { - for (;;) { - __llvm_libc::syscall_impl(SYS_exit_group, status); - __llvm_libc::syscall_impl(SYS_exit, status); - } -} +LLVM_LIBC_FUNCTION(void, _Exit, (int status)) { quick_exit(status); } } // namespace __llvm_libc