|
13 | 13 | #error "This file is for GPU offloading compilation only"
|
14 | 14 | #endif
|
15 | 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 | 16 | #include_next <string.h>
|
20 | 17 |
|
21 | 18 | #if __has_include(<llvm-libc-decls/string.h>)
|
|
26 | 23 |
|
27 | 24 | #pragma omp begin declare target
|
28 | 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 *, const char *, 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 *) __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 |
29 | 86 | #include <llvm-libc-decls/string.h>
|
30 | 87 |
|
| 88 | +#endif |
| 89 | + |
31 | 90 | #pragma omp end declare target
|
32 | 91 |
|
33 | 92 | #undef __LIBC_ATTRS
|
|
0 commit comments