|
9 | 9 |
|
10 | 10 | #include <utils/ByteOrder.h> |
11 | 11 | #include <utils/SortedVector.h> |
| 12 | +#include <cutils/qsort_r_compat.h> |
12 | 13 |
|
13 | 14 | #if HAVE_PRINTF_ZD |
14 | 15 | # define ZD "%zd" |
@@ -213,11 +214,7 @@ status_t StringPool::addStyleSpan(size_t idx, const entry_style_span& span) |
213 | 214 | return NO_ERROR; |
214 | 215 | } |
215 | 216 |
|
216 | | -#ifdef __GLIBC__ |
217 | | -int StringPool::config_sort(const void* lhs, const void* rhs, void* state) |
218 | | -#else |
219 | 217 | int StringPool::config_sort(void* state, const void* lhs, const void* rhs) |
220 | | -#endif |
221 | 218 | { |
222 | 219 | StringPool* pool = (StringPool*)state; |
223 | 220 | const entry& lhe = pool->mEntries[pool->mEntryArray[*static_cast<const size_t*>(lhs)]]; |
@@ -245,13 +242,7 @@ void StringPool::sortByConfig() |
245 | 242 | NOISY(printf("SORTING STRINGS BY CONFIGURATION...\n")); |
246 | 243 | // Vector::sort uses insertion sort, which is very slow for this data set. |
247 | 244 | // Use quicksort instead because we don't need a stable sort here. |
248 | | - // For more fun, GLibC took qsort_r from BSD but then decided to swap the |
249 | | - // order the last two parameters. |
250 | | -#ifdef __GLIBC__ |
251 | | - qsort_r(newPosToOriginalPos.editArray(), N, sizeof(size_t), config_sort, this); |
252 | | -#else |
253 | | - qsort_r(newPosToOriginalPos.editArray(), N, sizeof(size_t), this, config_sort); |
254 | | -#endif |
| 245 | + qsort_r_compat(newPosToOriginalPos.editArray(), N, sizeof(size_t), this, config_sort); |
255 | 246 | //newPosToOriginalPos.sort(config_sort, this); |
256 | 247 | NOISY(printf("DONE SORTING STRINGS BY CONFIGURATION.\n")); |
257 | 248 |
|
|
0 commit comments