summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorMarcin Koscielnicki <koriakin@0x04.net>2016-04-15 22:11:10 +0000
committerMarcin Koscielnicki <koriakin@0x04.net>2016-04-15 22:11:10 +0000
commit604d873aa162335bbbdc17a7ad1d43cc7284ff12 (patch)
tree09c256148fd7829f9cf5463a5bf5d0b7076e0d6a /compiler-rt
parentdc75a6b517db0309d00e0cd456608ecca3d6452e (diff)
downloadbcm5719-llvm-604d873aa162335bbbdc17a7ad1d43cc7284ff12.tar.gz
bcm5719-llvm-604d873aa162335bbbdc17a7ad1d43cc7284ff12.zip
[sanitizers] [SystemZ] Introduce sanitizer_linux_s390.cc.
This file will contain s390-specific code. For now, let's move the s390 version of internal_mmap here. Differential Revision: http://reviews.llvm.org/D19174 llvm-svn: 266482
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/sanitizer_common/CMakeLists.txt1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux.cc29
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cc57
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_platform.h15
4 files changed, 76 insertions, 26 deletions
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 5d197a472f6..2afb946186d 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -11,6 +11,7 @@ set(SANITIZER_SOURCES
sanitizer_libc.cc
sanitizer_libignore.cc
sanitizer_linux.cc
+ sanitizer_linux_s390.cc
sanitizer_mac.cc
sanitizer_persistent_allocator.cc
sanitizer_platform_limits_linux.cc
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
index d0d30e96f36..bb30b759e0f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
@@ -110,34 +110,10 @@ namespace __sanitizer {
#endif
// --------------- sanitizer_libc.h
+#if !SANITIZER_S390
uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
OFF_T offset) {
-#ifdef __s390__
- struct s390_mmap_params {
- unsigned long addr;
- unsigned long length;
- unsigned long prot;
- unsigned long flags;
- unsigned long fd;
- unsigned long offset;
- } params = {
- (unsigned long)addr,
- (unsigned long)length,
- (unsigned long)prot,
- (unsigned long)flags,
- (unsigned long)fd,
-# ifdef __s390x__
- (unsigned long)offset,
-# else
- (unsigned long)(offset / 4096),
-# endif
- };
-# ifdef __s390x__
- return internal_syscall(SYSCALL(mmap), &params);
-# else
- return internal_syscall(SYSCALL(mmap2), &params);
-# endif
-#elif SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
+#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
offset);
#else
@@ -147,6 +123,7 @@ uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
offset / 4096);
#endif
}
+#endif // !SANITIZER_S390
uptr internal_munmap(void *addr, uptr length) {
return internal_syscall(SYSCALL(munmap), (uptr)addr, length);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cc
new file mode 100644
index 00000000000..07546286c87
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_s390.cc
@@ -0,0 +1,57 @@
+//===-- sanitizer_linux_s390.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 s390-linux-specific functions from
+// sanitizer_libc.h.
+//===----------------------------------------------------------------------===//
+
+#include "sanitizer_platform.h"
+
+#if SANITIZER_LINUX && SANITIZER_S390
+
+#include "sanitizer_linux.h"
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+namespace __sanitizer {
+
+// --------------- sanitizer_libc.h
+uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
+ OFF_T offset) {
+ struct s390_mmap_params {
+ unsigned long addr;
+ unsigned long length;
+ unsigned long prot;
+ unsigned long flags;
+ unsigned long fd;
+ unsigned long offset;
+ } params = {
+ (unsigned long)addr,
+ (unsigned long)length,
+ (unsigned long)prot,
+ (unsigned long)flags,
+ (unsigned long)fd,
+# ifdef __s390x__
+ (unsigned long)offset,
+# else
+ (unsigned long)(offset / 4096),
+# endif
+ };
+# ifdef __s390x__
+ return syscall(__NR_mmap, &params);
+# else
+ return syscall(__NR_mmap2, &params);
+# endif
+}
+
+} // namespace __sanitizer
+
+#endif // SANITIZER_LINUX && SANITIZER_S390
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
index 72240ae843c..3990158522a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform.h
@@ -108,6 +108,21 @@
# define SANITIZER_MIPS64 0
#endif
+#if defined(__s390__)
+# define SANITIZER_S390 1
+# if defined(__s390x__)
+# define SANITIZER_S390_31 0
+# define SANITIZER_S390_64 1
+# else
+# define SANITIZER_S390_31 1
+# define SANITIZER_S390_64 0
+# endif
+#else
+# define SANITIZER_S390 0
+# define SANITIZER_S390_31 0
+# define SANITIZER_S390_64 0
+#endif
+
// By default we allow to use SizeClassAllocator64 on 64-bit platform.
// But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
// does not work well and we need to fallback to SizeClassAllocator32.
OpenPOWER on IntegriCloud