From 70df757918c3f122950fda1d4cfded0157f2ab22 Mon Sep 17 00:00:00 2001 From: Timur Iskhodzhanov Date: Tue, 13 Mar 2012 16:12:03 +0000 Subject: [PATCH] [ASan/Win] Eliminate a couple of FIXMEs, add NORETURN to CheckFailed/UNIMPLEMENTED llvm-svn: 152628 --- compiler-rt/lib/asan/asan_internal.h | 4 +++- compiler-rt/lib/asan/asan_win.cc | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index 42e8829f3bb7..da335f0731a9 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -38,6 +38,7 @@ extern "C" void* _ReturnAddress(void); # define ALIAS(x) // TODO(timurrrr): do we need this on Windows? # define ALIGNED(x) __declspec(align(x)) # define NOINLINE __declspec(noinline) +# define NORETURN __declspec(noreturn) # define ASAN_INTERFACE_ATTRIBUTE // TODO(timurrrr): do we need this on Win? #else // defined(_WIN32) @@ -46,6 +47,7 @@ extern "C" void* _ReturnAddress(void); # define ALIAS(x) __attribute__((alias(x))) # define ALIGNED(x) __attribute__((aligned(x))) # define NOINLINE __attribute__((noinline)) +# define NORETURN __attribute__((noreturn)) # define ASAN_INTERFACE_ATTRIBUTE __attribute__((visibility("default"))) #endif // defined(_WIN32) @@ -145,7 +147,7 @@ class AsanThread; struct AsanStackTrace; // asan_rtl.cc -void CheckFailed(const char *cond, const char *file, int line); +void NORETURN CheckFailed(const char *cond, const char *file, int line); void ShowStatsAndAbort(); // asan_globals.cc diff --git a/compiler-rt/lib/asan/asan_win.cc b/compiler-rt/lib/asan/asan_win.cc index 53d6777b669b..b3a770b82769 100644 --- a/compiler-rt/lib/asan/asan_win.cc +++ b/compiler-rt/lib/asan/asan_win.cc @@ -15,7 +15,6 @@ #include #include -#include // FIXME: get rid of this. #include #include // FIXME: temporarily needed for placement new in AsanLock. @@ -72,17 +71,14 @@ size_t AsanWrite(int fd, const void *buf, size_t count) { // code unreachable on Windows. We should clean this up. int AsanOpenReadonly(const char* filename) { UNIMPLEMENTED(); - return -1; } size_t AsanRead(int fd, void *buf, size_t count) { UNIMPLEMENTED(); - return -1; } int AsanClose(int fd) { UNIMPLEMENTED(); - return -1; } // ---------------------- Stacktraces, symbols, etc. ---------------- {{{1 @@ -204,7 +200,6 @@ void AsanLock::Unlock() { // ---------------------- TSD ---------------- {{{1 static bool tsd_key_inited = false; -// FIXME: is __declspec enough? static __declspec(thread) void *fake_tsd = NULL; void AsanTSDInit(void (*destructor)(void *tsd)) { @@ -240,7 +235,18 @@ int AtomicInc(int *a) { } const char* AsanGetEnv(const char* name) { - // FIXME: implement. + static char env_buffer[32767] = {}; + + // Note: this implementation stores the result in a static buffer so we only + // allow it to be called just once. + static bool called_once = false; + if (called_once) + UNIMPLEMENTED(); + called_once = true; + + DWORD rv = GetEnvironmentVariableA(name, env_buffer, sizeof(env_buffer)); + if (rv > 0 && rv < sizeof(env_buffer)) + return env_buffer; return NULL; }