1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2013 ARM Ltd.
4  */
5 #ifndef __ASM_STRING_H
6 #define __ASM_STRING_H
7 
8 #if !(defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS))
9 #define __HAVE_ARCH_STRRCHR
10 extern char *strrchr(const char *, int c);
11 
12 #define __HAVE_ARCH_STRCHR
13 extern char *strchr(const char *, int c);
14 
15 #ifndef CONFIG_KASAN_HW_TAGS
16 #define __HAVE_ARCH_STRCMP
17 extern int strcmp(const char *, const char *);
18 
19 #define __HAVE_ARCH_STRNCMP
20 extern int strncmp(const char *, const char *, __kernel_size_t);
21 #endif
22 
23 #define __HAVE_ARCH_STRLEN
24 extern __kernel_size_t strlen(const char *);
25 
26 #define __HAVE_ARCH_STRNLEN
27 extern __kernel_size_t strnlen(const char *, __kernel_size_t);
28 
29 #define __HAVE_ARCH_MEMCMP
30 extern int memcmp(const void *, const void *, size_t);
31 
32 #define __HAVE_ARCH_MEMCHR
33 extern void *memchr(const void *, int, __kernel_size_t);
34 #endif
35 
36 #define __HAVE_ARCH_MEMCPY
37 extern void *memcpy(void *, const void *, __kernel_size_t);
38 extern void *__memcpy(void *, const void *, __kernel_size_t);
39 
40 #define __HAVE_ARCH_MEMMOVE
41 extern void *memmove(void *, const void *, __kernel_size_t);
42 extern void *__memmove(void *, const void *, __kernel_size_t);
43 
44 #define __HAVE_ARCH_MEMSET
45 extern void *memset(void *, int, __kernel_size_t);
46 extern void *__memset(void *, int, __kernel_size_t);
47 
48 #ifdef CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE
49 #define __HAVE_ARCH_MEMCPY_FLUSHCACHE
50 void memcpy_flushcache(void *dst, const void *src, size_t cnt);
51 #endif
52 
53 #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \
54 	!defined(__SANITIZE_ADDRESS__)
55 
56 /*
57  * For files that are not instrumented (e.g. mm/slub.c) we
58  * should use not instrumented version of mem* functions.
59  */
60 
61 #define memcpy(dst, src, len) __memcpy(dst, src, len)
62 #define memmove(dst, src, len) __memmove(dst, src, len)
63 #define memset(s, c, n) __memset(s, c, n)
64 
65 #ifndef __NO_FORTIFY
66 #define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
67 #endif
68 
69 #endif
70 
71 #endif
72