Skip to contentSkip to conversation

arc: Get rid of handwritten string routines

PATCH New Alexey Brodkin 1 participant 1 message Jan 25, 2018 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arc: Get rid of handwritten string routines

U-Boot is a bit special piese of software because it is being only executed once on power-on as compared to operating system for example. That's why we don't care much about performance optimizations instead we're more concerned about size. And up-to-date compilers might produce much smaller code compared to performance-optimized routines copy-pasted from the Linux kernel.

Here's an example:
------------------------------->8--------------------------

size_c_strings.txt renamed from size_asm_strings.txt +1 -1
@@ -1,2 +1,2 @@
    text	   data	    bss	    dec	    hex	filename
- 121260	   3784	   3308	 128352	  1f560	u-boot
+ 120448	   3784	   3308	 127540	  1f234	u-boot

------------------------------->8--------------------------

See we were able to shave off ~800 bytes of .text section.

Also usage of string routines implemented in C gives us an ability to support more HW flavors for free: generated instructions will match our target as long as correct compiler option is used.

---
 arch/arc/include/asm/string.h |  26 --------
 arch/arc/lib/Makefile         |   7 ---
 arch/arc/lib/memcmp.S         | 123 ------------------------------------
 arch/arc/lib/memcpy-700.S     |  63 -------------------
 arch/arc/lib/memset.S         |  62 -------------------
 arch/arc/lib/strchr-700.S     | 141 ------------------------------------------
 arch/arc/lib/strcmp.S         |  97 -----------------------------
 arch/arc/lib/strcpy-700.S     |  67 --------------------
 arch/arc/lib/strlen.S         |  80 ------------------------
 9 files changed, 666 deletions(-)
 delete mode 100644 arch/arc/lib/memcmp.S
 delete mode 100644 arch/arc/lib/memcpy-700.S
 delete mode 100644 arch/arc/lib/memset.S
 delete mode 100644 arch/arc/lib/strchr-700.S
 delete mode 100644 arch/arc/lib/strcmp.S
 delete mode 100644 arch/arc/lib/strcpy-700.S
 delete mode 100644 arch/arc/lib/strlen.S
arch/arc/include/asm/string.h +0 -26
index 909129c33318..8b137891791f 100644
@@ -1,27 +1 @@
-/*
- * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. All rights reserved.
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
 
-#ifndef __ASM_ARC_STRING_H
-#define __ASM_ARC_STRING_H
-
-#define __HAVE_ARCH_MEMSET
-#define __HAVE_ARCH_MEMCPY
-#define __HAVE_ARCH_MEMCMP
-#define __HAVE_ARCH_STRCHR
-#define __HAVE_ARCH_STRCPY
-#define __HAVE_ARCH_STRCMP
-#define __HAVE_ARCH_STRLEN
-
-extern void *memset(void *ptr, int, __kernel_size_t);
-extern void *memcpy(void *, const void *, __kernel_size_t);
-extern void memzero(void *ptr, __kernel_size_t n);
-extern int memcmp(const void *, const void *, __kernel_size_t);
-extern char *strchr(const char *s, int c);
-extern char *strcpy(char *dest, const char *src);
-extern int strcmp(const char *cs, const char *ct);
-extern __kernel_size_t strlen(const char *);
-
-#endif /* __ASM_ARC_STRING_H */
arch/arc/lib/Makefile +0 -7
index 12097bf3bee7..6b7fb0fdff9c 100644
@@ -10,13 +10,6 @@ obj-y += cache.o
 obj-y += cpu.o
 obj-y += interrupts.o
 obj-y += relocate.o
-obj-y += strchr-700.o
-obj-y += strcmp.o
-obj-y += strcpy-700.o
-obj-y += strlen.o
-obj-y += memcmp.o
-obj-y += memcpy-700.o
-obj-y += memset.o
 obj-y += reset.o
 obj-y += ints_low.o
 obj-y += init_helpers.o
arch/arc/lib/memcmp.S deleted +0 -123

123 lines not on this page · raw message

arch/arc/lib/memcpy-700.S deleted +0 -63

63 lines not on this page · raw message

arch/arc/lib/memset.S deleted +0 -62

62 lines not on this page · raw message

arch/arc/lib/strchr-700.S deleted +0 -141

141 lines not on this page · raw message

arch/arc/lib/strcmp.S deleted +0 -97

97 lines not on this page · raw message

arch/arc/lib/strcpy-700.S deleted +0 -67

67 lines not on this page · raw message

arch/arc/lib/strlen.S deleted +0 -80

80 lines not on this page · raw message

Signature · 1 line
2.14.3