Add lib_mips/string.c and stop using inline asm functions.
PATCH 2/2 Add lib_mips/string.c and stop using inline asm functions.
[MIPS] Add lib_mips/string.c and stop using inline asm functions.
From: Shinya Kuribayashi <[email protected]>
We MIPS stop using inline string functions as other ARCHs do so, since the optimized inline asm versions are not small.
This change was triggered by a following MIPS build error:
common/libcommon.a(exports.o)(.text+0xdc): In function `jumptable_init':common/exports.c:32: undefined reference to `strcmp'
make: *** [u-boot] Error 1
---
include/asm-mips/string.h | 18 +++++++ lib_mips/Makefile | 2 - lib_mips/string.c | 122 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletions(-)
include/asm-mips/string.h +18 -0
@@ -10,6 +10,12 @@#ifndef _ASM_STRING_H#define _ASM_STRING_H +/* +* We don't do inline string functions, since the +* optimised inline asm versions are not small. +* +* All the following inline asm functions are moved to lib_mips/string.c. +*/ /* * Most of the inline functions are rather naive implementations so I just
@@ -20,6 +26,8 @@ #ifndef IN_STRING_C #define __HAVE_ARCH_STRCPY +extern char *strcpy(char *__dest, __const__ char *__src); +#if 0 static __inline__ char *strcpy(char *__dest, __const__ char *__src) { char *__xdest = __dest;
@@ -40,8 +48,11 @@ static __inline__ char *strcpy(char *__dest, __const__ char *__src)return __xdest; } +#endif #define __HAVE_ARCH_STRNCPY +extern char *strncpy(char *__dest, __const__ char *__src, size_t __n); +#if 0 static __inline__ char *strncpy(char *__dest, __const__ char *__src, size_t __n) {char *__xdest = __dest;
@@ -68,8 +79,11 @@ static __inline__ char *strncpy(char *__dest, __const__ char *__src, size_t __n)return __xdest; } +#endif #define __HAVE_ARCH_STRCMP +extern int strcmp(__const__ char *__cs, __const__ char *__ct); +#if 0 static __inline__ int strcmp(__const__ char *__cs, __const__ char *__ct) {int __res;
@@ -96,10 +110,13 @@ static __inline__ int strcmp(__const__ char *__cs, __const__ char *__ct)return __res; } +#endif #endif /* !defined(IN_STRING_C) */ #define __HAVE_ARCH_STRNCMP +extern int strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count); +#if 0 static __inline__int strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count) {
@@ -129,6 +146,7 @@ strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count)return __res; } +#endif #endif /* CONFIG_32BIT */ /*
lib_mips/Makefile +1 -1
@@ -27,7 +27,7 @@ LIB = $(obj)lib$(ARCH).a SOBJS = -COBJS = board.o time.o mips_linux.o +COBJS = board.o string.o time.o mips_linux.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
lib_mips/string.c new file +122 -0
122 lines not on this page · raw message
PATCH 2/2 Add lib_mips/string.c and stop using inline asm functions.
Quoted 6 lines · In message <[email protected]> you wrote:
[MIPS] Add
lib_mips/string.cand stop using inline asm functions.From: Shinya Kuribayashi <[email protected]>
We MIPS stop using inline string functions as other ARCHs do so, since the optimized inline asm versions are not small.
I agree with this change in general, but the implementation looks broken to me.
include/asm-mips/string.h line 18
Quoted 11 lines
+++
b/include/asm-mips/string.hinclude/asm-mips/string.h +6
-0@@ -10,6 +10,12 @@#ifndef _ASM_STRING_H#define _ASM_STRING_H +/* +* We don't do inline string functions, since the +* optimised inline asm versions are not small. +* +* All the following inline asm functions are moved to lib_mips/string.c. +*/
Moving *inline* functions to lib_mips/string.c makes no sense to me.
include/asm-mips/string.h static __inline__ char *strcpy(char *__dest, __const__ char *__src) · line 51
Quoted 11 lines
include/asm-mips/string.h +3
-0#define __HAVE_ARCH_STRCPY +extern char *strcpy(char *__dest, __const__ char *__src); +#if 0 static __inline__ char *strcpy(char *__dest, __const__ char *__src) {char *__xdest = __dest;@@ -40,8 +48,11 @@ static __inline__ char *strcpy(char *__dest, __const__ char *__src) return __xdest; } +#endif
Please don't do this. Instead of "#if 0", please remove the code.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A failure will not appear until a unit has passed final inspection.