aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/machine/arm
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/machine/arm')
-rw-r--r--newlib/libc/machine/arm/strlen.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/newlib/libc/machine/arm/strlen.c b/newlib/libc/machine/arm/strlen.c
index 7e59e75..ac5d47d 100644
--- a/newlib/libc/machine/arm/strlen.c
+++ b/newlib/libc/machine/arm/strlen.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 ARM Ltd
+ * Copyright (c) 2008-2015 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,32 +31,12 @@
#include <string.h>
#include <limits.h>
-#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
+#if defined __OPTIMIZE_SIZE__ || defined PREFER_SIZE_OVER_SPEED
+#if defined __thumb__ && !defined __thumb2__
size_t
strlen (const char* str)
{
int scratch;
-#if defined (__thumb__) && !defined (__thumb2__)
size_t len;
asm ("mov %0, #0\n"
"1:\n\t"
@@ -66,7 +46,13 @@ strlen (const char* str)
"bne 1b"
: "=&r" (len), "=&r" (scratch) : "r" (str) : "memory", "cc");
return len - 1;
+}
+
#else
+size_t
+strlen (const char* str)
+{
+ int scratch;
const char* end;
asm ("1:\n\t"
"ldrb %1, [%0], #1\n\t"
@@ -74,13 +60,17 @@ strlen (const char* str)
"bne 1b"
: "=&r" (end), "=&r" (scratch) : "0" (str) : "memory", "cc");
return end - str - 1;
-#endif
}
#endif
-#else
-#if !(defined(_ISA_ARM_7) || defined(__ARM_ARCH_6T2__))
+#else /* defined __OPTIMIZE_SIZE__ || defined PREFER_SIZE_OVER_SPEED */
+#if defined __thumb__ && ! defined __thumb2__
+ /* Implemented in ../../string/strlen.c. */
+
+#elif defined _ISA_ARM_7 || defined __ARM_ARCH_6T2__
+ /* Implemented in strlen-armv7.S. */
+#else
size_t __attribute__((naked))
strlen (const char* str)
{