summaryrefslogtreecommitdiffstats
path: root/newlib/libc/machine/xscale/memset.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2000-11-30 01:57:27 +0000
committerNick Clifton <nickc@redhat.com>2000-11-30 01:57:27 +0000
commit0ffc3b94a0cc452f63eb977633e844dae8539f3a (patch)
treedf045c028255a9399e7a5c489a946561619cac3b /newlib/libc/machine/xscale/memset.c
parent09872ef885e9307dc41eb41fdc08bdb1f8ffef7a (diff)
downloadcygnal-0ffc3b94a0cc452f63eb977633e844dae8539f3a.tar.gz
cygnal-0ffc3b94a0cc452f63eb977633e844dae8539f3a.tar.bz2
cygnal-0ffc3b94a0cc452f63eb977633e844dae8539f3a.zip
Add support for Intel's XScale processor
Diffstat (limited to 'newlib/libc/machine/xscale/memset.c')
-rw-r--r--newlib/libc/machine/xscale/memset.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/newlib/libc/machine/xscale/memset.c b/newlib/libc/machine/xscale/memset.c
new file mode 100644
index 000000000..bfd0f0d47
--- /dev/null
+++ b/newlib/libc/machine/xscale/memset.c
@@ -0,0 +1,80 @@
+#if defined __thumb__
+
+#include "../../string/memset.c"
+
+#else
+
+#include <string.h>
+#include "xscale.h"
+
+void *
+memset (void *dst, int c, size_t len)
+{
+ int dummy;
+ asm volatile ("tst %0, #0x3"
+#ifndef __OPTIMIZE_SIZE__
+"
+ beq 1f
+ b 2f
+0:
+ strb %1, [%0], #1
+ tst %0, #0x3
+ beq 1f
+2:
+ movs r3, %2
+ sub %2, %2, #1
+ bne 0b
+1:
+ cmp %2, #0x3
+ bls 2f
+ and %1, %1, #0xff
+ orr lr, %1, %1, asl #8
+ cmp %2, #0xf
+ orr lr, lr, lr, asl #16
+ bls 1f
+ mov r3, lr
+ mov r4, lr
+ mov r5, lr
+0:
+ sub %2, %2, #16
+ stmia %0!, { r3, r4, r5, lr }
+ cmp %2, #0xf
+ bhi 0b
+1:
+ cmp %2, #0x7
+ bls 1f
+ mov r3, lr
+0:
+ sub %2, %2, #8
+ stmia %0!, { r3, lr }
+ cmp %2, #0x7
+ bhi 0b
+1:
+ cmp %2, #0x3
+ bls 2f
+0:
+ sub %2, %2, #4
+ str lr, [%0], #4
+ cmp %2, #0x3
+ bhi 0b
+"
+#endif /* !__OPTIMIZE_SIZE__ */
+"
+2:
+ movs r3, %2
+ sub %2, %2, #1
+ beq 1f
+0:
+ movs r3, %2
+ sub %2, %2, #1
+ strb %1, [%0], #1
+ bne 0b
+1:"
+
+ : "=&r" (dummy), "=&r" (c), "=&r" (len)
+ : "0" (dst), "1" (c), "2" (len)
+ : "memory", "r3", "r4", "r5", "lr");
+ return dst;
+}
+
+#endif