Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102924858
D34673.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D34673.diff
View Options
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 <mjg@freebsd.org>
+ * 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 <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));
-}
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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 7:45 PM (13 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14722599
Default Alt Text
D34673.diff (1 KB)
Attached To
Mode
D34673: amd64: bring back asm bcmp, code shared with memcmp
Attached
Detach File
Event Timeline
Log In to Comment