[llvm-commits] [compiler-rt] r158077 - in /compiler-rt/trunk/lib: asan/asan_internal.h sanitizer_common/sanitizer_internal_defs.h sanitizer_common/sanitizer_win.cc

Alexey Samsonov samsonov at google.com
Wed Jun 6 08:47:40 PDT 2012


Author: samsonov
Date: Wed Jun  6 10:47:40 2012
New Revision: 158077

URL: http://llvm.org/viewvc/llvm-project?rev=158077&view=rev
Log:
[Sanitizer] Make UNIMPLEMENTED macro common.

Modified:
    compiler-rt/trunk/lib/asan/asan_internal.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc

Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=158077&r1=158076&r2=158077&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Jun  6 10:47:40 2012
@@ -223,8 +223,6 @@
 void NORETURN Abort();
 int Atexit(void (*function)(void));
 
-#define UNIMPLEMENTED() CHECK("unimplemented" && 0)
-
 #define ASAN_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
 
 #if !defined(_WIN32) || defined(__clang__)

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=158077&r1=158076&r2=158077&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Wed Jun  6 10:47:40 2012
@@ -95,4 +95,6 @@
 #define CHECK_GT(a, b) CHECK_IMPL((a), >,  (b))
 #define CHECK_GE(a, b) CHECK_IMPL((a), >=, (b))
 
+#define UNIMPLEMENTED() CHECK("unimplemented" && 0)
+
 #endif  // SANITIZER_DEFS_H

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=158077&r1=158076&r2=158077&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Wed Jun  6 10:47:40 2012
@@ -14,13 +14,9 @@
 #ifdef _WIN32
 #include <windows.h>
 
-#include <assert.h>
-
 #include "sanitizer_common.h"
 #include "sanitizer_libc.h"
 
-#define UNIMPLEMENTED_WIN() assert(false)
-
 namespace __sanitizer {
 
 int GetPid() {
@@ -36,41 +32,36 @@
 }
 
 void UnmapOrDie(void *addr, uptr size) {
-  // FIXME: Use CHECK here.
-  RAW_CHECK(VirtualFree(addr, size, MEM_DECOMMIT));
+  if (VirtualFree(addr, size, MEM_DECOMMIT) == 0) {
+    RawWrite("Failed to unmap!\n");
+    Die();
+  }
 }
 
 void *internal_mmap(void *addr, uptr length, int prot, int flags,
                     int fd, u64 offset) {
-  UNIMPLEMENTED_WIN();
-  return 0;
+  UNIMPLEMENTED();
 }
 
 int internal_munmap(void *addr, uptr length) {
-  UNIMPLEMENTED_WIN();
-  return 0;
+  UNIMPLEMENTED();
 }
 
 int internal_close(fd_t fd) {
-  UNIMPLEMENTED_WIN();
-  return 0;
+  UNIMPLEMENTED();
 }
 
 fd_t internal_open(const char *filename, bool write) {
-  UNIMPLEMENTED_WIN();
-  return 0;
+  UNIMPLEMENTED();
 }
 
 uptr internal_read(fd_t fd, void *buf, uptr count) {
-  UNIMPLEMENTED_WIN();
-  return 0;
+  UNIMPLEMENTED();
 }
 
 uptr internal_write(fd_t fd, const void *buf, uptr count) {
-  if (fd != 2) {
-    UNIMPLEMENTED_WIN();
-    return 0;
-  }
+  if (fd != 2)
+    UNIMPLEMENTED();
   HANDLE err = GetStdHandle(STD_ERROR_HANDLE);
   if (err == 0)
     return 0;  // FIXME: this might not work on some apps.
@@ -81,18 +72,15 @@
 }
 
 uptr internal_filesize(fd_t fd) {
-  UNIMPLEMENTED_WIN();
-  return -1;
+  UNIMPLEMENTED();
 }
 
 int internal_dup2(int oldfd, int newfd) {
-  UNIMPLEMENTED_WIN();
-  return -1;
+  UNIMPLEMENTED();
 }
 
 int internal_sscanf(const char *str, const char *format, ...) {
-  UNIMPLEMENTED_WIN();
-  return -1;
+  UNIMPLEMENTED();
 }
 
 }  // namespace __sanitizer





More information about the llvm-commits mailing list