1 //===------------- GPU implementation of an exit function -------*- C++ -*-===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/__support/OSUtil/exit.h" 10 11 #include "src/__support/RPC/rpc_client.h" 12 #include "src/__support/macros/properties/architectures.h" 13 14 namespace LIBC_NAMESPACE::internal { 15 exit(int status)16[[noreturn]] void exit(int status) { 17 // We want to first make sure the server is listening before we exit. 18 rpc::Client::Port port = rpc::client.open<RPC_EXIT>(); 19 port.send_and_recv([](rpc::Buffer *) {}, [](rpc::Buffer *) {}); 20 port.send([&](rpc::Buffer *buffer) { 21 reinterpret_cast<uint32_t *>(buffer->data)[0] = status; 22 }); 23 port.close(); 24 25 gpu::end_program(); 26 } 27 28 } // namespace LIBC_NAMESPACE::internal 29