Fix LP64 builds after OpenBSD string changes.
Change-Id: I07202f6484e716d153d0387fcfc023e119438251
diff --git a/libc/arch-arm64/arm64.mk b/libc/arch-arm64/arm64.mk
index a0eb954..76c610a 100644
--- a/libc/arch-arm64/arm64.mk
+++ b/libc/arch-arm64/arm64.mk
@@ -5,7 +5,7 @@
bionic/memchr.c \
bionic/__memcmp16.cpp \
bionic/memcmp.c \
- bionic/memcpy.c \
+ bionic/memcpy.cpp \
bionic/memmove.c \
bionic/memrchr.c \
bionic/memset.c \
diff --git a/libc/arch-x86_64/x86_64.mk b/libc/arch-x86_64/x86_64.mk
index 9171c50..9bce065 100644
--- a/libc/arch-x86_64/x86_64.mk
+++ b/libc/arch-x86_64/x86_64.mk
@@ -4,7 +4,7 @@
bionic/index.cpp \
bionic/memchr.c \
bionic/memcmp.c \
- bionic/memcpy.c \
+ bionic/memcpy.cpp \
bionic/memmove.c \
bionic/memrchr.c \
bionic/memset.c \
diff --git a/libc/bionic/__memcmp16.cpp b/libc/bionic/__memcmp16.cpp
index bee0df1..eb3a08b 100644
--- a/libc/bionic/__memcmp16.cpp
+++ b/libc/bionic/__memcmp16.cpp
@@ -31,14 +31,13 @@
#include <stddef.h>
// Unoptimized version of __memcmp16.
-int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n) {
-
+extern "C" int __memcmp16(const unsigned short* lhs, const unsigned short* rhs, size_t n) {
for (size_t i = 0; i < n; i++) {
- if (*ptr1 != *ptr2) {
- return *ptr1 - *ptr2;
+ if (*lhs != *rhs) {
+ return *lhs - *rhs;
}
- ptr1++;
- ptr2++;
+ lhs++;
+ rhs++;
}
return 0;
}
diff --git a/libc/bionic/memcpy.c b/libc/bionic/memcpy.cpp
similarity index 81%
rename from libc/bionic/memcpy.c
rename to libc/bionic/memcpy.cpp
index dea78b2..d527e85 100644
--- a/libc/bionic/memcpy.c
+++ b/libc/bionic/memcpy.cpp
@@ -25,5 +25,14 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#define MEMCOPY
-#include "bcopy.c"
+
+#undef _FORTIFY_SOURCE
+#include <string.h>
+#include <strings.h>
+
+// Our unoptimized memcpy just calls the best bcopy available.
+// (It's this way round rather than the opposite because we're based on BSD source.)
+void* memcpy(void* dst, const void* src, size_t n) {
+ bcopy(src, dst, n);
+ return dst;
+}