summaryrefslogtreecommitdiffstats
path: root/newlib/libc/machine/arm/strlen.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/machine/arm/strlen.c')
-rw-r--r--newlib/libc/machine/arm/strlen.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/newlib/libc/machine/arm/strlen.c b/newlib/libc/machine/arm/strlen.c
index b8de22994..7e59e755d 100644
--- a/newlib/libc/machine/arm/strlen.c
+++ b/newlib/libc/machine/arm/strlen.c
@@ -34,6 +34,24 @@
#if defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED) || \
(defined (__thumb__) && !defined (__thumb2__))
+# if !defined (PREFER_SIZE_OVER_SPEED) && !defined (__OPTIMIZE_SIZE__)
+/* Thumb1 only variant.
+ If speed is preferred, the strlen() function in ../../string/strlen.c
+ will be used.
+
+ Leave this field blank. So the strlen() is not defined, and this will
+ automatically pull in the default C definition of strlen() from
+ ../../string/strlen.c. No need to include this file explicitely.
+ The lib_a-strlen.o will not be generated, so it won't replace the default
+ lib_a-strlen.o which is generated by ../../string/strlen.c. See the
+ commands in configure.in and Makefile.am for more details.
+
+ However, if we need to rewrite this function to be more efficient,
+ we can add the corresponding assembly code into this field and change
+ the commands in configure.in and Makefile.am to allow the corresponding
+ lib_a-strlen.o to be generated.
+*/
+# else
size_t
strlen (const char* str)
{
@@ -43,7 +61,7 @@ strlen (const char* str)
asm ("mov %0, #0\n"
"1:\n\t"
"ldrb %1, [%2, %0]\n\t"
- "add %0, %0, #1\n\t"
+ "add %0, %0, #1\n\t"
"cmp %1, #0\n\t"
"bne 1b"
: "=&r" (len), "=&r" (scratch) : "r" (str) : "memory", "cc");
@@ -58,6 +76,7 @@ strlen (const char* str)
return end - str - 1;
#endif
}
+#endif
#else
#if !(defined(_ISA_ARM_7) || defined(__ARM_ARCH_6T2__))