clang 20.0.0git
string.h
Go to the documentation of this file.
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
36extern "C" {
37void *memccpy(void *__restrict, const void *__restrict, int,
38 size_t) __LIBC_ATTRS;
39int memcmp(const void *, const void *, size_t) __LIBC_ATTRS;
40void *memcpy(void *__restrict, const void *__restrict, size_t) __LIBC_ATTRS;
41void *memmem(const void *, size_t, const void *, size_t) __LIBC_ATTRS;
42void *memmove(void *, const void *, size_t) __LIBC_ATTRS;
43void *mempcpy(void *__restrict, const void *__restrict, size_t) __LIBC_ATTRS;
44void *memset(void *, int, size_t) __LIBC_ATTRS;
45char *stpcpy(char *__restrict, const char *__restrict) __LIBC_ATTRS;
46char *stpncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
47char *strcat(char *__restrict, const char *__restrict) __LIBC_ATTRS;
48int strcmp(const char *, const char *) __LIBC_ATTRS;
49int strcoll(const char *, const char *) __LIBC_ATTRS;
50char *strcpy(char *__restrict, const char *__restrict) __LIBC_ATTRS;
51size_t strcspn(const char *, const char *) __LIBC_ATTRS;
52char *strdup(const char *) __LIBC_ATTRS;
53size_t strlen(const char *) __LIBC_ATTRS;
54char *strncat(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
55int strncmp(const char *, const char *, size_t) __LIBC_ATTRS;
56char *strncpy(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
57char *strndup(const char *, size_t) __LIBC_ATTRS;
58size_t strnlen(const char *, size_t) __LIBC_ATTRS;
59size_t strspn(const char *, const char *) __LIBC_ATTRS;
60char *strtok(char *__restrict, const char *__restrict) __LIBC_ATTRS;
61char *strtok_r(char *__restrict, const char *__restrict,
62 char **__restrict) __LIBC_ATTRS;
63size_t strxfrm(char *__restrict, const char *__restrict, size_t) __LIBC_ATTRS;
64}
65
66extern "C++" {
67char *strstr(char *, const char *) noexcept __LIBC_ATTRS;
68const char *strstr(const char *, const char *) noexcept __LIBC_ATTRS;
69char *strpbrk(char *, const char *) noexcept __LIBC_ATTRS;
70const char *strpbrk(const char *, const char *) noexcept __LIBC_ATTRS;
71char *strrchr(char *, int) noexcept __LIBC_ATTRS;
72const char *strrchr(const char *, int) noexcept __LIBC_ATTRS;
73char *strchr(char *, int) noexcept __LIBC_ATTRS;
74const char *strchr(const char *, int) noexcept __LIBC_ATTRS;
75char *strchrnul(char *, int) noexcept __LIBC_ATTRS;
76const char *strchrnul(const char *, int) noexcept __LIBC_ATTRS;
77char *strcasestr(char *, const char *) noexcept __LIBC_ATTRS;
78const char *strcasestr(const char *, const char *) noexcept __LIBC_ATTRS;
79void *memrchr(void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS;
80const void *memrchr(const void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS;
81void *memchr(void *__s, int __c, size_t __n) noexcept __LIBC_ATTRS;
82const 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__
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
static __inline__ vector float vector float vector float __c
Definition: altivec.h:4800