Skip to content

Commit

Permalink
Revert "parisc: Add assembly implementations for memset, strlen, strc…
Browse files Browse the repository at this point in the history
…py, strncpy and strcat"

commit f6a3308 upstream.

This reverts commit 83af58f.

It turns out that at least the assembly implementation for strncpy() was
buggy.  Revert the whole commit and return back to the default coding.

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: <stable@vger.kernel.org> # v5.4+
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
hdeller authored and gregkh committed Sep 3, 2021
1 parent 17982c6 commit 0085646
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 157 deletions.
15 changes: 0 additions & 15 deletions arch/parisc/include/asm/string.h
Expand Up @@ -8,19 +8,4 @@ extern void * memset(void *, int, size_t);
#define __HAVE_ARCH_MEMCPY
void * memcpy(void * dest,const void *src,size_t count);

#define __HAVE_ARCH_STRLEN
extern size_t strlen(const char *s);

#define __HAVE_ARCH_STRCPY
extern char *strcpy(char *dest, const char *src);

#define __HAVE_ARCH_STRNCPY
extern char *strncpy(char *dest, const char *src, size_t count);

#define __HAVE_ARCH_STRCAT
extern char *strcat(char *dest, const char *src);

#define __HAVE_ARCH_MEMSET
extern void *memset(void *, int, size_t);

#endif
4 changes: 0 additions & 4 deletions arch/parisc/kernel/parisc_ksyms.c
Expand Up @@ -17,10 +17,6 @@

#include <linux/string.h>
EXPORT_SYMBOL(memset);
EXPORT_SYMBOL(strlen);
EXPORT_SYMBOL(strcpy);
EXPORT_SYMBOL(strncpy);
EXPORT_SYMBOL(strcat);

#include <linux/atomic.h>
EXPORT_SYMBOL(__xchg8);
Expand Down
4 changes: 2 additions & 2 deletions arch/parisc/lib/Makefile
Expand Up @@ -3,7 +3,7 @@
# Makefile for parisc-specific library files
#

lib-y := lusercopy.o bitops.o checksum.o io.o memcpy.o \
ucmpdi2.o delay.o string.o
lib-y := lusercopy.o bitops.o checksum.o io.o memset.o memcpy.o \
ucmpdi2.o delay.o

obj-y := iomap.o
72 changes: 72 additions & 0 deletions arch/parisc/lib/memset.c
@@ -0,0 +1,72 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include <linux/types.h>
#include <asm/string.h>

#define OPSIZ (BITS_PER_LONG/8)
typedef unsigned long op_t;

void *
memset (void *dstpp, int sc, size_t len)
{
unsigned int c = sc;
long int dstp = (long int) dstpp;

if (len >= 8)
{
size_t xlen;
op_t cccc;

cccc = (unsigned char) c;
cccc |= cccc << 8;
cccc |= cccc << 16;
if (OPSIZ > 4)
/* Do the shift in two steps to avoid warning if long has 32 bits. */
cccc |= (cccc << 16) << 16;

/* There are at least some bytes to set.
No need to test for LEN == 0 in this alignment loop. */
while (dstp % OPSIZ != 0)
{
((unsigned char *) dstp)[0] = c;
dstp += 1;
len -= 1;
}

/* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */
xlen = len / (OPSIZ * 8);
while (xlen > 0)
{
((op_t *) dstp)[0] = cccc;
((op_t *) dstp)[1] = cccc;
((op_t *) dstp)[2] = cccc;
((op_t *) dstp)[3] = cccc;
((op_t *) dstp)[4] = cccc;
((op_t *) dstp)[5] = cccc;
((op_t *) dstp)[6] = cccc;
((op_t *) dstp)[7] = cccc;
dstp += 8 * OPSIZ;
xlen -= 1;
}
len %= OPSIZ * 8;

/* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */
xlen = len / OPSIZ;
while (xlen > 0)
{
((op_t *) dstp)[0] = cccc;
dstp += OPSIZ;
xlen -= 1;
}
len %= OPSIZ;
}

/* Write the last few bytes. */
while (len > 0)
{
((unsigned char *) dstp)[0] = c;
dstp += 1;
len -= 1;
}

return dstpp;
}
136 changes: 0 additions & 136 deletions arch/parisc/lib/string.S

This file was deleted.

0 comments on commit 0085646

Please sign in to comment.