aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-10-04 07:30:05 +0000
committerUlrich Drepper <drepper@redhat.com>1999-10-04 07:30:05 +0000
commitfbda91b119b7673a4d448f0dce31766eaa65112e (patch)
tree432f48a3043ee1216216e6b93547017b954cde9c /sysdeps/i386
parentba60c6d921580bd4b1adf24506bcebfd8efdea34 (diff)
downloadglibc-fbda91b119b7673a4d448f0dce31766eaa65112e.tar
glibc-fbda91b119b7673a4d448f0dce31766eaa65112e.tar.gz
glibc-fbda91b119b7673a4d448f0dce31766eaa65112e.tar.bz2
glibc-fbda91b119b7673a4d448f0dce31766eaa65112e.zip
Update.
1999-10-04 Ulrich Drepper <drepper@cygnus.com> * include/string.h: Add __memrchr declaration. * string/string.h: Moce __memrchr declaration to include/string.h. 1999-10-03 Ulrich Drepper <drepper@cygnus.com> * string/Makefile (routines): Add memrchr. * sysdeps/generic/memrchr.c: Don't undef memchr, undef memrchr. Correct order of tests for matching bytes. * string/tester.c: Add tests for memrchr. * sysdeps/i386/i486/bits/string.h (__memrchr): Correct implementation. Start from the last character and take decrement not increment into account for correction in return line. Add memrchr alias. * sysdeps/i386/bits/string.h: Likewise.
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/bits/string.h9
-rw-r--r--sysdeps/i386/i486/bits/string.h21
2 files changed, 18 insertions, 12 deletions
diff --git a/sysdeps/i386/bits/string.h b/sysdeps/i386/bits/string.h
index 01c17db68d..b727e2bc17 100644
--- a/sysdeps/i386/bits/string.h
+++ b/sysdeps/i386/bits/string.h
@@ -319,13 +319,16 @@ __memrchr (__const void *__s, int __c, size_t __n)
("std\n\t"
"repne; scasb\n\t"
"je 1f\n\t"
- "movl $1,%0\n"
+ "orl $-1,%0\n"
"1:\tcld"
: "=D" (__res), "=&c" (__d0)
- : "a" (__c), "0" (__s), "1" (__n)
+ : "a" (__c), "0" (__s + __n - 1), "1" (__n)
: "cc");
- return __res - 1;
+ return __res + 1;
}
+# ifdef __USE_GNU
+# define memrchr(s, c, n) __memrchr (s, c, n)
+# endif
#endif
/* Return the length of S. */
diff --git a/sysdeps/i386/i486/bits/string.h b/sysdeps/i386/i486/bits/string.h
index 9b37f5898e..54e5ac4620 100644
--- a/sysdeps/i386/i486/bits/string.h
+++ b/sysdeps/i386/i486/bits/string.h
@@ -452,34 +452,37 @@ __STRING_INLINE void *
__memrchr (__const void *__s, int __c, size_t __n)
{
register unsigned long int __d0;
-#ifdef __i686__
+# ifdef __i686__
register unsigned long int __d1;
-#endif
+# endif
register void *__res;
if (__n == 0)
return NULL;
-#ifdef __i686__
+# ifdef __i686__
__asm__ __volatile__
("std\n\t"
"repne; scasb\n\t"
"cmovne %2,%0\n\t"
"cld"
: "=D" (__res), "=&c" (__d0), "=&r" (__d1)
- : "a" (__c), "0" (__s), "1" (__n), "2" (1)
+ : "a" (__c), "0" (__s + __n - 1), "1" (__n), "2" (-1)
: "cc");
-#else
+# else
__asm__ __volatile__
("std\n\t"
"repne; scasb\n\t"
"je 1f\n\t"
- "movl $1,%0\n"
+ "orl $-1,%0\n"
"1:\tcld"
: "=D" (__res), "=&c" (__d0)
- : "a" (__c), "0" (__s), "1" (__n)
+ : "a" (__c), "0" (__s + __n - 1), "1" (__n)
: "cc");
-#endif
- return __res - 1;
+# endif
+ return __res + 1;
}
+# ifdef __USE_GNU
+# define memrchr(s, c, n) __memrchr (s, c, n)
+# endif
#endif
/* Return pointer to C in S. */