File: advise_linux.go

package info (click to toggle)
golang-github-tinylib-msgp 1.2.0-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 764 kB
  • sloc: makefile: 47
file content (25 lines) | stat: -rw-r--r-- 468 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//go:build linux && !appengine && !tinygo
// +build linux,!appengine,!tinygo

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
}