llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc

38 lines
1.1 KiB
C++
Raw Normal View History

//===-- sanitizer_linux.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 linux-specific functions from
// sanitizer_libc.h.
//===----------------------------------------------------------------------===//
#ifdef __linux__
#include "sanitizer_defs.h"
#include "sanitizer_libc.h"
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
namespace __sanitizer {
void *internal_mmap(void *addr, uptr length, int prot, int flags,
int fd, u64 offset) {
#if __WORDSIZE == 64
return (void *)syscall(__NR_mmap, addr, length, prot, flags, fd, offset);
#else
return (void *)syscall(__NR_mmap2, addr, length, prot, flags, fd, offset);
#endif
}
} // namespace __sanitizer
#endif // __linux__