Merge "string/memory functions: avoid qemu bugs/performance issues." into main
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index ff3618e..1b4ba23 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -101,6 +101,9 @@
}
system_properties_.contexts_->FreeAndUnmap();
+ if (system_properties_.appcompat_override_contexts_) {
+ system_properties_.appcompat_override_contexts_->FreeAndUnmap();
+ }
for (int i = 0; i < nprops; i++) {
delete names[i];
diff --git a/libc/Android.bp b/libc/Android.bp
index 6e5bddd..c816bdf 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1758,7 +1758,12 @@
arm: {
// TODO: This is to work around b/24465209. Remove after root cause is fixed.
pack_relocations: false,
- ldflags: ["-Wl,--hash-style=both"],
+ ldflags: [
+ "-Wl,--hash-style=both",
+ // Since we are preserving the debug_frame, do not compress
+ // in this case to make unwinds as fast as possible.
+ "-Wl,--compress-debug-sections=none",
+ ],
version_script: ":libc.arm.map",
no_libcrt: true,
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index 8068fc2..f46d702 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -91,17 +91,6 @@
extern __LIBC_HIDDEN__ __attribute__((weak)) ElfW(Rel) __rel_iplt_start[], __rel_iplt_end[];
static void call_ifunc_resolvers() {
- if (__rel_iplt_start == nullptr || __rel_iplt_end == nullptr) {
- // These symbols were not emitted by gold. Gold has code to do so, but for
- // whatever reason it is not being run. In these cases ifuncs cannot be
- // resolved, so we do not support using ifuncs in static executables linked
- // with gold.
- //
- // Since they are weak, they will be non-null when linked with bfd/lld and
- // null when linked with gold.
- return;
- }
-
for (ElfW(Rel)* r = __rel_iplt_start; r != __rel_iplt_end; ++r) {
ElfW(Addr)* offset = reinterpret_cast<ElfW(Addr)*>(r->r_offset);
ElfW(Addr) resolver = *offset;
@@ -112,17 +101,6 @@
extern __LIBC_HIDDEN__ __attribute__((weak)) ElfW(Rela) __rela_iplt_start[], __rela_iplt_end[];
static void call_ifunc_resolvers() {
- if (__rela_iplt_start == nullptr || __rela_iplt_end == nullptr) {
- // These symbols were not emitted by gold. Gold has code to do so, but for
- // whatever reason it is not being run. In these cases ifuncs cannot be
- // resolved, so we do not support using ifuncs in static executables linked
- // with gold.
- //
- // Since they are weak, they will be non-null when linked with bfd/lld and
- // null when linked with gold.
- return;
- }
-
for (ElfW(Rela)* r = __rela_iplt_start; r != __rela_iplt_end; ++r) {
ElfW(Addr)* offset = reinterpret_cast<ElfW(Addr)*>(r->r_offset);
ElfW(Addr) resolver = r->r_addend;
diff --git a/libc/include/string.h b/libc/include/string.h
index 89b2a45..47bdd72 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -37,7 +37,7 @@
__BEGIN_DECLS
-#if defined(__USE_BSD)
+#if defined(__USE_BSD) || defined(__USE_GNU)
#include <strings.h>
#endif
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index 30dea89..079c825 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -139,7 +139,7 @@
* Returns 0 on success, -1 if the system properties failed to re-initialize (same conditions as
* __system properties_init)
*/
-int __system_properties_zygote_reload(void); __INTRODUCED_IN(__ANDROID_API_V__)
+int __system_properties_zygote_reload(void) __INTRODUCED_IN(__ANDROID_API_V__);
/* Deprecated: use __system_property_wait instead. */
uint32_t __system_property_wait_any(uint32_t __old_serial);
diff --git a/tests/stdatomic_test.cpp b/tests/stdatomic_test.cpp
index 727af87..f5c6bb1 100644
--- a/tests/stdatomic_test.cpp
+++ b/tests/stdatomic_test.cpp
@@ -181,7 +181,8 @@
// And a rudimentary test of acquire-release memory ordering:
-static constexpr uint_least32_t BIG = 30'000'000ul; // Assumed even below.
+static constexpr uint_least32_t BIG = 30'000'000ul;
+static_assert((BIG % 2) == 0); // Assumed below.
struct three_atomics {
atomic_uint_least32_t x;
@@ -192,6 +193,8 @@
atomic_uint_least32_t z;
};
+atomic_bool read_enough(false);
+
// Very simple acquire/release memory ordering smoke test.
static void* writer(void* arg) {
three_atomics* a = reinterpret_cast<three_atomics*>(arg);
@@ -199,9 +202,18 @@
atomic_store_explicit(&a->x, i, memory_order_relaxed);
atomic_store_explicit(&a->z, i, memory_order_relaxed);
atomic_store_explicit(&a->y, i, memory_order_release);
+
+ // Force stores to be visible in spite of being overwritten below.
+ asm volatile("" ::: "memory");
+
atomic_store_explicit(&a->x, i+1, memory_order_relaxed);
atomic_store_explicit(&a->z, i+1, memory_order_relaxed);
atomic_store_explicit(&a->y, i+1, memory_order_release);
+ if (i >= BIG - 1000 && !atomic_load(&read_enough)) {
+ // Give reader a chance to catch up, at the expense of making the test
+ // less effective.
+ usleep(1000);
+ }
}
return nullptr;
}
@@ -229,7 +241,11 @@
<< xval << " < " << yval << ", " << zval << "\n";
return nullptr; // Only report once.
}
- if (repeat < repeat_limit) ++repeat;
+ if (repeat < repeat_limit) {
+ ++repeat;
+ } else if (!atomic_load_explicit(&read_enough, memory_order_relaxed)) {
+ atomic_store_explicit(&read_enough, true, memory_order_relaxed);
+ }
}
// The following assertion is not technically guaranteed to hold.
// But if it fails to hold, this test was useless, and we have a