blob: 80ecad2aae53d4b21b38df81e7e73514bffba465 [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 Samsonov03c8b842012-06-05 08:32:53 +000024#include <unistd.h>
Alexey Samsonov2c5fc3b2012-06-04 14:27:50 +000025
26namespace __sanitizer {
27
28void *internal_mmap(void *addr, size_t length, int prot, int flags,
29 int fd, u64 offset) {
30 return mmap(addr, length, prot, flags, fd, offset);
31}
32
Alexey Samsonov7ac77d62012-06-05 09:49:25 +000033int internal_munmap(void *addr, uptr length) {
34 return munmap(addr, length);
35}
36
Alexey Samsonov03c8b842012-06-05 08:32:53 +000037int internal_close(fd_t fd) {
38 return close(fd);
39}
40
Alexey Samsonovdde1f112012-06-05 07:05:10 +000041fd_t internal_open(const char *filename, bool write) {
42 return open(filename,
Alexey Samsonov3768b582012-06-05 14:07:11 +000043 write ? O_WRONLY | O_CREAT : O_RDONLY, 0660);
Alexey Samsonovdde1f112012-06-05 07:05:10 +000044}
45
Alexey Samsonov03c8b842012-06-05 08:32:53 +000046uptr internal_read(fd_t fd, void *buf, uptr count) {
47 return read(fd, buf, count);
48}
49
50uptr internal_write(fd_t fd, const void *buf, uptr count) {
51 return write(fd, buf, count);
52}
53
Alexey Samsonov2c5fc3b2012-06-04 14:27:50 +000054} // namespace __sanitizer
55
56#endif // __APPLE__