summaryrefslogtreecommitdiff
path: root/libc/string/bfin/memset.S
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2007-09-15 11:04:21 +0000
committerMike Frysinger <vapier@gentoo.org>2007-09-15 11:04:21 +0000
commit7efe92d0cadd12d3316939474f56a3f6e727a0b0 (patch)
tree1091149e7e94e1de15889d40637d5d3ca1add2f5 /libc/string/bfin/memset.S
parent953e7478a36597f227aeb487c97c03005a4a5f71 (diff)
pull from Blackfin repo: cleanup string funcs
Diffstat (limited to 'libc/string/bfin/memset.S')
-rw-r--r--libc/string/bfin/memset.S88
1 files changed, 49 insertions, 39 deletions
diff --git a/libc/string/bfin/memset.S b/libc/string/bfin/memset.S
index bd8eb4b6a..c8ee0835f 100644
--- a/libc/string/bfin/memset.S
+++ b/libc/string/bfin/memset.S
@@ -1,5 +1,5 @@
/* memset.S
- * Copyright (C) 2003, 2005, 2006 Analog Devices Inc., All Rights Reserved.
+ * Copyright (C) 2003-2007 Analog Devices Inc., All Rights Reserved.
*
* This file is subject to the terms and conditions of the GNU Library General
* Public License. See the file "COPYING.LIB" in the main directory of this
@@ -9,6 +9,8 @@
* http://www.analog.com/processors/resources/crosscore/visualDspDevSoftware.html
*/
+#include <sysdep.h>
+
/* void *memset(void *s, int c, size_t n);
* R0 = address (s) (leave unchanged to form result)
* R1 = filler byte (c)
@@ -21,66 +23,74 @@
.align 2
-.global _memset
-.type _memset, STT_FUNC
-_memset:
- P0 = R0 ; // P0 = address
- P2 = R2 ; // P2 = count
- R3 = R0 + R2; // end
+/* We have to bypass the libc-symbols.h machinery to make sure we get
+ * a weak symbol for memcpy (some crummy gcc tests want to redefine it).
+ */
+.global ___GI_memset
+.type ___GI_memset, STT_FUNC
+___GI_memset:
+ P0 = R0 ; /* P0 = address */
+ P2 = R2 ; /* P2 = count */
+ R3 = R0 + R2; /* end */
CC = R2 <= 7(IU);
- IF CC JUMP too_small;
- R1 = R1.B (Z); // R1 = fill char
+ IF CC JUMP .Ltoo_small;
+ R1 = R1.B (Z); /* R1 = fill char */
R2 = 3;
- R2 = R0 & R2; // addr bottom two bits
- CC = R2 == 0; // AZ set if zero.
- IF !CC JUMP force_align ; // Jump if addr not aligned.
+ R2 = R0 & R2; /* addr bottom two bits */
+ CC = R2 == 0; /* AZ set if zero. */
+ IF !CC JUMP .Lforce_align ; /* Jump if addr not aligned. */
-aligned:
- P1 = P2 >> 2; // count = n/4
- R2 = R1 << 8; // create quad filler
+.Laligned:
+ P1 = P2 >> 2; /* count = n/4 */
+ R2 = R1 << 8; /* create quad filler */
R2.L = R2.L + R1.L(NS);
R2.H = R2.L + R1.H(NS);
P2 = R3;
- LSETUP (quad_loop , quad_loop) LC0=P1;
-quad_loop:
+ LSETUP (.Lquad_loop , .Lquad_loop) LC0=P1;
+.Lquad_loop:
[P0++] = R2;
CC = P0 == P2;
- IF !CC JUMP bytes_left;
+ IF !CC JUMP .Lbytes_left;
RTS;
-bytes_left:
- R2 = R3; // end point
- R3 = P0; // current position
- R2 = R2 - R3; // bytes left
+.Lbytes_left:
+ R2 = R3; /* end point */
+ R3 = P0; /* current position */
+ R2 = R2 - R3; /* bytes left */
P2 = R2;
-too_small:
- CC = P2 == 0; //Check zero count
- IF CC JUMP finished; // Unusual
+.Ltoo_small:
+ CC = P2 == 0; /* Check zero count */
+ IF CC JUMP .Lfinished; /* Unusual */
-bytes: LSETUP (byte_loop , byte_loop) LC0=P2;
-byte_loop: B[P0++] = R1;
+.Lbytes:
+ LSETUP (.Lbyte_loop , .Lbyte_loop) LC0=P2;
+.Lbyte_loop:
+ B[P0++] = R1;
-finished:
+.Lfinished:
RTS;
-force_align:
- CC = BITTST (R0, 0 ); // odd byte
+.Lforce_align:
+ CC = BITTST (R0, 0); /* odd byte */
R0 = 4;
R0 = R0 - R2;
P1 = R0;
- R0 = P0; // Recover return address
- IF !CC JUMP skip1;
+ R0 = P0; /* Recover return address */
+ IF !CC JUMP .Lskip1;
B[P0++] = R1;
-skip1:
- CC = R2 <= 2; // 2 bytes
- P2 -= P1; // reduce count
- IF !CC JUMP aligned;
+.Lskip1:
+ CC = R2 <= 2; /* 2 bytes */
+ P2 -= P1; /* reduce count */
+ IF !CC JUMP .Laligned;
B[P0++] = R1;
B[P0++] = R1;
- JUMP aligned;
-.size _memset,.-_memset
+ JUMP .Laligned;
+
+.size ___GI_memset,.-___GI_memset
-libc_hidden_def (memset)
+.hidden ___GI_memset
+.weak _memset
+.set _memset,___GI_memset