From c2577db1c22e0bb64ea3df16e9424e6dce1d55ab Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 11 Jun 2014 11:11:21 -0600 Subject: Add Windows support. --- bolt_linux.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'bolt_linux.go') diff --git a/bolt_linux.go b/bolt_linux.go index 4351db5..9aba955 100644 --- a/bolt_linux.go +++ b/bolt_linux.go @@ -7,6 +7,27 @@ import ( var odirect = syscall.O_DIRECT +// fdatasync flushes written data to a file descriptor. func fdatasync(f *os.File) error { return syscall.Fdatasync(int(f.Fd())) } + +// 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) +} -- cgit v1.2.3