diff options
author | Joseph Huber <jhuber6@vols.utk.edu> | 2023-04-27 13:05:29 -0500 |
---|---|---|
committer | Joseph Huber <jhuber6@vols.utk.edu> | 2023-04-27 20:32:00 -0500 |
commit | 443d71527be0a052b2f533e4ad540733279ce46b (patch) | |
tree | 98526eef595809bbb466ff7c8304254898c31a6c /libc/src | |
parent | f7d5e9bc4ce5db276d5c0965dde4c4d323f699d1 (diff) | |
download | llvm-443d71527be0a052b2f533e4ad540733279ce46b.tar.gz |
[libc] Implement `exit` for the GPU partially
This patch implements the `exit` function on the GPU. This required
breaking the entrypoints calling eachother on `linux` since this doesn't
work with a non-aliased target. This is only partial support because
full support requires a malloc / free implementation for the exit
callbacks array.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D149363
Diffstat (limited to 'libc/src')
-rw-r--r-- | libc/src/stdlib/CMakeLists.txt | 9 | ||||
-rw-r--r-- | libc/src/stdlib/_Exit.cpp (renamed from libc/src/stdlib/linux/_Exit.cpp) | 11 | ||||
-rw-r--r-- | libc/src/stdlib/exit.cpp | 4 | ||||
-rw-r--r-- | libc/src/stdlib/linux/CMakeLists.txt | 12 |
4 files changed, 13 insertions, 23 deletions
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt index a9de969a5511..8067eebb532a 100644 --- a/libc/src/stdlib/CMakeLists.txt +++ b/libc/src/stdlib/CMakeLists.txt @@ -313,9 +313,13 @@ endif() add_entrypoint_object( _Exit - ALIAS + SRCS + _Exit.cpp + HDRS + _Exit.h DEPENDS - .${LIBC_TARGET_OS}._Exit + libc.include.stdlib + libc.src.__support.OSUtil.osutil ) add_entrypoint_object( @@ -341,6 +345,7 @@ add_entrypoint_object( DEPENDS ._Exit .atexit + libc.src.__support.OSUtil.osutil ) add_entrypoint_object( diff --git a/libc/src/stdlib/linux/_Exit.cpp b/libc/src/stdlib/_Exit.cpp index 0300a08847ce..5aec134b1c71 100644 --- a/libc/src/stdlib/linux/_Exit.cpp +++ b/libc/src/stdlib/_Exit.cpp @@ -1,4 +1,4 @@ -//===------------------- Linux Implementation of _Exit --------------------===// +//===------------------- 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,8 +6,7 @@ // //===----------------------------------------------------------------------===// -#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" @@ -15,10 +14,8 @@ 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); - } + quick_exit(status); + __builtin_unreachable(); } } // namespace __llvm_libc diff --git a/libc/src/stdlib/exit.cpp b/libc/src/stdlib/exit.cpp index 92faea4da6ad..71f5b1ecbf2c 100644 --- 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 @@ void call_exit_callbacks(); 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/linux/CMakeLists.txt b/libc/src/stdlib/linux/CMakeLists.txt index 360d3634f361..1d3c00a5e0dd 100644 --- a/libc/src/stdlib/linux/CMakeLists.txt +++ b/libc/src/stdlib/linux/CMakeLists.txt @@ -1,16 +1,4 @@ add_entrypoint_object( - _Exit - SRCS - _Exit.cpp - HDRS - ../_Exit.h - DEPENDS - libc.include.sys_syscall - libc.include.stdlib - libc.src.__support.OSUtil.osutil -) - -add_entrypoint_object( abort SRCS abort.cpp |