Merge pull request #5027 from Apsalar/solaris-tsm1-issue#4787
fix tsm1 for Solaris #4787, passes unit tests nowpull/5029/head
commit
f7b8321228
|
@ -0,0 +1,32 @@
|
|||
// +build solaris
|
||||
|
||||
package tsm1
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func mmap(f *os.File, offset int64, length int) ([]byte, error) {
|
||||
mmap, err := unix.Mmap(int(f.Fd()), 0, length, syscall.PROT_READ, syscall.MAP_SHARED)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := unix.Madvise(mmap, syscall.MADV_RANDOM); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mmap, nil
|
||||
}
|
||||
|
||||
func munmap(b []byte) (err error) {
|
||||
return unix.Munmap(b)
|
||||
}
|
||||
|
||||
// From: github.com/boltdb/bolt/bolt_unix.go
|
||||
func madvise(b []byte, advice int) (err error) {
|
||||
return unix.Madvise(b, advice)
|
||||
}
|
Loading…
Reference in New Issue