1//===---------- GPU implementation of a quick 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/quick_exit.h"
10
11#include "src/__support/RPC/rpc_client.h"
12#include "src/__support/macros/properties/architectures.h"
13
14namespace LIBC_NAMESPACE {
15
16[[noreturn]] void quick_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(fill: [](rpc::Buffer *) {}, use: [](rpc::Buffer *) {});
20 port.send(fill: [&](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
29

source code of libc/src/__support/OSUtil/gpu/quick_exit.cpp