18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_STRING_H
38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_STRING_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#ifdef __KERNEL__
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef CONFIG_KASAN
88c2ecf20Sopenharmony_ci#define __HAVE_ARCH_STRNCPY
98c2ecf20Sopenharmony_ci#define __HAVE_ARCH_STRNCMP
108c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMCHR
118c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMCMP
128c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMSET16
138c2ecf20Sopenharmony_ci#endif
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMSET
168c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMCPY
178c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMMOVE
188c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMCPY_FLUSHCACHE
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciextern char * strcpy(char *,const char *);
218c2ecf20Sopenharmony_ciextern char * strncpy(char *,const char *, __kernel_size_t);
228c2ecf20Sopenharmony_ciextern __kernel_size_t strlen(const char *);
238c2ecf20Sopenharmony_ciextern int strcmp(const char *,const char *);
248c2ecf20Sopenharmony_ciextern int strncmp(const char *, const char *, __kernel_size_t);
258c2ecf20Sopenharmony_ciextern char * strcat(char *, const char *);
268c2ecf20Sopenharmony_ciextern void * memset(void *,int,__kernel_size_t);
278c2ecf20Sopenharmony_ciextern void * memcpy(void *,const void *,__kernel_size_t);
288c2ecf20Sopenharmony_ciextern void * memmove(void *,const void *,__kernel_size_t);
298c2ecf20Sopenharmony_ciextern int memcmp(const void *,const void *,__kernel_size_t);
308c2ecf20Sopenharmony_ciextern void * memchr(const void *,int,__kernel_size_t);
318c2ecf20Sopenharmony_civoid memcpy_flushcache(void *dest, const void *src, size_t size);
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_civoid *__memset(void *s, int c, __kernel_size_t count);
348c2ecf20Sopenharmony_civoid *__memcpy(void *to, const void *from, __kernel_size_t n);
358c2ecf20Sopenharmony_civoid *__memmove(void *to, const void *from, __kernel_size_t n);
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
388c2ecf20Sopenharmony_ci/*
398c2ecf20Sopenharmony_ci * For files that are not instrumented (e.g. mm/slub.c) we
408c2ecf20Sopenharmony_ci * should use not instrumented version of mem* functions.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_ci#define memcpy(dst, src, len) __memcpy(dst, src, len)
438c2ecf20Sopenharmony_ci#define memmove(dst, src, len) __memmove(dst, src, len)
448c2ecf20Sopenharmony_ci#define memset(s, c, n) __memset(s, c, n)
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#ifndef __NO_FORTIFY
478c2ecf20Sopenharmony_ci#define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
488c2ecf20Sopenharmony_ci#endif
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#endif
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#ifdef CONFIG_PPC64
538c2ecf20Sopenharmony_ci#ifndef CONFIG_KASAN
548c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMSET32
558c2ecf20Sopenharmony_ci#define __HAVE_ARCH_MEMSET64
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ciextern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t);
588c2ecf20Sopenharmony_ciextern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
598c2ecf20Sopenharmony_ciextern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t);
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic inline void *memset16(uint16_t *p, uint16_t v, __kernel_size_t n)
628c2ecf20Sopenharmony_ci{
638c2ecf20Sopenharmony_ci	return __memset16(p, v, n * 2);
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistatic inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
678c2ecf20Sopenharmony_ci{
688c2ecf20Sopenharmony_ci	return __memset32(p, v, n * 4);
698c2ecf20Sopenharmony_ci}
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	return __memset64(p, v, n * 8);
748c2ecf20Sopenharmony_ci}
758c2ecf20Sopenharmony_ci#endif
768c2ecf20Sopenharmony_ci#else
778c2ecf20Sopenharmony_ci#ifndef CONFIG_KASAN
788c2ecf20Sopenharmony_ci#define __HAVE_ARCH_STRLEN
798c2ecf20Sopenharmony_ci#endif
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciextern void *memset16(uint16_t *, uint16_t, __kernel_size_t);
828c2ecf20Sopenharmony_ci#endif
838c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#endif	/* _ASM_POWERPC_STRING_H */
86