aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2023-11-20 11:17:54 -0600
committerJoseph Huber <huberjn@outlook.com>2023-11-20 11:22:59 -0600
commit88b672b0a79e9f68253abf7edcfa5a42d1321cae (patch)
treee0b12e6a87439de03769c9bfbe58304c523c5f88 /clang/lib
parent4a020018ce7abdee21e976f7ed5746ef2eb2c0fd (diff)
downloadllvm-88b672b0a79e9f68253abf7edcfa5a42d1321cae.zip
llvm-88b672b0a79e9f68253abf7edcfa5a42d1321cae.tar.gz
llvm-88b672b0a79e9f68253abf7edcfa5a42d1321cae.tar.bz2
[libc] Adjust headers for some implementations of 'stdio.h'
Summary: This is sometimes a macro, undefine it so we can declare it as the GPU needs.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Headers/llvm_libc_wrappers/stdio.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
index 51b0f0e..0870f3e 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdio.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
@@ -21,6 +21,17 @@
#define __LIBC_ATTRS __attribute__((device))
#endif
+// Some headers provide these as macros. Temporarily undefine them so they do
+// not conflict with any definitions for the GPU.
+
+#pragma push_macro("stdout")
+#pragma push_macro("stdin")
+#pragma push_macro("stderr")
+
+#undef stdout
+#undef stderr
+#undef stdin
+
#pragma omp begin declare target
#include <llvm-libc-decls/stdio.h>
@@ -29,6 +40,13 @@
#undef __LIBC_ATTRS
+// Restore the original macros when compiling on the host.
+#if !defined(__NVPTX__) && !defined(__AMDGPU__)
+#pragma pop_macro("stdout")
+#pragma pop_macro("stderr")
+#pragma pop_macro("stdin")
+#endif
+
#endif
#endif // __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__