blob: 2aa0e31e68844336a0fd37ac81bd2b97204b454f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
jdl@freescale.coma37c8872005-09-07 15:27:09 -05002#ifndef _ASM_POWERPC_STRING_H
3#define _ASM_POWERPC_STRING_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07004
5#ifdef __KERNEL__
6
Christophe Leroy26deb042019-04-26 16:23:26 +00007#ifndef CONFIG_KASAN
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#define __HAVE_ARCH_STRNCPY
Steven Rostedt01195362008-03-01 03:04:57 +11009#define __HAVE_ARCH_STRNCMP
Christophe Leroy26deb042019-04-26 16:23:26 +000010#define __HAVE_ARCH_MEMCHR
11#define __HAVE_ARCH_MEMCMP
12#define __HAVE_ARCH_MEMSET16
13#endif
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#define __HAVE_ARCH_MEMSET
16#define __HAVE_ARCH_MEMCPY
17#define __HAVE_ARCH_MEMMOVE
Oliver O'Halloran6c447412017-10-19 18:13:55 +110018#define __HAVE_ARCH_MEMCPY_FLUSHCACHE
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Linus Torvalds1da177e2005-04-16 15:20:36 -070020extern char * strcpy(char *,const char *);
21extern char * strncpy(char *,const char *, __kernel_size_t);
22extern __kernel_size_t strlen(const char *);
23extern int strcmp(const char *,const char *);
Steven Rostedt01195362008-03-01 03:04:57 +110024extern int strncmp(const char *, const char *, __kernel_size_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025extern char * strcat(char *, const char *);
26extern void * memset(void *,int,__kernel_size_t);
27extern void * memcpy(void *,const void *,__kernel_size_t);
28extern void * memmove(void *,const void *,__kernel_size_t);
29extern int memcmp(const void *,const void *,__kernel_size_t);
30extern void * memchr(const void *,int,__kernel_size_t);
Li RongQinge2802612019-04-26 19:36:30 +080031void memcpy_flushcache(void *dest, const void *src, size_t size);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Christophe Leroy26deb042019-04-26 16:23:26 +000033void *__memset(void *s, int c, __kernel_size_t count);
34void *__memcpy(void *to, const void *from, __kernel_size_t n);
35void *__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. Rao694fc882017-03-28 01:07:40 +053052#ifdef CONFIG_PPC64
Christophe Leroy26deb042019-04-26 16:23:26 +000053#ifndef CONFIG_KASAN
Naveen N. Rao694fc882017-03-28 01:07:40 +053054#define __HAVE_ARCH_MEMSET32
55#define __HAVE_ARCH_MEMSET64
56
57extern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t);
58extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
59extern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t);
60
61static inline void *memset16(uint16_t *p, uint16_t v, __kernel_size_t n)
62{
63 return __memset16(p, v, n * 2);
64}
65
66static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
67{
68 return __memset32(p, v, n * 4);
69}
70
71static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
72{
73 return __memset64(p, v, n * 8);
74}
Christophe Leroy26deb042019-04-26 16:23:26 +000075#endif
Christophe Leroyda74f652017-08-23 16:54:32 +020076#else
Christophe Leroy26deb042019-04-26 16:23:26 +000077#ifndef CONFIG_KASAN
Christophe Leroy9412b232018-08-01 09:01:14 +000078#define __HAVE_ARCH_STRLEN
Christophe Leroy26deb042019-04-26 16:23:26 +000079#endif
Christophe Leroy9412b232018-08-01 09:01:14 +000080
Christophe Leroyda74f652017-08-23 16:54:32 +020081extern void *memset16(uint16_t *, uint16_t, __kernel_size_t);
Naveen N. Rao694fc882017-03-28 01:07:40 +053082#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#endif /* __KERNEL__ */
84
jdl@freescale.coma37c8872005-09-07 15:27:09 -050085#endif /* _ASM_POWERPC_STRING_H */