[libc-commits] [libc] [libc] Add `scanf` support to the GPU build (PR #104812)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Wed Aug 21 15:04:11 PDT 2024
================
@@ -12,17 +12,41 @@
#include "src/__support/File/file.h"
#include "src/__support/arg_list.h"
#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/architectures.h"
#include "src/stdio/scanf_core/reader.h"
#include "src/stdio/scanf_core/scanf_main.h"
+#if defined(LIBC_TARGET_ARCH_IS_GPU)
+#include "src/stdio/ferror.h"
+#include "src/stdio/getc.h"
+#include "src/stdio/ungetc.h"
+#endif
+
#include "hdr/types/FILE.h"
#include <stddef.h>
namespace LIBC_NAMESPACE_DECL {
namespace internal {
-#ifndef LIBC_COPT_STDIO_USE_SYSTEM_FILE
+#if defined(LIBC_TARGET_ARCH_IS_GPU)
+// Since ungetc_unlocked isn't always available, we don't acquire the lock for
+// system files.
+LIBC_INLINE void flockfile(::FILE *) { return; }
+
+LIBC_INLINE void funlockfile(::FILE *) { return; }
+
+LIBC_INLINE int getc(void *f) {
+ return LIBC_NAMESPACE::getc(reinterpret_cast<::FILE *>(f));
----------------
jhuber6 wrote:
Added a bit extra
https://github.com/llvm/llvm-project/pull/104812
More information about the libc-commits
mailing list