diff options
author | Roland McGrath <roland@gnu.org> | 1999-10-04 05:13:05 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1999-10-04 05:13:05 +0000 |
commit | ca74785646503695c49b592aa7dac8f27b3567fe (patch) | |
tree | 7a4f8ad087d52ecf3970d12701916400f17cbf9d /sysdeps/i386/bits | |
parent | c8f3e6db60f54ef53c5b68fcc4cbe060fff41741 (diff) | |
download | glibc-ca74785646503695c49b592aa7dac8f27b3567fe.tar.gz glibc-ca74785646503695c49b592aa7dac8f27b3567fe.tar.xz glibc-ca74785646503695c49b592aa7dac8f27b3567fe.zip |
1999-10-04 Roland McGrath <roland@baalperazim.frob.com>
* sysdeps/generic/memrchr.c: New file, adapted from memchr.c. * sysdeps/i386/bits/string.h (__memrchr): New function. * string/string.h: Declare memrchr, __memrchr. * manual/string.texi (Search Functions): Document memrchr.
Diffstat (limited to 'sysdeps/i386/bits')
-rw-r--r-- | sysdeps/i386/bits/string.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sysdeps/i386/bits/string.h b/sysdeps/i386/bits/string.h index 44d6f8ba43..6fc78b3799 100644 --- a/sysdeps/i386/bits/string.h +++ b/sysdeps/i386/bits/string.h @@ -305,6 +305,27 @@ memchr (__const void *__s, int __c, size_t __n) } #endif +#define _HAVE_STRING_ARCH_memrchr 1 +#ifndef _FORCE_INLINES +__STRING_INLINE void * +__memrchr (__const void *__s, int __c, size_t __n) +{ + register unsigned long int __d0; + register void *__res; + if (__n == 0) + return NULL; + __asm__ __volatile__ + ("std\n\t" + "repne; scasb\n\t" + "je 1f\n\t" + "movl $1,%0\n" + "1:" + : "=D" (__res), "=&c" (__d0) + : "a" (__c), "0" (__s), "1" (__n)); + return __res - 1; +} +#endif + /* Return the length of S. */ #define _HAVE_STRING_ARCH_strlen 1 #ifndef _FORCE_INLINES |