[llvm-commits] [compiler-rt] r151162 - in /compiler-rt/trunk/lib/asan: asan_interface.h asan_internal.h asan_posix.cc asan_rtl.cc asan_win.cc
Alexey Samsonov
samsonov at google.com
Wed Feb 22 06:07:06 PST 2012
Author: samsonov
Date: Wed Feb 22 08:07:06 2012
New Revision: 151162
URL: http://llvm.org/viewvc/llvm-project?rev=151162&view=rev
Log:
AddressSanitizer: get rid of stdlib.h and add (smaller) stddef.h instead
Modified:
compiler-rt/trunk/lib/asan/asan_interface.h
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_posix.cc
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/asan_win.cc
Modified: compiler-rt/trunk/lib/asan/asan_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interface.h?rev=151162&r1=151161&r2=151162&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interface.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interface.h Wed Feb 22 08:07:06 2012
@@ -15,6 +15,10 @@
#ifndef ASAN_INTERFACE_H
#define ASAN_INTERFACE_H
+// ----------- ATTENTION -------------
+// This header should NOT include any other headers from ASan runtime.
+// All functions in this header are extern "C" and start with __asan_.
+
#if !defined(_WIN32)
#include <stdint.h> // for uintptr_t
#define ASAN_INTERFACE_FUNCTION_ATTRIBUTE __attribute__((visibility("default")))
@@ -22,10 +26,7 @@
// TODO(timurrrr): find out what we need on Windows. __declspec(dllexport) ?
#define ASAN_INTERFACE_FUNCTION_ATTRIBUTE
#endif
-#include <stdlib.h> // for size_t
-
-// This header should NOT include any other headers from ASan runtime.
-// All functions in this header are extern "C" and start with __asan_.
+#include <stddef.h> // for size_t
extern "C" {
// This function should be called at the very beginning of the process,
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=151162&r1=151161&r2=151162&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Wed Feb 22 08:07:06 2012
@@ -18,7 +18,7 @@
# error "This operating system is not supported by AddressSanitizer"
#endif
-#include <stdlib.h> // for size_t, uintptr_t, etc.
+#include <stddef.h> // for size_t, uintptr_t, etc.
#if defined(_WIN32)
// There's no <stdint.h> in Visual Studio 9, so we have to define [u]int*_t.
@@ -75,6 +75,8 @@
# define INT64_MAX (__INT64_C(9223372036854775807))
# define UINT64_MAX (__UINT64_C(18446744073709551615))
+#define ASAN_DEFAULT_FAILURE_EXITCODE 1
+
#if defined(__linux__)
# define ASAN_LINUX 1
#else
@@ -229,6 +231,7 @@
void AsanDie();
void SleepForSeconds(int seconds);
void Exit(int exitcode);
+int Atexit(void (*function)(void));
#define CHECK(cond) do { if (!(cond)) { \
CheckFailed(#cond, __FILE__, __LINE__); \
Modified: compiler-rt/trunk/lib/asan/asan_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_posix.cc?rev=151162&r1=151161&r2=151162&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Wed Feb 22 08:07:06 2012
@@ -21,6 +21,7 @@
#include <pthread.h>
#include <signal.h>
+#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
@@ -99,6 +100,10 @@
return _exit(exitcode);
}
+int Atexit(void (*function)(void)) {
+ return atexit(function);
+}
+
int AtomicInc(int *a) {
#ifdef ANDROID
return __atomic_inc(a) + 1;
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151162&r1=151161&r2=151162&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Feb 22 08:07:06 2012
@@ -44,7 +44,7 @@
bool FLAG_replace_cfallocator; // Used on Mac only.
size_t FLAG_max_malloc_fill_size = 0;
bool FLAG_use_fake_stack;
-int FLAG_exitcode = EXIT_FAILURE;
+int FLAG_exitcode = ASAN_DEFAULT_FAILURE_EXITCODE;
bool FLAG_allow_user_poisoning;
int FLAG_sleep_before_dying;
@@ -433,13 +433,14 @@
FLAG_replace_str = IntFlagValue(options, "replace_str=", 1);
FLAG_replace_intrin = IntFlagValue(options, "replace_intrin=", 1);
FLAG_use_fake_stack = IntFlagValue(options, "use_fake_stack=", 1);
- FLAG_exitcode = IntFlagValue(options, "exitcode=", EXIT_FAILURE);
+ FLAG_exitcode = IntFlagValue(options, "exitcode=",
+ ASAN_DEFAULT_FAILURE_EXITCODE);
FLAG_allow_user_poisoning = IntFlagValue(options,
"allow_user_poisoning=", 1);
FLAG_sleep_before_dying = IntFlagValue(options, "sleep_before_dying=", 0);
if (FLAG_atexit) {
- atexit(asan_atexit);
+ Atexit(asan_atexit);
}
// interceptors
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=151162&r1=151161&r2=151162&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Wed Feb 22 08:07:06 2012
@@ -16,6 +16,7 @@
#include <dbghelp.h>
#include <stdio.h> // FIXME: get rid of this.
+#include <stdlib.h>
#include <new> // FIXME: temporarily needed for placement new in AsanLock.
@@ -262,6 +263,10 @@
_exit(exitcode);
}
+int Atexit(void (*function)(void)) {
+ return atexit(function);
+}
+
} // namespace __asan
#endif // _WIN32
More information about the llvm-commits
mailing list