Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/string/strlen.c')
-rw-r--r--newlib/libc/string/strlen.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/newlib/libc/string/strlen.c b/newlib/libc/string/strlen.c
index a796d2738..4249e14c7 100644
--- a/newlib/libc/string/strlen.c
+++ b/newlib/libc/string/strlen.c
@@ -1,7 +1,7 @@
-/*
+/*
FUNCTION
<<strlen>>---character string length
-
+
INDEX
strlen
@@ -57,32 +57,32 @@ size_t
_DEFUN (strlen, (str),
_CONST char *str)
{
+#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
_CONST char *start = str;
-#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
+ while (*str)
+ str++;
+
+ return str - start;
+#else
+ _CONST char *start = str;
unsigned long *aligned_addr;
- /* Align the pointer, so we can search a word at a time. */
- while (UNALIGNED (str))
+ if (!UNALIGNED (str))
{
- if (!*str)
- return str - start;
- str++;
+ /* If the string is word-aligned, we can check for the presence of
+ a null in each word-sized block. */
+ aligned_addr = (unsigned long*)str;
+ while (!DETECTNULL (*aligned_addr))
+ aligned_addr++;
+
+ /* Once a null is detected, we check each byte in that block for a
+ precise position of the null. */
+ str = (char*)aligned_addr;
}
-
- /* If the string is word-aligned, we can check for the presence of
- a null in each word-sized block. */
- aligned_addr = (unsigned long *)str;
- while (!DETECTNULL (*aligned_addr))
- aligned_addr++;
-
- /* Once a null is detected, we check each byte in that block for a
- precise position of the null. */
- str = (char *) aligned_addr;
-
-#endif /* not PREFER_SIZE_OVER_SPEED */
-
+
while (*str)
str++;
return str - start;
+#endif /* not PREFER_SIZE_OVER_SPEED */
}