diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-11-06 13:19:59 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-11-06 13:19:59 +0000 |
commit | 33b2a94ded8473154553c71ef585b8b2522ce70f (patch) | |
tree | a878fa7c32797fe81a2504d1aa022a2a6e7a3375 | |
parent | 1e99374ba2a4fdec2c0d14197a204b3f75e60565 (diff) | |
download | compiler-rt-33b2a94ded8473154553c71ef585b8b2522ce70f.tar.gz |
tsan: windows: less includes, better diagnostics for failed VirtualAlloc(), implement sched_yield()
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167452 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/sanitizer_common/sanitizer_win.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc index 64b220255..297e3d2df 100644 --- a/lib/sanitizer_common/sanitizer_win.cc +++ b/lib/sanitizer_common/sanitizer_win.cc @@ -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 @@ void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, *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 UnmapOrDie(void *addr, uptr size) { } 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 @@ void Abort() { _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 @@ uptr internal_readlink(const char *path, char *buf, uptr bufsize) { } int internal_sched_yield() { - UNIMPLEMENTED(); + Sleep(0); + return 0; } } // namespace __sanitizer |