[compiler-rt] r182366 - [nolibc] Move libc-dependent sanitizer_posix.cc code to sanitizer_posix_libcdep.cc.
Peter Collingbourne
peter at pcc.me.uk
Tue May 21 03:27:07 PDT 2013
Author: pcc
Date: Tue May 21 05:27:07 2013
New Revision: 182366
URL: http://llvm.org/viewvc/llvm-project?rev=182366&view=rev
Log:
[nolibc] Move libc-dependent sanitizer_posix.cc code to sanitizer_posix_libcdep.cc.
Added:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
Modified:
compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/trunk/lib/tsan/go/buildgo.sh
Modified: compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt?rev=182366&r1=182365&r2=182366&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/CMakeLists.txt Tue May 21 05:27:07 2013
@@ -26,6 +26,7 @@ set(SANITIZER_SOURCES
set(SANITIZER_LIBCDEP_SOURCES
sanitizer_common_libcdep.cc
sanitizer_linux_libcdep.cc
+ sanitizer_posix_libcdep.cc
)
# Explicitly list all sanitizer_common headers. Not all of these are
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=182366&r1=182365&r2=182366&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Tue May 21 05:27:07 2013
@@ -20,17 +20,7 @@
#include "sanitizer_procmaps.h"
#include "sanitizer_stacktrace.h"
-#include <errno.h>
-#include <pthread.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/mman.h>
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
namespace __sanitizer {
@@ -39,14 +29,6 @@ uptr GetMmapGranularity() {
return GetPageSize();
}
-u32 GetUid() {
- return getuid();
-}
-
-uptr GetThreadSelf() {
- return (uptr)pthread_self();
-}
-
void *MmapOrDie(uptr size, const char *mem_type) {
size = RoundUpTo(size, GetPageSizeCached());
uptr res = internal_mmap(0, size,
@@ -119,10 +101,6 @@ void *Mprotect(uptr fixed_addr, uptr siz
MAP_NORESERVE, -1, 0);
}
-void FlushUnneededShadowMemory(uptr addr, uptr size) {
- madvise((void*)addr, size, MADV_DONTNEED);
-}
-
void *MapFileToMemory(const char *file_name, uptr *buff_size) {
uptr openrv = OpenFile(file_name, false);
CHECK(!internal_iserror(openrv));
@@ -177,76 +155,6 @@ const char *GetPwd() {
return GetEnv("PWD");
}
-void DisableCoreDumper() {
- struct rlimit nocore;
- nocore.rlim_cur = 0;
- nocore.rlim_max = 0;
- setrlimit(RLIMIT_CORE, &nocore);
-}
-
-bool StackSizeIsUnlimited() {
- struct rlimit rlim;
- CHECK_EQ(0, getrlimit(RLIMIT_STACK, &rlim));
- return (rlim.rlim_cur == (uptr)-1);
-}
-
-void SetStackSizeLimitInBytes(uptr limit) {
- struct rlimit rlim;
- rlim.rlim_cur = limit;
- rlim.rlim_max = limit;
- if (setrlimit(RLIMIT_STACK, &rlim)) {
- Report("ERROR: %s setrlimit() failed %d\n", SanitizerToolName, errno);
- Die();
- }
- CHECK(!StackSizeIsUnlimited());
-}
-
-void SleepForSeconds(int seconds) {
- sleep(seconds);
-}
-
-void SleepForMillis(int millis) {
- usleep(millis * 1000);
-}
-
-void Abort() {
- abort();
-}
-
-int Atexit(void (*function)(void)) {
-#ifndef SANITIZER_GO
- return atexit(function);
-#else
- return 0;
-#endif
-}
-
-int internal_isatty(fd_t fd) {
- return isatty(fd);
-}
-
-#ifndef SANITIZER_GO
-void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp,
- uptr stack_top, uptr stack_bottom, bool fast) {
-#if !SANITIZER_CAN_FAST_UNWIND
- fast = false;
-#endif
-#if SANITIZER_MAC
- // Always unwind fast on Mac.
- (void)fast;
-#else
- if (!fast || (stack_top == stack_bottom))
- return stack->SlowUnwindStack(pc, max_s);
-#endif // SANITIZER_MAC
- stack->size = 0;
- stack->trace[0] = pc;
- if (max_s > 1) {
- stack->max_size = max_s;
- stack->FastUnwindStack(pc, bp, stack_top, stack_bottom);
- }
-}
-#endif // SANITIZER_GO
-
} // namespace __sanitizer
#endif // SANITIZER_LINUX || SANITIZER_MAC
Added: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc?rev=182366&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc (added)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc Tue May 21 05:27:07 2013
@@ -0,0 +1,116 @@
+//===-- sanitizer_posix_libcdep.cc ----------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is shared between AddressSanitizer and ThreadSanitizer
+// run-time libraries and implements libc-dependent POSIX-specific functions
+// from sanitizer_libc.h.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_platform.h"
+
+#if SANITIZER_LINUX || SANITIZER_MAC
+#include "sanitizer_common.h"
+#include "sanitizer_stacktrace.h"
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+namespace __sanitizer {
+
+u32 GetUid() {
+ return getuid();
+}
+
+uptr GetThreadSelf() {
+ return (uptr)pthread_self();
+}
+
+void FlushUnneededShadowMemory(uptr addr, uptr size) {
+ madvise((void*)addr, size, MADV_DONTNEED);
+}
+
+void DisableCoreDumper() {
+ struct rlimit nocore;
+ nocore.rlim_cur = 0;
+ nocore.rlim_max = 0;
+ setrlimit(RLIMIT_CORE, &nocore);
+}
+
+bool StackSizeIsUnlimited() {
+ struct rlimit rlim;
+ CHECK_EQ(0, getrlimit(RLIMIT_STACK, &rlim));
+ return (rlim.rlim_cur == (uptr)-1);
+}
+
+void SetStackSizeLimitInBytes(uptr limit) {
+ struct rlimit rlim;
+ rlim.rlim_cur = limit;
+ rlim.rlim_max = limit;
+ if (setrlimit(RLIMIT_STACK, &rlim)) {
+ Report("ERROR: %s setrlimit() failed %d\n", SanitizerToolName, errno);
+ Die();
+ }
+ CHECK(!StackSizeIsUnlimited());
+}
+
+void SleepForSeconds(int seconds) {
+ sleep(seconds);
+}
+
+void SleepForMillis(int millis) {
+ usleep(millis * 1000);
+}
+
+void Abort() {
+ abort();
+}
+
+int Atexit(void (*function)(void)) {
+#ifndef SANITIZER_GO
+ return atexit(function);
+#else
+ return 0;
+#endif
+}
+
+int internal_isatty(fd_t fd) {
+ return isatty(fd);
+}
+
+#ifndef SANITIZER_GO
+void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp,
+ uptr stack_top, uptr stack_bottom, bool fast) {
+#if !SANITIZER_CAN_FAST_UNWIND
+ fast = false;
+#endif
+#if SANITIZER_MAC
+ // Always unwind fast on Mac.
+ (void)fast;
+#else
+ if (!fast || (stack_top == stack_bottom))
+ return stack->SlowUnwindStack(pc, max_s);
+#endif // SANITIZER_MAC
+ stack->size = 0;
+ stack->trace[0] = pc;
+ if (max_s > 1) {
+ stack->max_size = max_s;
+ stack->FastUnwindStack(pc, bp, stack_top, stack_bottom);
+ }
+}
+#endif // SANITIZER_GO
+
+} // namespace __sanitizer
+
+#endif
Modified: compiler-rt/trunk/lib/tsan/go/buildgo.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/buildgo.sh?rev=182366&r1=182365&r2=182366&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/buildgo.sh (original)
+++ compiler-rt/trunk/lib/tsan/go/buildgo.sh Tue May 21 05:27:07 2013
@@ -30,6 +30,7 @@ if [ "`uname -a | grep Linux`" != "" ];
SRCS+="
../rtl/tsan_platform_linux.cc
../../sanitizer_common/sanitizer_posix.cc
+ ../../sanitizer_common/sanitizer_posix_libcdep.cc
../../sanitizer_common/sanitizer_linux.cc
../../sanitizer_common/sanitizer_linux_libcdep.cc
"
More information about the llvm-commits
mailing list