aboutsummaryrefslogtreecommitdiff
path: root/bolt_darwin.go
blob: 557de72fa6938e2d4a903bb11626abcf318e1b91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package bolt

import (
	"os"
	"syscall"
)

var odirect int

// fdatasync flushes written data to a file descriptor.
func fdatasync(f *os.File) error {
	return f.Sync()
}

// flock acquires an advisory lock on a file descriptor.
func flock(f *os.File) error {
	return syscall.Flock(int(f.Fd()), syscall.LOCK_EX)
}

// funlock releases an advisory lock on a file descriptor.
func funlock(f *os.File) error {
	return syscall.Flock(int(f.Fd()), syscall.LOCK_UN)
}

// mmap memory maps a file to a byte slice.
func mmap(f *os.File, sz int) ([]byte, error) {
	return syscall.Mmap(int(f.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED)
}

// munmap unmaps a pointer from a file.
func munmap(b []byte) error {
	return syscall.Munmap(b)
}