-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tsm1 for Solaris #4787, passes unit tests now
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// +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) | ||
} |