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

Dmitry Vyukov dvyukov at google.com
Tue Nov 6 05:19:59 PST 2012


Author: dvyukov
Date: Tue Nov  6 07:19:59 2012
New Revision: 167452

URL: http://llvm.org/viewvc/llvm-project?rev=167452&view=rev
Log:
tsan: windows: less includes, better diagnostics for failed VirtualAlloc(), implement sched_yield()


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

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=167452&r1=167451&r2=167452&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Tue Nov  6 07:19:59 2012
@@ -12,6 +12,8 @@
 // sanitizer_libc.h.
 //===----------------------------------------------------------------------===//
 #ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
 #include <windows.h>
 
 #include "sanitizer_common.h"
@@ -41,7 +43,6 @@
   *stack_bottom = (uptr)mbi.AllocationBase;
 }
 
-
 void *MmapOrDie(uptr size, const char *mem_type) {
   void *rv = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
   if (rv == 0) {
@@ -61,8 +62,12 @@
 }
 
 void *MmapFixedNoReserve(uptr fixed_addr, uptr size) {
-  return VirtualAlloc((LPVOID)fixed_addr, size,
-                      MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+  void *p = VirtualAlloc((LPVOID)fixed_addr, size,
+      MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+  if (p == 0)
+    Report("ERROR: Failed to allocate 0x%zx (%zd) bytes at %p (%d)\n",
+           size, size, fixed_addr, GetLastError());
+  return p;
 }
 
 void *Mprotect(uptr fixed_addr, uptr size) {
@@ -136,9 +141,11 @@
   _exit(-1);  // abort is not NORETURN on Windows.
 }
 
+#ifndef SANITIZER_GO
 int Atexit(void (*function)(void)) {
   return atexit(function);
 }
+#endif
 
 // ------------------ sanitizer_libc.h
 void *internal_mmap(void *addr, uptr length, int prot, int flags,
@@ -191,7 +198,8 @@
 }
 
 int internal_sched_yield() {
-  UNIMPLEMENTED();
+  Sleep(0);
+  return 0;
 }
 
 }  // namespace __sanitizer





More information about the llvm-commits mailing list