diff --git a/lib/libc/amd64/string/Makefile.inc b/lib/libc/amd64/string/Makefile.inc --- a/lib/libc/amd64/string/Makefile.inc +++ b/lib/libc/amd64/string/Makefile.inc @@ -1,6 +1,7 @@ # $FreeBSD$ MDSRCS+= \ + bcmp.S \ memcmp.S \ memcpy.S \ memmove.S \ diff --git a/lib/libc/amd64/string/bcmp.S b/lib/libc/amd64/string/bcmp.S new file mode 100644 --- /dev/null +++ b/lib/libc/amd64/string/bcmp.S @@ -0,0 +1,7 @@ +/*- + * Written by Mateusz Guzik + * Public domain. + */ + +#define BCMP +#include "memcmp.S" diff --git a/lib/libc/amd64/string/bcmp.c b/lib/libc/amd64/string/bcmp.c deleted file mode 100644 --- a/lib/libc/amd64/string/bcmp.c +++ /dev/null @@ -1,16 +0,0 @@ -/*- - * Written by Mateusz Guzik - * Public domain. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -int -bcmp(const void *b1, const void *b2, size_t len) -{ - - return (memcmp(b1, b2, len)); -} diff --git a/lib/libc/amd64/string/memcmp.S b/lib/libc/amd64/string/memcmp.S --- a/lib/libc/amd64/string/memcmp.S +++ b/lib/libc/amd64/string/memcmp.S @@ -39,7 +39,11 @@ #define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ +#ifdef BCMP +ENTRY(bcmp) +#else ENTRY(memcmp) +#endif xorl %eax,%eax 10: cmpq $16,%rdx @@ -143,8 +147,25 @@ /* * Mismatch was found. - * - * Before we compute it we narrow down the range (16 -> 8 -> 4 bytes). + */ +#ifdef BCMP + ALIGN_TEXT +10320016: +10320000: +10081608: +10163224: +10163216: +10163208: +10040804: +80: +1: + leal 1(%eax),%eax + ret +END(bcmp) +#else +/* + * We need to compute the difference between strings. + * Start with narrowing the range down (16 -> 8 -> 4 bytes). */ ALIGN_TEXT 10320016: @@ -214,5 +235,6 @@ subl %r8d,%eax ret END(memcmp) +#endif .section .note.GNU-stack,"",%progbits