diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-20 14:34:19 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-20 14:34:19 +0000 |
commit | 7dd438230613f3a29babf22543ee9ed89b8828d1 (patch) | |
tree | 212ad123e170bf3ee27b277aae54a67f9f17a0e0 /libc/string/i386/rawmemchr.c | |
parent | 1d5c6ff2a4e8624a24165a9f3469b43113447b9d (diff) |
libc/string/i386/rawmemchr.c: i386 version, adapted from strlen()
libc/string/i386/strlen.c: small optimization, same code size)
text data bss dec hex filename
- 240449 1759 11960 254168 3e0d8 lib/libuClibc-0.9.30-svn.so
+ 240339 1759 11960 254058 3e06a lib/libuClibc-0.9.30-svn.so
Diffstat (limited to 'libc/string/i386/rawmemchr.c')
-rw-r--r-- | libc/string/i386/rawmemchr.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libc/string/i386/rawmemchr.c b/libc/string/i386/rawmemchr.c new file mode 100644 index 000000000..be0b142c3 --- /dev/null +++ b/libc/string/i386/rawmemchr.c @@ -0,0 +1,24 @@ +/* + * Adapted from strlen.c code + * + * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <string.h> + +#undef rawmemchr +void *rawmemchr(const void *s, int c) +{ + void *eax; + int ecx, edi; + __asm__ __volatile__( + " repne; scasb\n" + " leal -1(%%edi), %%eax\n" + : "=&c" (ecx), "=&D" (edi), "=&a" (eax) + : "0" (0xffffffff), "1" (s), "2" (c) + ); + return eax; +} +libc_hidden_def(rawmemchr) |