|
12 | 12 | #include "src/__support/File/file.h" |
13 | 13 | #include "src/__support/arg_list.h" |
14 | 14 | #include "src/__support/macros/config.h" |
| 15 | +#include "src/__support/macros/properties/architectures.h" |
15 | 16 | #include "src/stdio/scanf_core/reader.h" |
16 | 17 | #include "src/stdio/scanf_core/scanf_main.h" |
17 | 18 |
|
| 19 | +#if defined(LIBC_TARGET_ARCH_IS_GPU) |
| 20 | +#include "src/stdio/ferror.h" |
| 21 | +#include "src/stdio/getc.h" |
| 22 | +#include "src/stdio/ungetc.h" |
| 23 | +#endif |
| 24 | + |
18 | 25 | #include "hdr/types/FILE.h" |
19 | 26 | #include <stddef.h> |
20 | 27 |
|
21 | 28 | namespace LIBC_NAMESPACE_DECL { |
22 | 29 |
|
23 | 30 | namespace internal { |
24 | 31 |
|
25 | | -#ifndef LIBC_COPT_STDIO_USE_SYSTEM_FILE |
| 32 | +#if defined(LIBC_TARGET_ARCH_IS_GPU) |
| 33 | +// The GPU build provides FILE access through the host operating system's |
| 34 | +// library. So here we simply use the public entrypoints like in the SYSTEM_FILE |
| 35 | +// interface. Entrypoints should normally not call others, this is an exception. |
| 36 | +// FIXME: We do not acquire any locks here, so this is not thread safe. |
| 37 | +LIBC_INLINE void flockfile(::FILE *) { return; } |
| 38 | + |
| 39 | +LIBC_INLINE void funlockfile(::FILE *) { return; } |
| 40 | + |
| 41 | +LIBC_INLINE int getc(void *f) { |
| 42 | + return LIBC_NAMESPACE::getc(reinterpret_cast<::FILE *>(f)); |
| 43 | +} |
| 44 | + |
| 45 | +LIBC_INLINE void ungetc(int c, void *f) { |
| 46 | + LIBC_NAMESPACE::ungetc(c, reinterpret_cast<::FILE *>(f)); |
| 47 | +} |
| 48 | + |
| 49 | +LIBC_INLINE int ferror_unlocked(::FILE *f) { return LIBC_NAMESPACE::ferror(f); } |
| 50 | + |
| 51 | +#elif !defined(LIBC_COPT_STDIO_USE_SYSTEM_FILE) |
26 | 52 |
|
27 | 53 | LIBC_INLINE void flockfile(FILE *f) { |
28 | 54 | reinterpret_cast<LIBC_NAMESPACE::File *>(f)->lock(); |
|
0 commit comments