Author: Joseph Huber Date: 2023-11-20T11:22:59-06:00 New Revision: 88b672b0a79e9f68253abf7edcfa5a42d1321cae
URL: https://github.com/llvm/llvm-project/commit/88b672b0a79e9f68253abf7edcfa5a42d1321cae DIFF: https://github.com/llvm/llvm-project/commit/88b672b0a79e9f68253abf7edcfa5a42d1321cae.diff LOG: [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. Added: Modified: clang/lib/Headers/llvm_libc_wrappers/stdio.h Removed: ################################################################################ diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h b/clang/lib/Headers/llvm_libc_wrappers/stdio.h index 51b0f0e3307772c..0870f3e741ec135 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__ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits