[Lldb-commits] [lldb] r105797 - in /lldb/trunk: include/lldb/Symbol/Symtab.h source/Symbol/Symtab.cpp

Eli Friedman eli.friedman at gmail.com
Thu Jun 10 16:36:31 PDT 2010


Author: efriedma
Date: Thu Jun 10 18:36:31 2010
New Revision: 105797

URL: http://llvm.org/viewvc/llvm-project?rev=105797&view=rev
Log:
Make qsort_r usage "portable".  Why does a function which seems so simple
have to be so complicated?


Modified:
    lldb/trunk/include/lldb/Symbol/Symtab.h
    lldb/trunk/source/Symbol/Symtab.cpp

Modified: lldb/trunk/include/lldb/Symbol/Symtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=105797&r1=105796&r2=105797&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symtab.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symtab.h Thu Jun 10 18:36:31 2010
@@ -60,6 +60,7 @@
     typedef collection::const_iterator  const_iterator;
 
     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        InitAddressIndexes ();
 

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=105797&r1=105796&r2=105797&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Thu Jun 10 18:36:31 2010
@@ -251,6 +251,10 @@
     return 1;
 }
 
+int Symtab::CompareSymbolValueByIndexLinux(const void* a, const void* b, void* thunk) {
+  CompareSymbolValueByIndex(thunk, a, b);
+}
+
 void
 Symtab::SortSymbolIndexesByValue (std::vector<uint32_t>& indexes, bool remove_duplicates) const
 {
@@ -259,7 +263,12 @@
         return;
 
     // 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);
+#else
+    ::qsort_r (&indexes[0], indexes.size(), sizeof(uint32_t), CompareSymbolValueByIndexLinux, (void *)&m_symbols[0]);
+#endif
 
     // Remove any duplicates if requested
     if (remove_duplicates)





More information about the lldb-commits mailing list