[llvm-commits] [compiler-rt] r152628 - in /compiler-rt/trunk/lib/asan: asan_internal.h asan_win.cc
Timur Iskhodzhanov
timurrrr at google.com
Tue Mar 13 09:12:04 PDT 2012
Author: timurrrr
Date: Tue Mar 13 11:12:03 2012
New Revision: 152628
URL: http://llvm.org/viewvc/llvm-project?rev=152628&view=rev
Log:
[ASan/Win] Eliminate a couple of FIXMEs, add NORETURN to CheckFailed/UNIMPLEMENTED
Modified:
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_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=152628&r1=152627&r2=152628&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Tue Mar 13 11:12:03 2012
@@ -38,6 +38,7 @@
# 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 @@
# 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 @@
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
Modified: compiler-rt/trunk/lib/asan/asan_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=152628&r1=152627&r2=152628&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Tue Mar 13 11:12:03 2012
@@ -15,7 +15,6 @@
#include <windows.h>
#include <dbghelp.h>
-#include <stdio.h> // FIXME: get rid of this.
#include <stdlib.h>
#include <new> // FIXME: temporarily needed for placement new in AsanLock.
@@ -72,17 +71,14 @@
// 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 @@
// ---------------------- 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 @@
}
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;
}
More information about the llvm-commits
mailing list