diff options
author | Joseph Huber <huberjn@outlook.com> | 2024-07-01 06:29:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-01 06:29:48 -0500 |
commit | ec0e6ef09bdbae42872af1145f9c58c641d0ab8a (patch) | |
tree | 25e9bc8c8e7848de2193860fd7219d6f55b87249 /libc/src | |
parent | d32d20f3a05abf74ecc11848a672d4cac4fa45cd (diff) | |
download | llvm-ec0e6ef09bdbae42872af1145f9c58c641d0ab8a.zip llvm-ec0e6ef09bdbae42872af1145f9c58c641d0ab8a.tar.gz llvm-ec0e6ef09bdbae42872af1145f9c58c641d0ab8a.tar.bz2 |
[libc] Implement the 'remove' function on the GPU (#97096)
Summary:
Straightforward RPC implementation of the `remove` function for the GPU.
Copies over the string and calls `remove` on it, passing the result
back. This is required for building some `libc++` functionality.
Diffstat (limited to 'libc/src')
-rw-r--r-- | libc/src/stdio/gpu/CMakeLists.txt | 11 | ||||
-rw-r--r-- | libc/src/stdio/gpu/remove.cpp | 26 |
2 files changed, 37 insertions, 0 deletions
diff --git a/libc/src/stdio/gpu/CMakeLists.txt b/libc/src/stdio/gpu/CMakeLists.txt index 1b1e2a9..8940843 100644 --- a/libc/src/stdio/gpu/CMakeLists.txt +++ b/libc/src/stdio/gpu/CMakeLists.txt @@ -263,6 +263,17 @@ add_entrypoint_object( ) add_entrypoint_object( + remove + SRCS + remove.cpp + HDRS + ../remove.h + DEPENDS + libc.include.stdio + .gpu_file +) + +add_entrypoint_object( stdin SRCS stdin.cpp diff --git a/libc/src/stdio/gpu/remove.cpp b/libc/src/stdio/gpu/remove.cpp new file mode 100644 index 0000000..398be5f --- /dev/null +++ b/libc/src/stdio/gpu/remove.cpp @@ -0,0 +1,26 @@ +//===-- Implementation of remove ------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "src/stdio/remove.h" +#include "file.h" + +#include <stdio.h> + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(int, remove, (const char *path)) { + int ret; + rpc::Client::Port port = rpc::client.open<RPC_REMOVE>(); + port.send_n(path, internal::string_length(path) + 1); + port.recv( + [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); }); + port.close(); + return ret; +} + +} // namespace LIBC_NAMESPACE |