2016-12-09 09:00:14 +00:00
|
|
|
// +build !windows,!plan9,!solaris
|
|
|
|
|
|
|
|
package tsdb
|
|
|
|
|
2016-12-11 14:49:36 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
func mmap(f *os.File, length int) ([]byte, error) {
|
|
|
|
return unix.Mmap(int(f.Fd()), 0, length, unix.PROT_READ, unix.MAP_SHARED)
|
|
|
|
}
|
|
|
|
|
|
|
|
func munmap(b []byte) (err error) {
|
|
|
|
return unix.Munmap(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
// unix.Madvise is not defined for darwin, so we define it ourselves.
|
|
|
|
func madvise(b []byte, advice int) (err error) {
|
|
|
|
_, _, e1 := unix.Syscall(unix.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice))
|
|
|
|
if e1 != 0 {
|
|
|
|
err = e1
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|