xref: /aosp_15_r20/external/llvm-libc/src/stdlib/gpu/system.cpp (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
1 //===-- GPU implementation of system --------------------------------------===//
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/RPC/rpc_client.h"
10 #include "src/__support/common.h"
11 #include "src/__support/macros/config.h"
12 #include "src/string/string_utils.h"
13 
14 #include "src/stdlib/system.h"
15 
16 namespace LIBC_NAMESPACE_DECL {
17 
18 LLVM_LIBC_FUNCTION(int, system, (const char *command)) {
19   int ret;
20   rpc::Client::Port port = rpc::client.open<RPC_SYSTEM>();
21   port.send_n(command, internal::string_length(command) + 1);
__anonce2fb3510102(rpc::Buffer *buffer, uint32_t) 22   port.recv([&](rpc::Buffer *buffer, uint32_t) {
23     ret = static_cast<int>(buffer->data[0]);
24   });
25   port.close();
26 
27   return ret;
28 }
29 
30 } // namespace LIBC_NAMESPACE_DECL
31