Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F131872945
D29067.id86309.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D29067.id86309.diff
View Options
diff --git a/lib/libc/powerpc64/string/Makefile.inc b/lib/libc/powerpc64/string/Makefile.inc
--- a/lib/libc/powerpc64/string/Makefile.inc
+++ b/lib/libc/powerpc64/string/Makefile.inc
@@ -12,12 +12,7 @@
memmove_resolver.c \
strncpy_arch_2_05.S \
strncpy.c \
- strncpy_resolver.c
-
-# XXX Port strcpy to LE.
-.if ${MACHINE_ARCH} == "powerpc64"
-MDSRCS+= \
+ strncpy_resolver.c \
strcpy_arch_2_05.S \
strcpy.c \
strcpy_resolver.c
-.endif
diff --git a/lib/libc/powerpc64/string/strcpy_arch_2_05.S b/lib/libc/powerpc64/string/strcpy_arch_2_05.S
--- a/lib/libc/powerpc64/string/strcpy_arch_2_05.S
+++ b/lib/libc/powerpc64/string/strcpy_arch_2_05.S
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#if !defined(__BIG_ENDIAN__)
-#error "Optimized SRTCPY is only supported by big-endian architecture!"
-#endif
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
@@ -71,6 +68,7 @@
beq cr7,.Lcopy_dw_loop
addi %r8,%r8,8 /* Forward r8 to use std instruction. */
+#if defined(__BIG_ENDIAN__)
/* Find where the zero is located. */
.Lcheck_zero:
rldicr. %r5,%r0,0,7
@@ -136,6 +134,68 @@
.Lfound_on_byte_0:
srdi %r6,%r0,56
stb %r6,0(%r8)
+#elif defined(__LITTLE_ENDIAN__)
+/* Find where the zero is located. */
+.Lcheck_zero:
+ andi. %r7,%r0,0xff
+ beq .Lfound_on_byte_0
+ andi. %r7,%r0,0xff00
+ beq .Lfound_on_byte_1
+ andis. %r7,%r0,0xff
+ beq .Lfound_on_byte_2
+ andis. %r7,%r0,0xff00
+ beq .Lfound_on_byte_3
+ rldicr. %r7,%r0,24,7
+ beq .Lfound_on_byte_4
+ rldicr. %r7,%r0,16,7
+ beq .Lfound_on_byte_5
+ rldicr. %r7,%r0,8,7
+ beq .Lfound_on_byte_6
+
+/* Copy the last string bytes according to the string end position. */
+.Lfound_on_byte_7:
+ std %r0,0(%r8)
+ b .Lexit
+
+.Lfound_on_byte_6:
+ stw %r0,0(%r8)
+ srdi %r6,%r0,32
+ sth %r6,4(%r8)
+ srdi %r6,%r0,48
+ stb %r6,6(%r8)
+ b .Lexit
+
+.Lfound_on_byte_5:
+ stw %r0,0(%r8)
+ srdi %r6,%r0,32
+ sth %r6,4(%r8)
+ b .Lexit
+
+.Lfound_on_byte_4:
+ stw %r0,0(%r8)
+ srdi %r6,%r0,32
+ stb %r6,4(%r8)
+ b .Lexit
+
+.Lfound_on_byte_3:
+ stw %r0,0(%r8)
+ b .Lexit
+
+.Lfound_on_byte_2:
+ sth %r0,0(%r8)
+ srdi %r6,%r0,16
+ stb %r6,2(%r8)
+ b .Lexit
+
+.Lfound_on_byte_1:
+ sth %r0,0(%r8)
+ b .Lexit
+
+.Lfound_on_byte_0:
+ stb %r0,0(%r8)
+#else
+#error "Unable to determine Endianness"
+#endif
.Lexit:
blr
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 12, 9:05 PM (6 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23641127
Default Alt Text
D29067.id86309.diff (2 KB)
Attached To
Mode
D29067: powerpc64le: port optimized strcpy for LE version of processor
Attached
Detach File
Event Timeline
Log In to Comment