Skip to content

Commit 8f0f265

Browse files
author
Michal Simek
committed
microblaze: Use simple memset implementation from lib/string.c
On microblaze systems which are not using OPT_LIB_FUNCTION only simple memset is used. This function is already implemented in lib/string.c that's why it should be used instead. This change is done in respect of issue fixed by commit 33d0f96 ("lib/string.c: Use freestanding environment") where gcc-10.x moved -ftree-loop-distribute-patterns optimization is to O2 optimization level. This optimization causes GCC to convert the while loop in memset.c into a call to memset. So This optimization is transforming a loop in a memset/memcpy into a call to the function itself. This makes the memset implementation as recursive. Based on fix above -ffreestanding was used and it needs to be used on Microblaze too but the patch is not adding this flag it removes simple implementation to cause that generic implementation is used where this flag is already setup. Signed-off-by: Michal Simek <[email protected]> Signed-off-by: Mahesh Bodapati <[email protected]> Link: https://lore.kernel.org/r/4a143e7654f72ee893dcea9769946e17d3570b16.1645797329.git.michal.simek@xilinx.com
1 parent 3123109 commit 8f0f265

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

arch/microblaze/include/asm/string.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
#ifdef __KERNEL__
1010

11+
#ifdef CONFIG_OPT_LIB_FUNCTION
1112
#define __HAVE_ARCH_MEMSET
13+
#endif
1214
#define __HAVE_ARCH_MEMCPY
1315
#define __HAVE_ARCH_MEMMOVE
1416

arch/microblaze/lib/memset.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,7 @@
3030
#include <linux/compiler.h>
3131
#include <linux/string.h>
3232

33-
#ifdef __HAVE_ARCH_MEMSET
34-
#ifndef CONFIG_OPT_LIB_FUNCTION
35-
void *memset(void *v_src, int c, __kernel_size_t n)
36-
{
37-
char *src = v_src;
38-
39-
/* Truncate c to 8 bits */
40-
c = (c & 0xFF);
41-
42-
/* Simple, byte oriented memset or the rest of count. */
43-
while (n--)
44-
*src++ = c;
45-
46-
return v_src;
47-
}
48-
#else /* CONFIG_OPT_LIB_FUNCTION */
33+
#ifdef CONFIG_OPT_LIB_FUNCTION
4934
void *memset(void *v_src, int c, __kernel_size_t n)
5035
{
5136
char *src = v_src;
@@ -94,6 +79,5 @@ void *memset(void *v_src, int c, __kernel_size_t n)
9479

9580
return v_src;
9681
}
97-
#endif /* CONFIG_OPT_LIB_FUNCTION */
9882
EXPORT_SYMBOL(memset);
99-
#endif /* __HAVE_ARCH_MEMSET */
83+
#endif /* CONFIG_OPT_LIB_FUNCTION */

0 commit comments

Comments
 (0)