1 //===---------- GPU implementation of a quick exit function -----*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
10 #define LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H
12 #include "quick_exit.h"
14 #include "src/__support/RPC/rpc_client.h"
15 #include "src/__support/macros/properties/architectures.h"
17 namespace LIBC_NAMESPACE
{
19 void quick_exit(int status
) {
20 // We want to first make sure the server is listening before we exit.
21 rpc::Client::Port port
= rpc::client
.open
<RPC_EXIT
>();
22 port
.send_and_recv([](rpc::Buffer
*) {}, [](rpc::Buffer
*) {});
23 port
.send([&](rpc::Buffer
*buffer
) {
24 reinterpret_cast<uint32_t *>(buffer
->data
)[0] = status
;
31 } // namespace LIBC_NAMESPACE
33 #endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_GPU_QUICK_EXIT_H