#include <utils/ByteOrder.h>
#include <utils/SortedVector.h>
+#include <cutils/qsort_r_compat.h>
#if HAVE_PRINTF_ZD
# define ZD "%zd"
return NO_ERROR;
}
-#ifdef __GLIBC__
-int StringPool::config_sort(const void* lhs, const void* rhs, void* state)
-#else
int StringPool::config_sort(void* state, const void* lhs, const void* rhs)
-#endif
{
StringPool* pool = (StringPool*)state;
const entry& lhe = pool->mEntries[pool->mEntryArray[*static_cast<const size_t*>(lhs)]];
NOISY(printf("SORTING STRINGS BY CONFIGURATION...\n"));
// Vector::sort uses insertion sort, which is very slow for this data set.
// Use quicksort instead because we don't need a stable sort here.
- // For more fun, GLibC took qsort_r from BSD but then decided to swap the
- // order the last two parameters.
-#ifdef __GLIBC__
- qsort_r(newPosToOriginalPos.editArray(), N, sizeof(size_t), config_sort, this);
-#else
- qsort_r(newPosToOriginalPos.editArray(), N, sizeof(size_t), this, config_sort);
-#endif
+ qsort_r_compat(newPosToOriginalPos.editArray(), N, sizeof(size_t), this, config_sort);
//newPosToOriginalPos.sort(config_sort, this);
NOISY(printf("DONE SORTING STRINGS BY CONFIGURATION.\n"));
const Vector<size_t>* offsetsForString(const String16& val) const;
private:
-#ifdef __GLIBC__
- static int config_sort(const void* lhs, const void* rhs, void* state);
-#else
static int config_sort(void* state, const void* lhs, const void* rhs);
-#endif
const bool mUTF8;