[llvm-commits] [compiler-rt] r158493 - in /compiler-rt/trunk/lib: asan/asan_internal.h asan/asan_posix.cc asan/asan_thread_registry.cc asan/asan_win.cc sanitizer_common/sanitizer_common.h sanitizer_common/sanitizer_posix.cc sanitizer_common/sanitizer_win.cc
Alexey Samsonov
samsonov at google.com
Thu Jun 14 23:37:34 PDT 2012
Author: samsonov
Date: Fri Jun 15 01:37:34 2012
New Revision: 158493
URL: http://llvm.org/viewvc/llvm-project?rev=158493&view=rev
Log:
[Sanitizer] move more portability wrappers to common runtime: sleep, _exit, abort, atexit, pthread_self
Modified:
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_posix.cc
compiler-rt/trunk/lib/asan/asan_thread_registry.cc
compiler-rt/trunk/lib/asan/asan_win.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
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=158493&r1=158492&r2=158493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Fri Jun 15 01:37:34 2012
@@ -129,7 +129,6 @@
void SetAlternateSignalStack();
void UnsetAlternateSignalStack();
void InstallSignalHandlers();
-uptr GetThreadSelf();
int AtomicInc(int *a);
u16 AtomicExchange(u16 *a, u16 new_val);
u8 AtomicExchange(u8 *a, u8 new_val);
@@ -200,11 +199,6 @@
enum LinkerInitialized { LINKER_INITIALIZED = 0 };
-void SleepForSeconds(int seconds);
-void NORETURN Exit(int exitcode);
-void NORETURN Abort();
-int Atexit(void (*function)(void));
-
#define ASAN_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
#if !defined(_WIN32) || defined(__clang__)
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=158493&r1=158492&r2=158493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_posix.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_posix.cc Fri Jun 15 01:37:34 2012
@@ -134,26 +134,6 @@
MaybeInstallSigaction(SIGBUS, ASAN_OnSIGSEGV);
}
-uptr GetThreadSelf() {
- return (uptr)pthread_self();
-}
-
-void SleepForSeconds(int seconds) {
- sleep(seconds);
-}
-
-void Exit(int exitcode) {
- _exit(exitcode);
-}
-
-void Abort() {
- abort();
-}
-
-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_thread_registry.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread_registry.cc?rev=158493&r1=158492&r2=158493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_thread_registry.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_thread_registry.cc Fri Jun 15 01:37:34 2012
@@ -16,6 +16,7 @@
#include "asan_stack.h"
#include "asan_thread.h"
#include "asan_thread_registry.h"
+#include "sanitizer_common/sanitizer_common.h"
namespace __asan {
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=158493&r1=158492&r2=158493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Fri Jun 15 01:37:34 2012
@@ -192,10 +192,6 @@
return t;
}
-uptr GetThreadSelf() {
- return GetCurrentThreadId();
-}
-
void SetAlternateSignalStack() {
// FIXME: Decide what to do on Windows.
}
@@ -208,23 +204,6 @@
// FIXME: Decide what to do on Windows.
}
-void SleepForSeconds(int seconds) {
- Sleep(seconds * 1000);
-}
-
-void Exit(int exitcode) {
- _exit(exitcode);
-}
-
-void Abort() {
- abort();
- _exit(-1); // abort is not NORETURN on Windows.
-}
-
-int Atexit(void (*function)(void)) {
- return atexit(function);
-}
-
void SortArray(uptr *array, uptr size) {
std::sort(array, array + size);
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=158493&r1=158492&r2=158493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Fri Jun 15 01:37:34 2012
@@ -28,6 +28,7 @@
// Threads
int GetPid();
+uptr GetThreadSelf();
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
uptr *stack_bottom);
@@ -58,6 +59,10 @@
// Other
void DisableCoreDumper();
void DumpProcessMap();
+void SleepForSeconds(int seconds);
+void NORETURN Exit(int exitcode);
+void NORETURN Abort();
+int Atexit(void (*function)(void));
// Bit twiddling.
inline bool IsPowerOfTwo(uptr x) {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=158493&r1=158492&r2=158493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Fri Jun 15 01:37:34 2012
@@ -17,8 +17,10 @@
#include "sanitizer_libc.h"
#include "sanitizer_procmaps.h"
+#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/time.h>
@@ -33,6 +35,10 @@
return getpid();
}
+uptr GetThreadSelf() {
+ return (uptr)pthread_self();
+}
+
void *MmapOrDie(uptr size, const char *mem_type) {
size = RoundUpTo(size, kPageSize);
void *res = internal_mmap(0, size,
@@ -90,6 +96,22 @@
setrlimit(RLIMIT_CORE, &nocore);
}
+void SleepForSeconds(int seconds) {
+ sleep(seconds);
+}
+
+void Exit(int exitcode) {
+ _exit(exitcode);
+}
+
+void Abort() {
+ abort();
+}
+
+int Atexit(void (*function)(void)) {
+ return atexit(function);
+}
+
// -------------- sanitizer_libc.h
int internal_sscanf(const char *str, const char *format, ...) {
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=158493&r1=158492&r2=158493&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Fri Jun 15 01:37:34 2012
@@ -24,6 +24,10 @@
return GetProcessId(GetCurrentProcess());
}
+uptr GetThreadSelf() {
+ return GetCurrentThreadId();
+}
+
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
uptr *stack_bottom) {
CHECK(stack_top);
@@ -90,6 +94,23 @@
UNIMPLEMENTED();
}
+void SleepForSeconds(int seconds) {
+ Sleep(seconds * 1000);
+}
+
+void Exit(int exitcode) {
+ _exit(exitcode);
+}
+
+void Abort() {
+ abort();
+ _exit(-1); // abort is not NORETURN on Windows.
+}
+
+int Atexit(void (*function)(void)) {
+ return atexit(function);
+}
+
// ------------------ sanitizer_libc.h
void *internal_mmap(void *addr, uptr length, int prot, int flags,
int fd, u64 offset) {
More information about the llvm-commits
mailing list