Warning: This file is not a C or C++ file. It does not have highlighting.
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 | #include_next <string.h> |
17 | |
18 | #if __has_include(<llvm-libc-decls/string.h>) |
19 | |
20 | #if defined(__HIP__) || defined(__CUDA__) |
21 | #define __LIBC_ATTRS __attribute__((device)) |
22 | #endif |
23 | |
24 | #pragma omp begin declare target |
25 | |
26 | // The GNU headers provide C++ standard compliant headers when in C++ mode and |
27 | // the LLVM libc does not. We need to manually provide the definitions using the |
28 | // same prototypes. |
29 | #if defined(__cplusplus) && defined(__GLIBC__) && \ |
30 | defined(__CORRECT_ISO_CPP_STRING_H_PROTO) |
31 | |
32 | #ifndef __LIBC_ATTRS |
33 | #define __LIBC_ATTRS |
34 | #endif |
35 | |
36 | extern "C" { |
37 | void *memccpy(void *__restrict, const void *__restrict, int, |
38 | size_t) __LIBC_ATTRS; |
39 | int memcmp(const void *, const void *, size_t) __LIBC_ATTRS; |
40 | void *memcpy(void *__restrict, const void *__restrict, size_t) __LIBC_ATTRS; |
41 | void *memmem(const void *, size_t, const void *, size_t) __LIBC_ATTRS; |
42 | void *memmove(void *, const void *, size_t) __LIBC_ATTRS; |
43 | void *mempcpy(void *__restrict, const void *__restrict, size_t) __LIBC_ATTRS; |
44 | void *memset(void *, int, size_t) __LIBC_ATTRS; |
45 | char *stpcpy(char *__restrict, const char *__restrict) __LIBC_ATTRS; |
46 | char *stpncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; |
47 | char *strcat(char *__restrict, const char *__restrict) __LIBC_ATTRS; |
48 | int strcmp(const char *, const char *) __LIBC_ATTRS; |
49 | int strcoll(const char *, const char *) __LIBC_ATTRS; |
50 | char *strcpy(char *__restrict, const char *__restrict) __LIBC_ATTRS; |
51 | size_t strcspn(const char *, const char *) __LIBC_ATTRS; |
52 | char *strdup(const char *) __LIBC_ATTRS; |
53 | size_t strlen(const char *) __LIBC_ATTRS; |
54 | char *strncat(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; |
55 | int strncmp(const char *, const char *, size_t) __LIBC_ATTRS; |
56 | char *strncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; |
57 | char *strndup(const char *, size_t) __LIBC_ATTRS; |
58 | size_t strnlen(const char *, size_t) __LIBC_ATTRS; |
59 | size_t strspn(const char *, const char *) __LIBC_ATTRS; |
60 | char *strtok(char *__restrict, const char *__restrict) __LIBC_ATTRS; |
61 | char *strtok_r(char *__restrict, const char *__restrict, |
62 | char **__restrict) __LIBC_ATTRS; |
63 | size_t strxfrm(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS; |
64 | } |
65 | |
66 | extern "C++" { |
67 | char *strstr(char *, const char *) noexcept __LIBC_ATTRS; |
68 | const char *strstr(const char *, const char *) noexcept __LIBC_ATTRS; |
69 | char *strpbrk(char *, const char *) noexcept __LIBC_ATTRS; |
70 | const char *strpbrk(const char *, const char *) noexcept __LIBC_ATTRS; |
71 | char *strrchr(char *, int) noexcept __LIBC_ATTRS; |
72 | const char *strrchr(const char *, int) noexcept __LIBC_ATTRS; |
73 | char *strchr(char *, int) noexcept __LIBC_ATTRS; |
74 | const char *strchr(const char *, int) noexcept __LIBC_ATTRS; |
75 | char *strchrnul(char *, int) noexcept __LIBC_ATTRS; |
76 | const char *strchrnul(const char *, int) noexcept __LIBC_ATTRS; |
77 | char *strcasestr(char *, const char *) noexcept __LIBC_ATTRS; |
78 | const char *strcasestr(const char *, const char *) noexcept __LIBC_ATTRS; |
79 | void *memrchr(void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; |
80 | const void *memrchr(const void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; |
81 | void *memchr(void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; |
82 | const void *memchr(const void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS; |
83 | } |
84 | |
85 | #else |
86 | #include <llvm-libc-decls/string.h> |
87 | |
88 | #endif |
89 | |
90 | #pragma omp end declare target |
91 | |
92 | #undef __LIBC_ATTRS |
93 | |
94 | #endif |
95 | |
96 | #endif // __CLANG_LLVM_LIBC_WRAPPERS_STRING_H__ |
97 |
Warning: This file is not a C or C++ file. It does not have highlighting.