summaryrefslogtreecommitdiff
path: root/libc/src/stdio/gpu/ferror.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/stdio/gpu/ferror.cpp')
-rw-r--r--libc/src/stdio/gpu/ferror.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/libc/src/stdio/gpu/ferror.cpp b/libc/src/stdio/gpu/ferror.cpp
new file mode 100644
index 000000000000..e4bd631f392d
--- /dev/null
+++ b/libc/src/stdio/gpu/ferror.cpp
@@ -0,0 +1,26 @@
+//===-- Implementation of ferror ------------------------------------------===//
+//
+// 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/ferror.h"
+#include "file.h"
+
+#include <stdio.h>
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(int, ferror, (::FILE * stream)) {
+ int ret;
+ rpc::Client::Port port = rpc::client.open<RPC_FERROR>();
+ port.send_and_recv(
+ [=](rpc::Buffer *buffer) { buffer->data[0] = file::from_stream(stream); },
+ [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+ port.close();
+ return ret;
+}
+
+} // namespace __llvm_libc