Index: lib/sanitizer_common/CMakeLists.txt =================================================================== --- lib/sanitizer_common/CMakeLists.txt +++ lib/sanitizer_common/CMakeLists.txt @@ -11,6 +11,7 @@ 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 Index: lib/sanitizer_common/sanitizer_linux.cc =================================================================== --- lib/sanitizer_common/sanitizer_linux.cc +++ lib/sanitizer_common/sanitizer_linux.cc @@ -111,34 +111,10 @@ #endif // --------------- sanitizer_libc.h +#ifndef __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), ¶ms); -# else - return internal_syscall(SYSCALL(mmap2), ¶ms); -# 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 @@ -148,6 +124,7 @@ offset / 4096); #endif } +#endif uptr internal_munmap(void *addr, uptr length) { return internal_syscall(SYSCALL(munmap), (uptr)addr, length); Index: lib/sanitizer_common/sanitizer_linux_s390.cc =================================================================== --- /dev/null +++ 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 && defined(__s390__) + +#include "sanitizer_linux.h" + +#include +#include + +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, ¶ms); +# else + return syscall(__NR_mmap2, ¶ms); +# endif +} + +} // namespace __sanitizer + +#endif // SANITIZER_LINUX && defined(__s390__)