amd64: bring back asm bcmp, shared with memcmp
Turns out clang converts "memcmp(foo, bar, len) == 0" and similar to bcmp calls. Reviewed by: emaste (previous version), jhb (previous version) Differential Revision: https://reviews.freebsd.org/D34673
This commit is contained in:
parent
8f1543785f
commit
fbc002cb72
@ -1,6 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
MDSRCS+= \
|
||||
bcmp.S \
|
||||
memcmp.S \
|
||||
memcpy.S \
|
||||
memmove.S \
|
||||
|
7
lib/libc/amd64/string/bcmp.S
Normal file
7
lib/libc/amd64/string/bcmp.S
Normal file
@ -0,0 +1,7 @@
|
||||
/*-
|
||||
* Written by Mateusz Guzik <mjg@freebsd.org>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#define BCMP
|
||||
#include "memcmp.S"
|
@ -1,16 +0,0 @@
|
||||
/*-
|
||||
* Written by Mateusz Guzik <mjg@freebsd.org>
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
bcmp(const void *b1, const void *b2, size_t len)
|
||||
{
|
||||
|
||||
return (memcmp(b1, b2, len));
|
||||
}
|
@ -39,7 +39,11 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#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 @@ ENTRY(memcmp)
|
||||
|
||||
/*
|
||||
* 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 @@ ENTRY(memcmp)
|
||||
subl %r8d,%eax
|
||||
ret
|
||||
END(memcmp)
|
||||
#endif
|
||||
|
||||
.section .note.GNU-stack,"",%progbits
|
||||
|
Loading…
Reference in New Issue
Block a user