forked from OSchip/llvm-project
Make qsort_r usage "portable". Why does a function which seems so simple
have to be so complicated? llvm-svn: 105797
This commit is contained in:
parent
c27ee0fd29
commit
a92e332b09
|
@ -60,6 +60,7 @@ protected:
|
||||||
typedef collection::const_iterator const_iterator;
|
typedef collection::const_iterator const_iterator;
|
||||||
|
|
||||||
static int CompareSymbolValueByIndex (void *thunk, const void *a, const void *b);
|
static int CompareSymbolValueByIndex (void *thunk, const void *a, const void *b);
|
||||||
|
static int CompareSymbolValueByIndexLinux (const void *a, const void *b, void *thunk);
|
||||||
void InitNameIndexes ();
|
void InitNameIndexes ();
|
||||||
void InitAddressIndexes ();
|
void InitAddressIndexes ();
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,10 @@ Symtab::CompareSymbolValueByIndex (void *thunk, const void *a, const void *b)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Symtab::CompareSymbolValueByIndexLinux(const void* a, const void* b, void* thunk) {
|
||||||
|
CompareSymbolValueByIndex(thunk, a, b);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Symtab::SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const
|
Symtab::SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const
|
||||||
{
|
{
|
||||||
|
@ -259,7 +263,12 @@ Symtab::SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_du
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Sort the indexes in place using qsort
|
// Sort the indexes in place using qsort
|
||||||
|
// FIXME: (WRONGDEFINE) Need a better define for this!
|
||||||
|
#ifdef __APPLE__
|
||||||
::qsort_r (&indexes[0], indexes.size(), sizeof(uint32_t), (void *)&m_symbols[0], Symtab::CompareSymbolValueByIndex);
|
::qsort_r (&indexes[0], indexes.size(), sizeof(uint32_t), (void *)&m_symbols[0], Symtab::CompareSymbolValueByIndex);
|
||||||
|
#else
|
||||||
|
::qsort_r (&indexes[0], indexes.size(), sizeof(uint32_t), CompareSymbolValueByIndexLinux, (void *)&m_symbols[0]);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Remove any duplicates if requested
|
// Remove any duplicates if requested
|
||||||
if (remove_duplicates)
|
if (remove_duplicates)
|
||||||
|
|
Loading…
Reference in New Issue