Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
jdl@freescale.com | a37c887 | 2005-09-07 15:27:09 -0500 | [diff] [blame] | 2 | #ifndef _ASM_POWERPC_STRING_H |
| 3 | #define _ASM_POWERPC_STRING_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | |
| 5 | #ifdef __KERNEL__ |
| 6 | |
Christophe Leroy | 26deb04 | 2019-04-26 16:23:26 +0000 | [diff] [blame] | 7 | #ifndef CONFIG_KASAN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #define __HAVE_ARCH_STRNCPY |
Steven Rostedt | 0119536 | 2008-03-01 03:04:57 +1100 | [diff] [blame] | 9 | #define __HAVE_ARCH_STRNCMP |
Christophe Leroy | 26deb04 | 2019-04-26 16:23:26 +0000 | [diff] [blame] | 10 | #define __HAVE_ARCH_MEMCHR |
| 11 | #define __HAVE_ARCH_MEMCMP |
| 12 | #define __HAVE_ARCH_MEMSET16 |
| 13 | #endif |
| 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #define __HAVE_ARCH_MEMSET |
| 16 | #define __HAVE_ARCH_MEMCPY |
| 17 | #define __HAVE_ARCH_MEMMOVE |
Oliver O'Halloran | 6c44741 | 2017-10-19 18:13:55 +1100 | [diff] [blame] | 18 | #define __HAVE_ARCH_MEMCPY_FLUSHCACHE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | extern char * strcpy(char *,const char *); |
| 21 | extern char * strncpy(char *,const char *, __kernel_size_t); |
| 22 | extern __kernel_size_t strlen(const char *); |
| 23 | extern int strcmp(const char *,const char *); |
Steven Rostedt | 0119536 | 2008-03-01 03:04:57 +1100 | [diff] [blame] | 24 | extern int strncmp(const char *, const char *, __kernel_size_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | extern char * strcat(char *, const char *); |
| 26 | extern void * memset(void *,int,__kernel_size_t); |
| 27 | extern void * memcpy(void *,const void *,__kernel_size_t); |
| 28 | extern void * memmove(void *,const void *,__kernel_size_t); |
| 29 | extern int memcmp(const void *,const void *,__kernel_size_t); |
| 30 | extern void * memchr(const void *,int,__kernel_size_t); |
Li RongQing | e280261 | 2019-04-26 19:36:30 +0800 | [diff] [blame] | 31 | void memcpy_flushcache(void *dest, const void *src, size_t size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Christophe Leroy | 26deb04 | 2019-04-26 16:23:26 +0000 | [diff] [blame] | 33 | void *__memset(void *s, int c, __kernel_size_t count); |
| 34 | void *__memcpy(void *to, const void *from, __kernel_size_t n); |
| 35 | void *__memmove(void *to, const void *from, __kernel_size_t n); |
| 36 | |
| 37 | #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) |
| 38 | /* |
| 39 | * For files that are not instrumented (e.g. mm/slub.c) we |
| 40 | * should use not instrumented version of mem* functions. |
| 41 | */ |
| 42 | #define memcpy(dst, src, len) __memcpy(dst, src, len) |
| 43 | #define memmove(dst, src, len) __memmove(dst, src, len) |
| 44 | #define memset(s, c, n) __memset(s, c, n) |
| 45 | |
| 46 | #ifndef __NO_FORTIFY |
| 47 | #define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */ |
| 48 | #endif |
| 49 | |
| 50 | #endif |
| 51 | |
Naveen N. Rao | 694fc88 | 2017-03-28 01:07:40 +0530 | [diff] [blame] | 52 | #ifdef CONFIG_PPC64 |
Christophe Leroy | 26deb04 | 2019-04-26 16:23:26 +0000 | [diff] [blame] | 53 | #ifndef CONFIG_KASAN |
Naveen N. Rao | 694fc88 | 2017-03-28 01:07:40 +0530 | [diff] [blame] | 54 | #define __HAVE_ARCH_MEMSET32 |
| 55 | #define __HAVE_ARCH_MEMSET64 |
| 56 | |
| 57 | extern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t); |
| 58 | extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t); |
| 59 | extern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t); |
| 60 | |
| 61 | static inline void *memset16(uint16_t *p, uint16_t v, __kernel_size_t n) |
| 62 | { |
| 63 | return __memset16(p, v, n * 2); |
| 64 | } |
| 65 | |
| 66 | static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n) |
| 67 | { |
| 68 | return __memset32(p, v, n * 4); |
| 69 | } |
| 70 | |
| 71 | static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n) |
| 72 | { |
| 73 | return __memset64(p, v, n * 8); |
| 74 | } |
Christophe Leroy | 26deb04 | 2019-04-26 16:23:26 +0000 | [diff] [blame] | 75 | #endif |
Christophe Leroy | da74f65 | 2017-08-23 16:54:32 +0200 | [diff] [blame] | 76 | #else |
Christophe Leroy | 26deb04 | 2019-04-26 16:23:26 +0000 | [diff] [blame] | 77 | #ifndef CONFIG_KASAN |
Christophe Leroy | 9412b23 | 2018-08-01 09:01:14 +0000 | [diff] [blame] | 78 | #define __HAVE_ARCH_STRLEN |
Christophe Leroy | 26deb04 | 2019-04-26 16:23:26 +0000 | [diff] [blame] | 79 | #endif |
Christophe Leroy | 9412b23 | 2018-08-01 09:01:14 +0000 | [diff] [blame] | 80 | |
Christophe Leroy | da74f65 | 2017-08-23 16:54:32 +0200 | [diff] [blame] | 81 | extern void *memset16(uint16_t *, uint16_t, __kernel_size_t); |
Naveen N. Rao | 694fc88 | 2017-03-28 01:07:40 +0530 | [diff] [blame] | 82 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #endif /* __KERNEL__ */ |
| 84 | |
jdl@freescale.com | a37c887 | 2005-09-07 15:27:09 -0500 | [diff] [blame] | 85 | #endif /* _ASM_POWERPC_STRING_H */ |