diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2010-05-18 04:15:21 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-05-21 03:31:08 -0400 |
commit | ca5d0674c37840366f04a7bbfbf78e7b5f3ce0a4 (patch) | |
tree | 14f6b84f0eca9909108d0dc222d0fb64fc437ee9 /arch/powerpc/lib | |
parent | 7358650e9e9a81c854dc4582b4193eb5ea500bf6 (diff) |
powerpc: Fix string library functions
The powerpc strncmp implementation does not correctly handle a zero
length, despite the claim in 0119536cd314ef95553604208c25bc35581f7f0a
(Add hand-coded assembly strcmp).
Additionally, all the length arguments are size_t, not int, so use
PPC_LCMPI and eq instead of cmpwi and le throughout.
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/lib')
-rw-r--r-- | arch/powerpc/lib/string.S | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S index 3ac0cd3a5373..455881a5563f 100644 --- a/arch/powerpc/lib/string.S +++ b/arch/powerpc/lib/string.S | |||
@@ -28,7 +28,7 @@ _GLOBAL(strcpy) | |||
28 | /* This clears out any unused part of the destination buffer, | 28 | /* This clears out any unused part of the destination buffer, |
29 | just as the libc version does. -- paulus */ | 29 | just as the libc version does. -- paulus */ |
30 | _GLOBAL(strncpy) | 30 | _GLOBAL(strncpy) |
31 | cmpwi 0,r5,0 | 31 | PPC_LCMPI 0,r5,0 |
32 | beqlr | 32 | beqlr |
33 | mtctr r5 | 33 | mtctr r5 |
34 | addi r6,r3,-1 | 34 | addi r6,r3,-1 |
@@ -39,7 +39,7 @@ _GLOBAL(strncpy) | |||
39 | bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */ | 39 | bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */ |
40 | bnelr /* if we didn't hit a null char, we're done */ | 40 | bnelr /* if we didn't hit a null char, we're done */ |
41 | mfctr r5 | 41 | mfctr r5 |
42 | cmpwi 0,r5,0 /* any space left in destination buffer? */ | 42 | PPC_LCMPI 0,r5,0 /* any space left in destination buffer? */ |
43 | beqlr /* we know r0 == 0 here */ | 43 | beqlr /* we know r0 == 0 here */ |
44 | 2: stbu r0,1(r6) /* clear it out if so */ | 44 | 2: stbu r0,1(r6) /* clear it out if so */ |
45 | bdnz 2b | 45 | bdnz 2b |
@@ -70,8 +70,8 @@ _GLOBAL(strcmp) | |||
70 | blr | 70 | blr |
71 | 71 | ||
72 | _GLOBAL(strncmp) | 72 | _GLOBAL(strncmp) |
73 | PPC_LCMPI r5,0 | 73 | PPC_LCMPI 0,r5,0 |
74 | ble- 2f | 74 | beq- 2f |
75 | mtctr r5 | 75 | mtctr r5 |
76 | addi r5,r3,-1 | 76 | addi r5,r3,-1 |
77 | addi r4,r4,-1 | 77 | addi r4,r4,-1 |
@@ -94,8 +94,8 @@ _GLOBAL(strlen) | |||
94 | blr | 94 | blr |
95 | 95 | ||
96 | _GLOBAL(memcmp) | 96 | _GLOBAL(memcmp) |
97 | cmpwi 0,r5,0 | 97 | PPC_LCMPI 0,r5,0 |
98 | ble- 2f | 98 | beq- 2f |
99 | mtctr r5 | 99 | mtctr r5 |
100 | addi r6,r3,-1 | 100 | addi r6,r3,-1 |
101 | addi r4,r4,-1 | 101 | addi r4,r4,-1 |
@@ -108,8 +108,8 @@ _GLOBAL(memcmp) | |||
108 | blr | 108 | blr |
109 | 109 | ||
110 | _GLOBAL(memchr) | 110 | _GLOBAL(memchr) |
111 | cmpwi 0,r5,0 | 111 | PPC_LCMPI 0,r5,0 |
112 | ble- 2f | 112 | beq- 2f |
113 | mtctr r5 | 113 | mtctr r5 |
114 | addi r3,r3,-1 | 114 | addi r3,r3,-1 |
115 | 1: lbzu r0,1(r3) | 115 | 1: lbzu r0,1(r3) |