[Flang] remove whole-archive option for AIX linker (#76039)
[llvm-project.git] / clang / lib / Headers / llvm_libc_wrappers / stdio.h
blob0870f3e741ec135a65908ac5c9de12004a08dfd6
1 //===-- Wrapper for C standard stdio.h declarations on the GPU ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
10 #define __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__
12 #if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
13 #error "This file is for GPU offloading compilation only"
14 #endif
16 #include_next <stdio.h>
18 #if __has_include(<llvm-libc-decls/stdio.h>)
20 #if defined(__HIP__) || defined(__CUDA__)
21 #define __LIBC_ATTRS __attribute__((device))
22 #endif
24 // Some headers provide these as macros. Temporarily undefine them so they do
25 // not conflict with any definitions for the GPU.
27 #pragma push_macro("stdout")
28 #pragma push_macro("stdin")
29 #pragma push_macro("stderr")
31 #undef stdout
32 #undef stderr
33 #undef stdin
35 #pragma omp begin declare target
37 #include <llvm-libc-decls/stdio.h>
39 #pragma omp end declare target
41 #undef __LIBC_ATTRS
43 // Restore the original macros when compiling on the host.
44 #if !defined(__NVPTX__) && !defined(__AMDGPU__)
45 #pragma pop_macro("stdout")
46 #pragma pop_macro("stderr")
47 #pragma pop_macro("stdin")
48 #endif
50 #endif
52 #endif // __CLANG_LLVM_LIBC_WRAPPERS_STDIO_H__