xref: /freebsd/contrib/llvm-project/clang/lib/Headers/llvm_libc_wrappers/string.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 //===-- Wrapper for C standard string.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 //===----------------------------------------------------------------------===//
8 
9 #ifndef __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
10 #define __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
11 
12 #if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
13 #error "This file is for GPU offloading compilation only"
14 #endif
15 
16 // FIXME: The GNU headers provide C++ standard compliant headers when in C++
17 // mode and the LLVM libc does not. We cannot enable memchr, strchr, strchrnul,
18 // strpbrk, strrchr, strstr, or strcasestr until this is addressed.
19 #include_next <string.h>
20 
21 #if __has_include(<llvm-libc-decls/string.h>)
22 
23 #if defined(__HIP__) || defined(__CUDA__)
24 #define __LIBC_ATTRS __attribute__((device))
25 #endif
26 
27 #pragma omp begin declare target
28 
29 #include <llvm-libc-decls/string.h>
30 
31 #pragma omp end declare target
32 
33 #undef __LIBC_ATTRS
34 
35 #endif
36 
37 #endif // __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__
38