162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_POWERPC_STRING_H
362306a36Sopenharmony_ci#define _ASM_POWERPC_STRING_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#ifdef __KERNEL__
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef CONFIG_KASAN
862306a36Sopenharmony_ci#define __HAVE_ARCH_STRNCPY
962306a36Sopenharmony_ci#define __HAVE_ARCH_STRNCMP
1062306a36Sopenharmony_ci#define __HAVE_ARCH_MEMCHR
1162306a36Sopenharmony_ci#define __HAVE_ARCH_MEMCMP
1262306a36Sopenharmony_ci#define __HAVE_ARCH_MEMSET16
1362306a36Sopenharmony_ci#endif
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define __HAVE_ARCH_MEMSET
1662306a36Sopenharmony_ci#define __HAVE_ARCH_MEMCPY
1762306a36Sopenharmony_ci#define __HAVE_ARCH_MEMMOVE
1862306a36Sopenharmony_ci#define __HAVE_ARCH_MEMCPY_FLUSHCACHE
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciextern char * strcpy(char *,const char *);
2162306a36Sopenharmony_ciextern char * strncpy(char *,const char *, __kernel_size_t);
2262306a36Sopenharmony_ciextern __kernel_size_t strlen(const char *);
2362306a36Sopenharmony_ciextern int strcmp(const char *,const char *);
2462306a36Sopenharmony_ciextern int strncmp(const char *, const char *, __kernel_size_t);
2562306a36Sopenharmony_ciextern char * strcat(char *, const char *);
2662306a36Sopenharmony_ciextern void * memset(void *,int,__kernel_size_t);
2762306a36Sopenharmony_ciextern void * memcpy(void *,const void *,__kernel_size_t);
2862306a36Sopenharmony_ciextern void * memmove(void *,const void *,__kernel_size_t);
2962306a36Sopenharmony_ciextern int memcmp(const void *,const void *,__kernel_size_t);
3062306a36Sopenharmony_ciextern void * memchr(const void *,int,__kernel_size_t);
3162306a36Sopenharmony_civoid memcpy_flushcache(void *dest, const void *src, size_t size);
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifdef CONFIG_KASAN
3462306a36Sopenharmony_ci/* __mem variants are used by KASAN to implement instrumented meminstrinsics. */
3562306a36Sopenharmony_ci#ifdef CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX
3662306a36Sopenharmony_ci#define __memset memset
3762306a36Sopenharmony_ci#define __memcpy memcpy
3862306a36Sopenharmony_ci#define __memmove memmove
3962306a36Sopenharmony_ci#else /* CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX */
4062306a36Sopenharmony_civoid *__memset(void *s, int c, __kernel_size_t count);
4162306a36Sopenharmony_civoid *__memcpy(void *to, const void *from, __kernel_size_t n);
4262306a36Sopenharmony_civoid *__memmove(void *to, const void *from, __kernel_size_t n);
4362306a36Sopenharmony_ci#ifndef __SANITIZE_ADDRESS__
4462306a36Sopenharmony_ci/*
4562306a36Sopenharmony_ci * For files that are not instrumented (e.g. mm/slub.c) we
4662306a36Sopenharmony_ci * should use not instrumented version of mem* functions.
4762306a36Sopenharmony_ci */
4862306a36Sopenharmony_ci#define memcpy(dst, src, len) __memcpy(dst, src, len)
4962306a36Sopenharmony_ci#define memmove(dst, src, len) __memmove(dst, src, len)
5062306a36Sopenharmony_ci#define memset(s, c, n) __memset(s, c, n)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#ifndef __NO_FORTIFY
5362306a36Sopenharmony_ci#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
5462306a36Sopenharmony_ci#endif
5562306a36Sopenharmony_ci#endif /* !__SANITIZE_ADDRESS__ */
5662306a36Sopenharmony_ci#endif /* CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX */
5762306a36Sopenharmony_ci#endif /* CONFIG_KASAN */
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#ifdef CONFIG_PPC64
6062306a36Sopenharmony_ci#ifndef CONFIG_KASAN
6162306a36Sopenharmony_ci#define __HAVE_ARCH_MEMSET32
6262306a36Sopenharmony_ci#define __HAVE_ARCH_MEMSET64
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciextern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t);
6562306a36Sopenharmony_ciextern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
6662306a36Sopenharmony_ciextern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t);
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_cistatic inline void *memset16(uint16_t *p, uint16_t v, __kernel_size_t n)
6962306a36Sopenharmony_ci{
7062306a36Sopenharmony_ci	return __memset16(p, v, n * 2);
7162306a36Sopenharmony_ci}
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_cistatic inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
7462306a36Sopenharmony_ci{
7562306a36Sopenharmony_ci	return __memset32(p, v, n * 4);
7662306a36Sopenharmony_ci}
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_cistatic inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
7962306a36Sopenharmony_ci{
8062306a36Sopenharmony_ci	return __memset64(p, v, n * 8);
8162306a36Sopenharmony_ci}
8262306a36Sopenharmony_ci#endif
8362306a36Sopenharmony_ci#else
8462306a36Sopenharmony_ci#ifndef CONFIG_KASAN
8562306a36Sopenharmony_ci#define __HAVE_ARCH_STRLEN
8662306a36Sopenharmony_ci#endif
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ciextern void *memset16(uint16_t *, uint16_t, __kernel_size_t);
8962306a36Sopenharmony_ci#endif
9062306a36Sopenharmony_ci#endif /* __KERNEL__ */
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#endif	/* _ASM_POWERPC_STRING_H */
93