Page MenuHomeFreeBSD

D15368.1779278545.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D15368.1779278545.diff

Index: lib/libc/powerpc64/string/Makefile.inc
===================================================================
--- /dev/null
+++ lib/libc/powerpc64/string/Makefile.inc
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+MDSRCS+= \
+ strcpy.S
Index: lib/libc/powerpc64/string/strcpy.S
===================================================================
--- /dev/null
+++ lib/libc/powerpc64/string/strcpy.S
@@ -0,0 +1,143 @@
+/*-
+ * Copyright (c) 2018 Instituto de Pesquisas Eldorado
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+#if 0
+ RCSID("$NetBSD: strcpy.S,v 1.0 2018/05/08 13:00:49 lbianc Exp $")
+#endif
+
+ENTRY(strcpy)
+ std 3,-8(1)
+
+
+ andi. 0,4,0x7
+ beq .Lcopy_dw /* Check if address is aligned. */
+
+/* Align the reading address. */
+.Lalignment:
+ lbz 0,0(4)
+ cmpdi cr7,0,0
+ stb 0,0(3)
+ beq cr7,.Lexit
+ addi 4,4,1
+ addi 3,3,1
+ andi. 0,4,0x7
+ bne .Lalignment
+
+/* Copy by double word with aligned address. */
+.Lcopy_dw:
+ ld 0,0(4)
+ xor 6,6,6
+ cmpb 5,0,6
+ cmpdi cr7,5,0
+ bne cr7,.Lcheck_zero
+ addi 3,3,-8
+.Lcopy_dw_loop:
+ stdu 0,8(3)
+ ldu 0,8(4)
+ cmpb 5,0,6
+ cmpdi cr7,5,0
+ beq cr7,.Lcopy_dw_loop
+
+ addi 3,3,8 /* Fix r3 to use std instruction. */
+/* Find where the zero is located. */
+.Lcheck_zero:
+ rldicr. 5,0,0,7
+ beq .Lfound_on_byte_1
+ rldicr. 7,0,8,7
+ beq .Lfound_on_byte_2
+ rldicr. 7,0,16,7
+ beq .Lfound_on_byte_3
+ rldicr. 7,0,24,7
+ beq .Lfound_on_byte_4
+ andis. 7,0,0xff00
+ beq .Lfound_on_byte_5
+ andis. 7,0,0xff
+ beq .Lfound_on_byte_6
+ andi. 7,0,0xff00
+ beq .Lfound_on_byte_7
+
+/* Treatment of each byte where the zero my be found, saving
+ the correct register data. */
+.Lfound_on_byte_8:
+ std 0,0(3)
+ b .Lexit
+
+.Lfound_on_byte_7:
+ srdi 6,0,32
+ stw 6,0(3)
+ srdi 6,0,16
+ sth 6,4(3)
+ srdi 6,0,8
+ stb 6,6(3)
+ b .Lexit
+
+.Lfound_on_byte_6:
+ srdi 6,0,32
+ stw 6,0(3)
+ srdi 6,0,16
+ sth 6,4(3)
+ b .Lexit
+
+.Lfound_on_byte_5:
+ srdi 6,0,32
+ stw 6,0(3)
+ srdi 6,0,24
+ stb 6,4(3)
+ b .Lexit
+
+.Lfound_on_byte_4:
+ srdi 6,0,32
+ stw 6,0(3)
+ b .Lexit
+
+.Lfound_on_byte_3:
+ srdi 6,0,48
+ sth 6,0(3)
+ srdi 6,0,40
+ stb 6,2(3)
+ b .Lexit
+
+.Lfound_on_byte_2:
+ srdi 6,0,48
+ sth 6,0(3)
+ b .Lexit
+
+.Lfound_on_byte_1:
+ srdi 6,0,56
+ stb 6,0(3)
+.Lexit:
+ xor 0,0,0 /* Erase data from register 0. */
+ ld 3,-8(1) /* Load destination address. */
+ blr
+
+END(strcpy)
+
+ .section .note.GNU-stack,"",%progbits

File Metadata

Mime Type
text/plain
Expires
Wed, May 20, 12:02 PM (14 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28753724
Default Alt Text
D15368.1779278545.diff (3 KB)

Event Timeline