From 6c106c856412c027ff78a9661386b3a42a52cf36 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 19 Dec 2008 13:51:38 +0000 Subject: strncat: shorter version for i386, add small embedded test memchr: add small embedded test strnlen: make small embedded test easier to use strncmp: reformat assembly to make it readable, no code changes (verified with objdump) text data bss dec hex filename - 46 0 0 46 2e libc/string/i386/strncat.os + 39 0 0 39 27 libc/string/i386/strncat.os --- libc/string/i386/strncmp.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'libc/string/i386/strncmp.c') diff --git a/libc/string/i386/strncmp.c b/libc/string/i386/strncmp.c index a14bb503b..bfb20c307 100644 --- a/libc/string/i386/strncmp.c +++ b/libc/string/i386/strncmp.c @@ -32,27 +32,28 @@ #include -/* Experimentally off - libc_hidden_proto(strncmp) */ +#undef strncmp int strncmp(const char *cs, const char *ct, size_t count) { - register int __res; - int d0, d1, d2; - __asm__ __volatile__( - "incl %3\n" - "1:\tdecl %3\n\t" - "jz 2f\n" - "lodsb\n\t" - "scasb\n\t" - "jne 3f\n\t" - "testb %%al,%%al\n\t" - "jne 1b\n" - "2:\txorl %%eax,%%eax\n\t" - "jmp 4f\n" - "3:\tsbbl %%eax,%%eax\n\t" - "orb $1,%%al\n" - "4:" - :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) - :"1" (cs),"2" (ct),"3" (count)); - return __res; + int eax; + int esi, edi, ecx; + __asm__ __volatile__( + " incl %%ecx\n" + "1: decl %%ecx\n" + " jz 2f\n" + " lodsb\n" + " scasb\n" + " jne 3f\n" + " testb %%al, %%al\n" + " jnz 1b\n" + "2: xorl %%eax, %%eax\n" + " jmp 4f\n" + "3: sbbl %%eax, %%eax\n" + " orb $1, %%al\n" + "4:\n" + : "=a" (eax), "=&S" (esi), "=&D" (edi), "=&c" (ecx) + : "1" (cs), "2" (ct), "3" (count) + ); + return eax; } libc_hidden_weak(strncmp) -- cgit v1.2.3