Merge "Fix parse of gtest_filter in bionic gtest main."
diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk
index 989e9e6..c3eb6d3 100644
--- a/benchmarks/Android.mk
+++ b/benchmarks/Android.mk
@@ -28,6 +28,9 @@
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_STATIC_LIBRARY)
+# Only supported on linux systems.
+ifeq ($(HOST_OS),linux)
+
include $(CLEAR_VARS)
LOCAL_MODULE := libbenchmark
LOCAL_CFLAGS += -O2 -Wall -Wextra -Werror
@@ -37,6 +40,8 @@
LOCAL_MULTILIB := both
include $(BUILD_HOST_STATIC_LIBRARY)
+endif
+
# -----------------------------------------------------------------------------
# Benchmarks.
# -----------------------------------------------------------------------------
@@ -76,6 +81,9 @@
# performance of the old release's libc, and a static benchmark isn't
# going to let you do that.
+# Only supported on linux systems.
+ifeq ($(HOST_OS),linux)
+
# Build benchmarks for the host (against glibc!). Run with:
include $(CLEAR_VARS)
LOCAL_MODULE := bionic-benchmarks-glibc
@@ -88,6 +96,8 @@
LOCAL_STATIC_LIBRARIES += libbenchmark
include $(BUILD_HOST_EXECUTABLE)
+endif
+
ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
include $(LOCAL_PATH)/../build/run-on-host.mk
diff --git a/libc/Android.mk b/libc/Android.mk
index a2a3108..691017a 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -271,7 +271,6 @@
upstream-freebsd/lib/libc/string/wcsspn.c \
upstream-freebsd/lib/libc/string/wcstok.c \
upstream-freebsd/lib/libc/string/wmemchr.c \
- upstream-freebsd/lib/libc/string/wmemcpy.c \
upstream-freebsd/lib/libc/string/wmemset.c \
libc_upstream_netbsd_src_files := \
@@ -506,6 +505,7 @@
upstream-openbsd/lib/libc/string/strspn.c \
upstream-openbsd/lib/libc/string/strstr.c \
upstream-openbsd/lib/libc/string/strtok.c \
+ upstream-openbsd/lib/libc/string/wmemcpy.c \
upstream-openbsd/lib/libc/string/wcslcpy.c \
upstream-openbsd/lib/libc/string/wcsstr.c \
upstream-openbsd/lib/libc/string/wcswidth.c \
diff --git a/libc/arch-arm/arm.mk b/libc/arch-arm/arm.mk
index 5f0b1b3..f712c4c 100644
--- a/libc/arch-arm/arm.mk
+++ b/libc/arch-arm/arm.mk
@@ -40,7 +40,6 @@
upstream-freebsd/lib/libc/string/wmemmove.c \
libc_openbsd_src_files_arm += \
- upstream-openbsd/lib/libc/string/bcopy.c \
upstream-openbsd/lib/libc/string/stpncpy.c \
upstream-openbsd/lib/libc/string/strlcat.c \
upstream-openbsd/lib/libc/string/strlcpy.c \
diff --git a/libc/arch-arm/cortex-a15/cortex-a15.mk b/libc/arch-arm/cortex-a15/cortex-a15.mk
index ec423c5..cc502cf 100644
--- a/libc/arch-arm/cortex-a15/cortex-a15.mk
+++ b/libc/arch-arm/cortex-a15/cortex-a15.mk
@@ -9,4 +9,6 @@
arch-arm/cortex-a15/bionic/strcpy.S \
arch-arm/cortex-a15/bionic/__strcpy_chk.S \
arch-arm/cortex-a15/bionic/strlen.S \
- bionic/memmove.c \
+
+libc_openbsd_src_files_arm += \
+ upstream-openbsd/lib/libc/string/memmove.c \
diff --git a/libc/arch-arm/cortex-a9/cortex-a9.mk b/libc/arch-arm/cortex-a9/cortex-a9.mk
index e38c40a..7570567 100644
--- a/libc/arch-arm/cortex-a9/cortex-a9.mk
+++ b/libc/arch-arm/cortex-a9/cortex-a9.mk
@@ -9,4 +9,6 @@
arch-arm/cortex-a9/bionic/strcpy.S \
arch-arm/cortex-a9/bionic/__strcpy_chk.S \
arch-arm/cortex-a9/bionic/strlen.S \
- bionic/memmove.c \
+
+libc_openbsd_src_files_arm += \
+ upstream-openbsd/lib/libc/string/memmove.c \
diff --git a/libc/arch-arm/generic/generic.mk b/libc/arch-arm/generic/generic.mk
index 96ed949..e49d6d2 100644
--- a/libc/arch-arm/generic/generic.mk
+++ b/libc/arch-arm/generic/generic.mk
@@ -5,8 +5,10 @@
arch-arm/generic/bionic/strcmp.S \
arch-arm/generic/bionic/strcpy.S \
arch-arm/generic/bionic/strlen.c \
- bionic/memmove.c \
bionic/__strcat_chk.cpp \
bionic/__strcpy_chk.cpp \
+
+libc_openbsd_src_files_arm += \
+ upstream-openbsd/lib/libc/string/memmove.c \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/strcat.c \
diff --git a/libc/arch-arm/krait/krait.mk b/libc/arch-arm/krait/krait.mk
index 450f472..8bd5e8b 100644
--- a/libc/arch-arm/krait/krait.mk
+++ b/libc/arch-arm/krait/krait.mk
@@ -12,4 +12,6 @@
arch-arm/cortex-a15/bionic/strcat.S \
arch-arm/cortex-a15/bionic/strcpy.S \
arch-arm/cortex-a15/bionic/strlen.S \
- bionic/memmove.c \
+
+libc_openbsd_src_files_arm += \
+ upstream-openbsd/lib/libc/string/memmove.c \
diff --git a/libc/arch-arm64/bionic/setjmp.S b/libc/arch-arm64/bionic/setjmp.S
index 5c956ff..6e119dc 100644
--- a/libc/arch-arm64/bionic/setjmp.S
+++ b/libc/arch-arm64/bionic/setjmp.S
@@ -49,8 +49,8 @@
#define _JB_X19 (_JB_X20_X21 + 2)
#define _JB_D14_D15 (_JB_X19 + 1)
#define _JB_D12_D13 (_JB_D14_D15 + 2)
-#define _JB_D10_D11 (_JB_D12_D13 + 1)
-#define _JB_D8_D9 (_JB_D10_D11 + 1)
+#define _JB_D10_D11 (_JB_D12_D13 + 2)
+#define _JB_D8_D9 (_JB_D10_D11 + 2)
ENTRY(setjmp)
mov w1, #1
diff --git a/libc/arch-mips/mips.mk b/libc/arch-mips/mips.mk
index d558baa..7f36635 100644
--- a/libc/arch-mips/mips.mk
+++ b/libc/arch-mips/mips.mk
@@ -23,13 +23,12 @@
#
libc_bionic_src_files_mips += \
+ arch-mips/string/memcmp.c \
bionic/__memcpy_chk.cpp \
bionic/__memset_chk.cpp \
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
bionic/memchr.c \
- bionic/memcmp.c \
- bionic/memmove.c \
bionic/memrchr.c \
bionic/strchr.cpp \
bionic/strnlen.c \
@@ -46,7 +45,7 @@
upstream-freebsd/lib/libc/string/wmemmove.c \
libc_openbsd_src_files_mips += \
- upstream-openbsd/lib/libc/string/bcopy.c \
+ upstream-openbsd/lib/libc/string/memmove.c \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/stpncpy.c \
upstream-openbsd/lib/libc/string/strcat.c \
@@ -79,11 +78,9 @@
else
libc_bionic_src_files_mips += \
- bionic/memcpy.cpp \
- bionic/memset.c \
-
-libc_openbsd_src_files_mips += \
- upstream-openbsd/lib/libc/string/strlen.c \
+ arch-mips/string/memcpy.c \
+ arch-mips/string/memset.c \
+ arch-mips/string/strlen.c \
endif
diff --git a/libc/bionic/memcmp.c b/libc/arch-mips/string/memcmp.c
similarity index 100%
rename from libc/bionic/memcmp.c
rename to libc/arch-mips/string/memcmp.c
diff --git a/libc/arch-mips/string/memcpy.c b/libc/arch-mips/string/memcpy.c
new file mode 100644
index 0000000..5551a6d
--- /dev/null
+++ b/libc/arch-mips/string/memcpy.c
@@ -0,0 +1,91 @@
+/* $OpenBSD: memcpy.c,v 1.1 2014/11/30 19:43:56 deraadt Exp $ */
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <syslog.h>
+
+/*
+ * sizeof(word) MUST BE A POWER OF TWO
+ * SO THAT wmask BELOW IS ALL ONES
+ */
+typedef long word; /* "word" used for optimal copy speed */
+
+#define wsize sizeof(word)
+#define wmask (wsize - 1)
+
+/*
+ * Copy a block of memory, not handling overlap.
+ */
+void *
+memcpy(void *dst0, const void *src0, size_t length)
+{
+ char *dst = dst0;
+ const char *src = src0;
+ size_t t;
+
+ if (length == 0 || dst == src) /* nothing to do */
+ goto done;
+
+ /*
+ * Macros: loop-t-times; and loop-t-times, t>0
+ */
+#define TLOOP(s) if (t) TLOOP1(s)
+#define TLOOP1(s) do { s; } while (--t)
+
+ /*
+ * Copy forward.
+ */
+ t = (long)src; /* only need low bits */
+ if ((t | (long)dst) & wmask) {
+ /*
+ * Try to align operands. This cannot be done
+ * unless the low bits match.
+ */
+ if ((t ^ (long)dst) & wmask || length < wsize)
+ t = length;
+ else
+ t = wsize - (t & wmask);
+ length -= t;
+ TLOOP1(*dst++ = *src++);
+ }
+ /*
+ * Copy whole words, then mop up any trailing bytes.
+ */
+ t = length / wsize;
+ TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
+ t = length & wmask;
+ TLOOP(*dst++ = *src++);
+done:
+ return (dst0);
+}
diff --git a/libc/bionic/memset.c b/libc/arch-mips/string/memset.c
similarity index 100%
rename from libc/bionic/memset.c
rename to libc/arch-mips/string/memset.c
diff --git a/libc/upstream-openbsd/lib/libc/string/strlen.c b/libc/arch-mips/string/strlen.c
similarity index 100%
rename from libc/upstream-openbsd/lib/libc/string/strlen.c
rename to libc/arch-mips/string/strlen.c
diff --git a/libc/arch-mips64/mips64.mk b/libc/arch-mips64/mips64.mk
index 6fa7d33..7990c69 100644
--- a/libc/arch-mips64/mips64.mk
+++ b/libc/arch-mips64/mips64.mk
@@ -10,14 +10,14 @@
bionic/__strcpy_chk.cpp \
bionic/__strcat_chk.cpp \
bionic/memchr.c \
- bionic/memcmp.c \
- bionic/memcpy.cpp \
- bionic/memmove.c \
bionic/memrchr.c \
- bionic/memset.c \
bionic/strchr.cpp \
bionic/strnlen.c \
bionic/strrchr.cpp \
+ arch-mips/string/memcmp.c \
+ arch-mips/string/memcpy.c \
+ arch-mips/string/memset.c \
+ arch-mips/string/strlen.c \
libc_freebsd_src_files_mips64 += \
upstream-freebsd/lib/libc/string/wcscat.c \
@@ -30,6 +30,7 @@
upstream-freebsd/lib/libc/string/wmemmove.c \
libc_openbsd_src_files_mips64 += \
+ upstream-openbsd/lib/libc/string/memmove.c \
upstream-openbsd/lib/libc/string/stpcpy.c \
upstream-openbsd/lib/libc/string/stpncpy.c \
upstream-openbsd/lib/libc/string/strcat.c \
@@ -37,7 +38,6 @@
upstream-openbsd/lib/libc/string/strcpy.c \
upstream-openbsd/lib/libc/string/strlcat.c \
upstream-openbsd/lib/libc/string/strlcpy.c \
- upstream-openbsd/lib/libc/string/strlen.c \
upstream-openbsd/lib/libc/string/strncat.c \
upstream-openbsd/lib/libc/string/strncmp.c \
upstream-openbsd/lib/libc/string/strncpy.c \
diff --git a/libc/bionic/error.cpp b/libc/bionic/error.cpp
index 9f4d0ee..e8df0e0 100644
--- a/libc/bionic/error.cpp
+++ b/libc/bionic/error.cpp
@@ -31,6 +31,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
unsigned int error_message_count = 0;
void (*error_print_progname)(void) = NULL;
diff --git a/libc/bionic/memcpy.cpp b/libc/bionic/memcpy.cpp
deleted file mode 100644
index d527e85..0000000
--- a/libc/bionic/memcpy.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#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;
-}
diff --git a/libc/bionic/memmove.c b/libc/bionic/memmove.c
deleted file mode 100644
index 39c766e..0000000
--- a/libc/bionic/memmove.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define MEMMOVE
-#include "upstream-openbsd/lib/libc/string/bcopy.c"
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index 18a4a14..28d6355 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -235,6 +235,16 @@
return signal(signum, handler);
}
+#if !defined(__i386__)
+// This was removed from POSIX 2008.
+#undef bcopy
+extern "C" void bcopy(const void* src, void* dst, size_t n) {
+ memcpy(dst, src, n);
+}
+#else
+// x86 has an assembler implementation.
+#endif
+
// sysv_signal() was never in POSIX.
extern sighandler_t _signal(int signum, sighandler_t handler, int flags);
extern "C" sighandler_t sysv_signal(int signum, sighandler_t handler) {
diff --git a/libc/bionic/scandir.cpp b/libc/bionic/scandir.cpp
index 28b4ed0..ee62fee 100644
--- a/libc/bionic/scandir.cpp
+++ b/libc/bionic/scandir.cpp
@@ -18,6 +18,7 @@
#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include "private/bionic_macros.h"
#include "private/ScopedReaddir.h"
diff --git a/libc/bionic/syslog.cpp b/libc/bionic/syslog.cpp
index d8b8b19..8e3f34f 100644
--- a/libc/bionic/syslog.cpp
+++ b/libc/bionic/syslog.cpp
@@ -16,6 +16,7 @@
#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include <syslog.h>
#include "private/libc_logging.h"
diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c
index c431835..573fcbe 100644
--- a/libc/dns/resolv/res_cache.c
+++ b/libc/dns/resolv/res_cache.c
@@ -28,6 +28,8 @@
#include "resolv_cache.h"
#include <resolv.h>
+#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -45,6 +47,8 @@
#include "resolv_netid.h"
#include "res_private.h"
+#include "private/libc_logging.h"
+
/* This code implements a small and *simple* DNS resolver cache.
*
* It is only used to cache DNS answers for a time defined by the smallest TTL
@@ -152,13 +156,21 @@
/* set to 1 to debug query data */
#define DEBUG_DATA 0
-#undef XLOG
#if DEBUG
-# include "private/libc_logging.h"
-# define XLOG(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
+#define __DEBUG__
+#else
+#define __DEBUG__ __attribute__((unused))
+#endif
-#include <stdio.h>
-#include <stdarg.h>
+#undef XLOG
+
+#define XLOG(...) ({ \
+ if (DEBUG) { \
+ __libc_format_log(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__); \
+ } else { \
+ ((void)0); \
+ } \
+})
/** BOUNDED BUFFER FORMATTING
**/
@@ -205,7 +217,7 @@
*/
/* add a char to a bounded buffer */
-static char*
+char*
_bprint_c( char* p, char* end, int c )
{
if (p < end) {
@@ -220,7 +232,7 @@
}
/* add a sequence of bytes to a bounded buffer */
-static char*
+char*
_bprint_b( char* p, char* end, const char* buf, int len )
{
int avail = end - p;
@@ -243,15 +255,15 @@
}
/* add a string to a bounded buffer */
-static char*
+char*
_bprint_s( char* p, char* end, const char* str )
{
return _bprint_b(p, end, str, strlen(str));
}
/* add a formatted string to a bounded buffer */
-static char*
-_bprint( char* p, char* end, const char* format, ... )
+char* _bprint( char* p, char* end, const char* format, ... ) __DEBUG__;
+char* _bprint( char* p, char* end, const char* format, ... )
{
int avail, n;
va_list args;
@@ -278,7 +290,7 @@
}
/* add a hex value to a bounded buffer, up to 8 digits */
-static char*
+char*
_bprint_hex( char* p, char* end, unsigned value, int numDigits )
{
char text[sizeof(unsigned)*2];
@@ -291,7 +303,7 @@
}
/* add the hexadecimal dump of some memory area to a bounded buffer */
-static char*
+char*
_bprint_hexdump( char* p, char* end, const uint8_t* data, int datalen )
{
int lineSize = 16;
@@ -330,20 +342,17 @@
}
/* dump the content of a query of packet to the log */
-static void
-XLOG_BYTES( const void* base, int len )
+void XLOG_BYTES( const void* base, int len ) __DEBUG__;
+void XLOG_BYTES( const void* base, int len )
{
- char buff[1024];
- char* p = buff, *end = p + sizeof(buff);
+ if (DEBUG_DATA) {
+ char buff[1024];
+ char* p = buff, *end = p + sizeof(buff);
- p = _bprint_hexdump(p, end, base, len);
- XLOG("%s",buff);
-}
-
-#else /* !DEBUG */
-# define XLOG(...) ((void)0)
-# define XLOG_BYTES(a,b) ((void)0)
-#endif
+ p = _bprint_hexdump(p, end, base, len);
+ XLOG("%s",buff);
+ }
+} __DEBUG__
static time_t
_time_now( void )
diff --git a/libc/dns/resolv/res_state.c b/libc/dns/resolv/res_state.c
index 75bff97..7533d19 100644
--- a/libc/dns/resolv/res_state.c
+++ b/libc/dns/resolv/res_state.c
@@ -34,6 +34,7 @@
#include "resolv_cache.h"
#include <pthread.h>
#include <stdlib.h>
+#include <string.h>
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 0060ea3..4cb288d 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -25,15 +25,16 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#ifndef _STDLIB_H_
-#define _STDLIB_H_
+
+#ifndef _STDLIB_H
+#define _STDLIB_H
#include <sys/cdefs.h>
+#include <xlocale.h>
-#include <stddef.h>
#include <alloca.h>
-#include <strings.h>
-#include <memory.h>
+#include <malloc.h>
+#include <stddef.h>
__BEGIN_DECLS
@@ -173,4 +174,4 @@
__END_DECLS
-#endif /* _STDLIB_H_ */
+#endif /* _STDLIB_H */
diff --git a/libc/include/string.h b/libc/include/string.h
index f0bed10..4ca77ae 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -36,6 +36,10 @@
__BEGIN_DECLS
+#if defined(__USE_BSD)
+#include <strings.h>
+#endif
+
extern void* memccpy(void* __restrict, const void* __restrict, int, size_t);
extern void* memchr(const void *, int, size_t) __purefunc;
extern void* memrchr(const void *, int, size_t) __purefunc;
diff --git a/libc/upstream-openbsd/lib/libc/string/bcopy.c b/libc/upstream-openbsd/lib/libc/string/memmove.c
similarity index 89%
rename from libc/upstream-openbsd/lib/libc/string/bcopy.c
rename to libc/upstream-openbsd/lib/libc/string/memmove.c
index 4308c64..1baad53 100644
--- a/libc/upstream-openbsd/lib/libc/string/bcopy.c
+++ b/libc/upstream-openbsd/lib/libc/string/memmove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcopy.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: memmove.c,v 1.1 2014/11/30 19:43:56 deraadt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -44,21 +44,9 @@
/*
* Copy a block of memory, handling overlap.
- * This is the routine that actually implements
- * (the portable versions of) bcopy, memcpy, and memmove.
*/
-#ifdef MEMCOPY
-void *
-memcpy(void *dst0, const void *src0, size_t length)
-#else
-#ifdef MEMMOVE
void *
memmove(void *dst0, const void *src0, size_t length)
-#else
-void
-bcopy(const void *src0, void *dst0, size_t length)
-#endif
-#endif
{
char *dst = dst0;
const char *src = src0;
@@ -120,9 +108,5 @@
TLOOP(*--dst = *--src);
}
done:
-#if defined(MEMCOPY) || defined(MEMMOVE)
return (dst0);
-#else
- return;
-#endif
}
diff --git a/libc/upstream-freebsd/lib/libc/string/wmemcpy.c b/libc/upstream-openbsd/lib/libc/string/wmemcpy.c
similarity index 84%
rename from libc/upstream-freebsd/lib/libc/string/wmemcpy.c
rename to libc/upstream-openbsd/lib/libc/string/wmemcpy.c
index c10770c..9bbd836 100644
--- a/libc/upstream-freebsd/lib/libc/string/wmemcpy.c
+++ b/libc/upstream-openbsd/lib/libc/string/wmemcpy.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: wmemcpy.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
+/* $NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
+
/*-
* Copyright (c)1999 Citrus Project,
* All rights reserved.
@@ -26,19 +29,12 @@
* citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*/
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wmemcpy.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
-#endif /* LIBC_SCCS and not lint */
-#endif
-__FBSDID("$FreeBSD$");
-
#include <string.h>
#include <wchar.h>
wchar_t *
-wmemcpy(wchar_t * __restrict d, const wchar_t * __restrict s, size_t n)
+wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
{
+
return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t));
}
diff --git a/tests/setjmp_test.cpp b/tests/setjmp_test.cpp
index 8afd494..a3b5885 100644
--- a/tests/setjmp_test.cpp
+++ b/tests/setjmp_test.cpp
@@ -161,3 +161,54 @@
}
sigprocmask(SIG_SETMASK, &ss.original, NULL);
}
+
+#if defined(__aarch64__)
+#define SET_FREG(n, v) asm volatile("fmov d"#n ", "#v : : : "d"#n)
+#define CLEAR_FREG(n) asm volatile("fmov d"#n ", xzr" : : : "d"#n)
+#define SET_FREGS \
+ SET_FREG(8, 8.0); SET_FREG(9, 9.0); SET_FREG(10, 10.0); SET_FREG(11, 11.0); \
+ SET_FREG(12, 12.0); SET_FREG(13, 13.0); SET_FREG(14, 14.0); SET_FREG(15, 15.0);
+#define CLEAR_FREGS \
+ CLEAR_FREG(8); CLEAR_FREG(9); CLEAR_FREG(10); CLEAR_FREG(11); \
+ CLEAR_FREG(12); CLEAR_FREG(13); CLEAR_FREG(14); CLEAR_FREG(15);
+#define GET_FREG(n) ({ double _r; asm volatile("fmov %0, d"#n : "=r"(_r) : :); _r; })
+#define CHECK_FREGS \
+ EXPECT_EQ(8.0, GET_FREG(8)); EXPECT_EQ(9.0, GET_FREG(9)); \
+ EXPECT_EQ(10.0, GET_FREG(10)); EXPECT_EQ(11.0, GET_FREG(11)); \
+ EXPECT_EQ(12.0, GET_FREG(12)); EXPECT_EQ(13.0, GET_FREG(13)); \
+ EXPECT_EQ(14.0, GET_FREG(14)); EXPECT_EQ(15.0, GET_FREG(15));
+#elif defined(__arm__)
+#define SET_FREG(n, v) \
+ ({ const double _v{v}; asm volatile("fcpyd d"#n ", %P0" : : "w"(_v) : "d"#n); })
+#define SET_FREGS \
+ SET_FREG(8, 8); SET_FREG(9, 9); SET_FREG(10, 10); SET_FREG(11, 11); \
+ SET_FREG(12, 12); SET_FREG(13, 13); SET_FREG(14, 14); SET_FREG(15, 15);
+#define CLEAR_FREGS \
+ SET_FREG(8, 0); SET_FREG(9, 0); SET_FREG(10, 0); SET_FREG(11, 0); \
+ SET_FREG(12, 0); SET_FREG(13, 0); SET_FREG(14, 0); SET_FREG(15, 0);
+#define GET_FREG(n) ({ double _r; asm volatile("fcpyd %P0, d"#n : "=w"(_r) : :); _r;})
+#define CHECK_FREGS \
+ EXPECT_EQ(8.0, GET_FREG(8)); EXPECT_EQ(9.0, GET_FREG(9)); \
+ EXPECT_EQ(10.0, GET_FREG(10)); EXPECT_EQ(11.0, GET_FREG(11)); \
+ EXPECT_EQ(12.0, GET_FREG(12)); EXPECT_EQ(13.0, GET_FREG(13)); \
+ EXPECT_EQ(14.0, GET_FREG(14)); EXPECT_EQ(15.0, GET_FREG(15));
+#else
+/* The other architectures don't save/restore fp registers. */
+#define SET_FREGS
+#define CLEAR_FREGS
+#define CHECK_FREGS
+#endif
+
+TEST(setjmp, setjmp_fp_registers) {
+ int value;
+ jmp_buf jb;
+ SET_FREGS;
+ if ((value = setjmp(jb)) == 0) {
+ CLEAR_FREGS;
+ longjmp(jb, 123);
+ FAIL(); // Unreachable.
+ } else {
+ ASSERT_EQ(123, value);
+ CHECK_FREGS;
+ }
+}