aboutsummaryrefslogtreecommitdiff
path: root/libsanitizer/sanitizer_common/sanitizer_win.cc
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2012-11-23 14:46:25 +0000
committerKostya Serebryany <kcc@gcc.gnu.org>2012-11-23 14:46:25 +0000
commite297eb600dd52acd73fb64ca45905b68f4e9b99b (patch)
treea354102cd1c27b09eefe0b04f517d4ecac5bc566 /libsanitizer/sanitizer_common/sanitizer_win.cc
parent8ddf5c28ea6be09213739c94f9765019be476bb0 (diff)
downloadgcc-e297eb600dd52acd73fb64ca45905b68f4e9b99b.zip
gcc-e297eb600dd52acd73fb64ca45905b68f4e9b99b.tar.gz
gcc-e297eb600dd52acd73fb64ca45905b68f4e9b99b.tar.bz2
[libsanitizer] merge from upstream r168514
From-SVN: r193756
Diffstat (limited to 'libsanitizer/sanitizer_common/sanitizer_win.cc')
-rw-r--r--libsanitizer/sanitizer_common/sanitizer_win.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/libsanitizer/sanitizer_common/sanitizer_win.cc b/libsanitizer/sanitizer_common/sanitizer_win.cc
index 3148523..03a5c20 100644
--- a/libsanitizer/sanitizer_common/sanitizer_win.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_win.cc
@@ -10,6 +10,9 @@
// sanitizer_libc.h.
//===----------------------------------------------------------------------===//
#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOGDI
+#include <stdlib.h>
#include <windows.h>
#include "sanitizer_common.h"
@@ -18,6 +21,10 @@
namespace __sanitizer {
// --------------------- sanitizer_common.h
+bool FileExists(const char *filename) {
+ UNIMPLEMENTED();
+}
+
int GetPid() {
return GetProcessId(GetCurrentProcess());
}
@@ -39,7 +46,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) {
@@ -59,8 +65,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) {
@@ -75,7 +85,6 @@ bool MemoryRangeIsAvailable(uptr range_start, uptr range_end) {
void *MapFileToMemory(const char *file_name, uptr *buff_size) {
UNIMPLEMENTED();
- return 0;
}
const char *GetEnv(const char *name) {
@@ -96,7 +105,6 @@ const char *GetEnv(const char *name) {
const char *GetPwd() {
UNIMPLEMENTED();
- return 0;
}
void DumpProcessMap() {
@@ -113,7 +121,6 @@ void ReExec() {
bool StackSizeIsUnlimited() {
UNIMPLEMENTED();
- return false;
}
void SetStackSizeLimitInBytes(uptr limit) {
@@ -137,39 +144,40 @@ 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,
int fd, u64 offset) {
UNIMPLEMENTED();
- return 0;
}
int internal_munmap(void *addr, uptr length) {
UNIMPLEMENTED();
- return 0;
}
int internal_close(fd_t fd) {
UNIMPLEMENTED();
- return 0;
+}
+
+int internal_isatty(fd_t fd) {
+ UNIMPLEMENTED();
}
fd_t internal_open(const char *filename, bool write) {
UNIMPLEMENTED();
- return 0;
}
uptr internal_read(fd_t fd, void *buf, uptr count) {
UNIMPLEMENTED();
- return 0;
}
uptr internal_write(fd_t fd, const void *buf, uptr count) {
- if (fd != 2)
+ if (fd != kStderrFd)
UNIMPLEMENTED();
HANDLE err = GetStdHandle(STD_ERROR_HANDLE);
if (err == 0)
@@ -182,21 +190,18 @@ uptr internal_write(fd_t fd, const void *buf, uptr count) {
uptr internal_filesize(fd_t fd) {
UNIMPLEMENTED();
- return 0;
}
int internal_dup2(int oldfd, int newfd) {
UNIMPLEMENTED();
- return 0;
}
uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
UNIMPLEMENTED();
- return 0;
}
int internal_sched_yield() {
- UNIMPLEMENTED();
+ Sleep(0);
return 0;
}