blob: f105ff040cbccf53c5e5bf35a21642c556f5c006 [file] [log] [blame]
Alexey Samsonov2c5fc3b2012-06-04 14:27:50 +00001//===-- sanitizer_linux.cc ------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is shared between AddressSanitizer and ThreadSanitizer
11// run-time libraries and implements linux-specific functions from
12// sanitizer_libc.h.
13//===----------------------------------------------------------------------===//
14#ifdef __linux__
15
16#include "sanitizer_defs.h"
17#include "sanitizer_libc.h"
18
19#include <sys/mman.h>
20#include <sys/syscall.h>
21#include <sys/types.h>
22#include <unistd.h>
23
24namespace __sanitizer {
25
26void *internal_mmap(void *addr, uptr length, int prot, int flags,
27 int fd, u64 offset) {
28#if __WORDSIZE == 64
29 return (void *)syscall(__NR_mmap, addr, length, prot, flags, fd, offset);
30#else
31 return (void *)syscall(__NR_mmap2, addr, length, prot, flags, fd, offset);
32#endif
33}
34
35} // namespace __sanitizer
36
37#endif // __linux__