[asan] move more stuff to OS-specific files
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@147647 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc
index f86dc0b..e2057dc 100644
--- a/lib/asan/asan_allocator.cc
+++ b/lib/asan/asan_allocator.cc
@@ -35,10 +35,6 @@
#include "asan_thread.h"
#include "asan_thread_registry.h"
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-
namespace __asan {
#define REDZONE FLAG_redzone
diff --git a/lib/asan/asan_internal.h b/lib/asan/asan_internal.h
index 4207c00..1f078fa 100644
--- a/lib/asan/asan_internal.h
+++ b/lib/asan/asan_internal.h
@@ -99,6 +99,8 @@
void *AsanMmapSomewhereOrDie(size_t size, const char *where);
void AsanUnmapOrDie(void *ptr, size_t size);
+void AsanDisableCoreDumper();
+
ssize_t AsanRead(int fd, void *buf, size_t count);
ssize_t AsanWrite(int fd, const void *buf, size_t count);
int AsanClose(int fd);
diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc
index cb50be9..bd92617 100644
--- a/lib/asan/asan_linux.cc
+++ b/lib/asan/asan_linux.cc
@@ -244,6 +244,12 @@
CHECK(AddrIsInStack((uintptr_t)&attr));
}
+void AsanDisableCoreDumper() {
+ struct rlimit nocore;
+ nocore.rlim_cur = 0;
+ nocore.rlim_max = 0;
+ setrlimit(RLIMIT_CORE, &nocore);
+}
} // namespace __asan
diff --git a/lib/asan/asan_mac.cc b/lib/asan/asan_mac.cc
index 8bedf7a..6d73309 100644
--- a/lib/asan/asan_mac.cc
+++ b/lib/asan/asan_mac.cc
@@ -22,6 +22,7 @@
#include "asan_thread_registry.h"
#include <sys/mman.h>
+#include <sys/resource.h>
#include <pthread.h>
#include <fcntl.h>
#include <unistd.h>
@@ -113,6 +114,13 @@
CHECK(AddrIsInStack((uintptr_t)&local));
}
+void AsanDisableCoreDumper() {
+ struct rlimit nocore;
+ nocore.rlim_cur = 0;
+ nocore.rlim_max = 0;
+ setrlimit(RLIMIT_CORE, &nocore);
+}
+
// Support for the following functions from libdispatch on Mac OS:
// dispatch_async_f()
// dispatch_async()
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc
index 583a971..efd044c 100644
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -26,7 +26,6 @@
#include <new>
#include <dlfcn.h>
-#include <execinfo.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
@@ -40,9 +39,6 @@
#ifndef ANDROID
#include <sys/ucontext.h>
#endif
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <unistd.h>
// must not include <setjmp.h> on Linux
namespace __asan {
@@ -775,10 +771,7 @@
if (__WORDSIZE == 64) {
// Disable core dumper -- it makes little sense to dump 16T+ core.
- struct rlimit nocore;
- nocore.rlim_cur = 0;
- nocore.rlim_max = 0;
- setrlimit(RLIMIT_CORE, &nocore);
+ AsanDisableCoreDumper();
}
{