Alexey Samsonov | 298dd7c | 2012-06-05 07:46:31 +0000 | [diff] [blame] | 1 | //===-- sanitizer_win.cc --------------------------------------------------===// |
Alexey Samsonov | dde1f11 | 2012-06-05 07:05:10 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file is shared between AddressSanitizer and ThreadSanitizer |
| 11 | // run-time libraries and implements windows-specific functions from |
| 12 | // sanitizer_libc.h. |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | #ifdef _WIN32 |
| 15 | #include <windows.h> |
| 16 | |
| 17 | #include <assert.h> |
| 18 | |
| 19 | #include "sanitizer_defs.h" |
| 20 | #include "sanitizer_libc.h" |
| 21 | |
| 22 | #define UNIMPLEMENTED_WIN() assert(false) |
| 23 | |
| 24 | namespace __sanitizer { |
| 25 | |
| 26 | void *internal_mmap(void *addr, uptr length, int prot, int flags, |
| 27 | int fd, u64 offset) { |
| 28 | UNIMPLEMENTED_WIN(); |
| 29 | return 0; |
| 30 | } |
| 31 | |
Alexey Samsonov | 03c8b84 | 2012-06-05 08:32:53 +0000 | [diff] [blame^] | 32 | int internal_close(fd_t fd) { |
| 33 | UNIMPLEMENTED_WIN(); |
| 34 | return 0; |
| 35 | } |
| 36 | |
Alexey Samsonov | dde1f11 | 2012-06-05 07:05:10 +0000 | [diff] [blame] | 37 | fd_t internal_open(const char *filename, bool write) { |
| 38 | UNIMPLEMENTED_WIN(); |
| 39 | return 0; |
| 40 | } |
| 41 | |
Alexey Samsonov | 03c8b84 | 2012-06-05 08:32:53 +0000 | [diff] [blame^] | 42 | uptr internal_read(fd_t fd, void *buf, uptr count) { |
| 43 | UNIMPLEMENTED_WIN(); |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | uptr internal_write(fd_t fd, const void *buf, uptr count) { |
| 48 | if (fd != 2) { |
| 49 | UNIMPLEMENTED_WIN(); |
| 50 | return 0; |
| 51 | } |
| 52 | HANDLE err = GetStdHandle(STD_ERROR_HANDLE); |
| 53 | if (err == 0) |
| 54 | return 0; // FIXME: this might not work on some apps. |
| 55 | DWORD ret; |
| 56 | if (!WriteFile(err, buf, count, &ret, 0)) |
| 57 | return 0; |
| 58 | return ret; |
| 59 | } |
| 60 | |
Alexey Samsonov | dde1f11 | 2012-06-05 07:05:10 +0000 | [diff] [blame] | 61 | } // namespace __sanitizer |
| 62 | |
| 63 | #endif // _WIN32 |