diff --git a/native/src/Android.mk b/native/src/Android.mk index 88fa86686..50dc583d3 100644 --- a/native/src/Android.mk +++ b/native/src/Android.mk @@ -112,7 +112,7 @@ LOCAL_LDFLAGS := -static -T src/lto_fix.lds ifdef B_CRT0 LOCAL_STATIC_LIBRARIES += crt0 LOCAL_CFLAGS += -DUSE_MUSL_PRINTF -LOCAL_LDFLAGS := -lm -Wl,--wrap=qsort +LOCAL_LDFLAGS := -lm endif include $(BUILD_EXECUTABLE) diff --git a/native/src/base/misc.cpp b/native/src/base/misc.cpp index d17707737..7cf725345 100644 --- a/native/src/base/misc.cpp +++ b/native/src/base/misc.cpp @@ -290,37 +290,3 @@ const char *rust::Utf8CStr::data() const { size_t rust::Utf8CStr::length() const { return cxx$utf8str$len(this); } - -#define elm(i) (p + (i * size)) - -// An alternative qsort implementation. Only used when linking with crt0 -extern "C" -void __wrap_qsort(void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*)) { - // Create the index array - uint8_t *p = (uint8_t *) ptr; - vector v(count); - std::iota(v.begin(), v.end(), 0); - - // Sort the index array - std::sort(v.begin(), v.end(), [=](int a, int b) { - return comp(elm(a), elm(b)) < 0; - }); - - // Reorganize the array with index array - void *t = malloc(size); - for (int i = 0; i < count; ++i) { - if (v[i] != i) { - memcpy(t, elm(i), size); - int j = i; - int k; - while (i != (k = v[j])) { - memcpy(elm(j), elm(k), size); - v[j] = j; - j = k; - } - memcpy(elm(j), t, size); - v[j] = j; - } - } - free(t); -} diff --git a/native/src/external/crt0 b/native/src/external/crt0 index 7a03e7b0e..6ec46be76 160000 --- a/native/src/external/crt0 +++ b/native/src/external/crt0 @@ -1 +1 @@ -Subproject commit 7a03e7b0ec410d9f5e927d816261b9aff1c57fa8 +Subproject commit 6ec46be760069d4645204b09b96e8dd414c3ac2e