[llvm-commits] [compiler-rt] r159738 - /compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc

Dmitry Vyukov dvyukov at google.com
Thu Jul 5 02:23:37 PDT 2012


Author: dvyukov
Date: Thu Jul  5 04:23:37 2012
New Revision: 159738

URL: http://llvm.org/viewvc/llvm-project?rev=159738&view=rev
Log:
tsan/asan: kill STL
First, placement new from standard library conflicts with our own.
Second, we are in trouble if user uses the same function (we either get instrumented code in runtime, or non-instrumented code in user program).


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc?rev=159738&r1=159737&r2=159738&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.cc Thu Jul  5 04:23:37 2012
@@ -13,10 +13,7 @@
 
 #include "sanitizer_common.h"
 #include "sanitizer_libc.h"
-
-// Should not add dependency on libstdc++,
-// since most of the stuff here is inlinable.
-#include <algorithm>
+#include <stdlib.h>
 
 namespace __sanitizer {
 
@@ -60,8 +57,19 @@
   return read_len;
 }
 
+static int comp(const void *p1, const void *p2) {
+  uptr v1 = *(uptr*)p1;
+  uptr v2 = *(uptr*)p2;
+  if (v1 < v2)
+    return -1;
+  else if (v1 > v2)
+    return 1;
+  else
+    return 0;
+}
+
 void SortArray(uptr *array, uptr size) {
-  std::sort(array, array + size);
+  qsort(array, size, sizeof(array[0]), &comp);
 }
 
 }  // namespace __sanitizer





More information about the llvm-commits mailing list