* Move bootwrapper's strchr() and strncmp() from .h to string.S
@ 2007-08-28 4:52 David Gibson
2007-08-28 7:33 ` Geert Uytterhoeven
0 siblings, 1 reply; 2+ messages in thread
From: David Gibson @ 2007-08-28 4:52 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev
Currently the bootwrapper has implementations of strchr() and
strncmp(), but they're inlines in flatdevtree_env.h, rather than in
string.S with all the rest of the string functions. This patch moves
them to string.S.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
Paul, please apply to the for-2.6.24 branch.
Index: working-2.6/arch/powerpc/boot/string.S
===================================================================
--- working-2.6.orig/arch/powerpc/boot/string.S 2006-12-08 10:42:48.000000000 +1100
+++ working-2.6/arch/powerpc/boot/string.S 2007-08-28 14:48:52.000000000 +1000
@@ -49,6 +49,17 @@ strcat:
bne 1b
blr
+ .globl strchr
+strchr:
+ addi r3,r3,-1
+1: lbzu r0,1(r3)
+ cmpw 0,r0,r4
+ beqlr
+ cmpwi 0,r0,0
+ bne 1b
+ li r3,0
+ blr
+
.globl strcmp
strcmp:
addi r5,r3,-1
@@ -61,6 +72,19 @@ strcmp:
beq 1b
blr
+ .globl strncmp
+strncmp:
+ mtctr r5
+ addi r5,r3,-1
+ addi r4,r4,-1
+1: lbzu r3,1(r5)
+ cmpwi 1,r3,0
+ lbzu r0,1(r4)
+ subf. r3,r0,r3
+ beqlr 1
+ bdnzt eq,1b
+ blr
+
.globl strlen
strlen:
addi r4,r3,-1
Index: working-2.6/arch/powerpc/boot/string.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/string.h 2006-12-08 10:42:48.000000000 +1100
+++ working-2.6/arch/powerpc/boot/string.h 2007-08-28 14:49:14.000000000 +1000
@@ -5,7 +5,9 @@
extern char *strcpy(char *dest, const char *src);
extern char *strncpy(char *dest, const char *src, size_t n);
extern char *strcat(char *dest, const char *src);
+extern char *strchr(const char *s, int c);
extern int strcmp(const char *s1, const char *s2);
+extern int strncmp(const char *s1, const char *s2, size_t n);
extern size_t strlen(const char *s);
extern size_t strnlen(const char *s, size_t count);
Index: working-2.6/arch/powerpc/boot/flatdevtree_env.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/flatdevtree_env.h 2007-08-15 16:56:30.000000000 +1000
+++ working-2.6/arch/powerpc/boot/flatdevtree_env.h 2007-08-28 14:38:29.000000000 +1000
@@ -24,24 +24,4 @@
#define be64_to_cpu(x) (x)
#define cpu_to_be64(x) (x)
-static inline int strncmp(const char *cs, const char *ct, size_t count)
-{
- signed char __res = 0;
-
- while (count) {
- if ((__res = *cs - *ct++) != 0 || !*cs++)
- break;
- count--;
- }
- return __res;
-}
-
-static inline char *strchr(const char *s, int c)
-{
- for (; *s != (char)c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *)s;
-}
-
#endif /* _PPC_BOOT_FLATDEVTREE_ENV_H_ */
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Move bootwrapper's strchr() and strncmp() from .h to string.S
2007-08-28 4:52 Move bootwrapper's strchr() and strncmp() from .h to string.S David Gibson
@ 2007-08-28 7:33 ` Geert Uytterhoeven
0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2007-08-28 7:33 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, Paul Mackerras
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2784 bytes --]
On Tue, 28 Aug 2007, David Gibson wrote:
> Currently the bootwrapper has implementations of strchr() and
> strncmp(), but they're inlines in flatdevtree_env.h, rather than in
> string.S with all the rest of the string functions. This patch moves
^^^^^
Nice move ;-)
... replaces them by assembler versions?
> them to string.S.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>
> Paul, please apply to the for-2.6.24 branch.
>
> Index: working-2.6/arch/powerpc/boot/string.S
> ===================================================================
> --- working-2.6.orig/arch/powerpc/boot/string.S 2006-12-08 10:42:48.000000000 +1100
> +++ working-2.6/arch/powerpc/boot/string.S 2007-08-28 14:48:52.000000000 +1000
> @@ -49,6 +49,17 @@ strcat:
> bne 1b
> blr
>
> + .globl strchr
> +strchr:
> + addi r3,r3,-1
> +1: lbzu r0,1(r3)
> + cmpw 0,r0,r4
> + beqlr
> + cmpwi 0,r0,0
> + bne 1b
> + li r3,0
> + blr
> +
> .globl strcmp
> strcmp:
> addi r5,r3,-1
> @@ -61,6 +72,19 @@ strcmp:
> beq 1b
> blr
>
> + .globl strncmp
> +strncmp:
> + mtctr r5
> + addi r5,r3,-1
> + addi r4,r4,-1
> +1: lbzu r3,1(r5)
> + cmpwi 1,r3,0
> + lbzu r0,1(r4)
> + subf. r3,r0,r3
> + beqlr 1
> + bdnzt eq,1b
> + blr
> +
> .globl strlen
> strlen:
> addi r4,r3,-1
> Index: working-2.6/arch/powerpc/boot/flatdevtree_env.h
> ===================================================================
> --- working-2.6.orig/arch/powerpc/boot/flatdevtree_env.h 2007-08-15 16:56:30.000000000 +1000
> +++ working-2.6/arch/powerpc/boot/flatdevtree_env.h 2007-08-28 14:38:29.000000000 +1000
> @@ -24,24 +24,4 @@
> #define be64_to_cpu(x) (x)
> #define cpu_to_be64(x) (x)
>
> -static inline int strncmp(const char *cs, const char *ct, size_t count)
> -{
> - signed char __res = 0;
> -
> - while (count) {
> - if ((__res = *cs - *ct++) != 0 || !*cs++)
> - break;
> - count--;
> - }
> - return __res;
> -}
> -
> -static inline char *strchr(const char *s, int c)
> -{
> - for (; *s != (char)c; ++s)
> - if (*s == '\0')
> - return NULL;
> - return (char *)s;
> -}
> -
> #endif /* _PPC_BOOT_FLATDEVTREE_ENV_H_ */
With kind regards,
Geert Uytterhoeven
Software Architect
Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/
Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V.
Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-28 7:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-28 4:52 Move bootwrapper's strchr() and strncmp() from .h to string.S David Gibson
2007-08-28 7:33 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).