File: advise_linux.go

package info (click to toggle)
golang-github-tinylib-msgp 1.0~beta-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 456 kB
  • ctags: 973
  • sloc: makefile: 41
file content (24 lines) | stat: -rw-r--r-- 418 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// +build linux,!appengine

package msgp

import (
	"os"
	"syscall"
)

func adviseRead(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL|syscall.MADV_WILLNEED)
}

func adviseWrite(mem []byte) {
	syscall.Madvise(mem, syscall.MADV_SEQUENTIAL)
}

func fallocate(f *os.File, sz int64) error {
	err := syscall.Fallocate(int(f.Fd()), 0, 0, sz)
	if err == syscall.ENOTSUP {
		return f.Truncate(sz)
	}
	return err
}