blob: 84fd11b39b65d0d807d236f789c70b418653af8a [file] [log] [blame]
Alexey Samsonov2c5fc3b2012-06-04 14:27:50 +00001//===-- sanitizer_mac.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 mac-specific functions from
12// sanitizer_libc.h.
13//===----------------------------------------------------------------------===//
14
15#ifdef __APPLE__
16
17#include "sanitizer_defs.h"
18#include "sanitizer_libc.h"
19
20#include <sys/mman.h>
Alexey Samsonovdde1f112012-06-05 07:05:10 +000021#include <sys/stat.h>
22#include <sys/types.h>
23#include <fcntl.h>
Alexey Samsonov2c5fc3b2012-06-04 14:27:50 +000024
25namespace __sanitizer {
26
27void *internal_mmap(void *addr, size_t length, int prot, int flags,
28 int fd, u64 offset) {
29 return mmap(addr, length, prot, flags, fd, offset);
30}
31
Alexey Samsonovdde1f112012-06-05 07:05:10 +000032fd_t internal_open(const char *filename, bool write) {
33 return open(filename,
34 write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660);
35}
36
Alexey Samsonov2c5fc3b2012-06-04 14:27:50 +000037} // namespace __sanitizer
38
39#endif // __APPLE__