8c9dadf82b
NetBSD doesn't have the right symbols defined in Go for mlockall support. The OS supports it just fine, but the definitions aren't present in Go. If someone wanted to they could add support XOR the values from `sys/mman.h` for `MCL_CURRENT | MCL_FUTURE` which is almost certainly `0x01 | 0x02` but we're not going to do that in code due to the maintenance of a one-off just for NetBSD. PR's welcome.
19 lines
324 B
Go
19 lines
324 B
Go
// +build darwin dragonfly freebsd linux openbsd solaris
|
|
|
|
package mlock
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func init() {
|
|
supported = true
|
|
}
|
|
|
|
func lockMemory() error {
|
|
// Mlockall prevents all current and future pages from being swapped out.
|
|
return unix.Mlockall(syscall.MCL_CURRENT | syscall.MCL_FUTURE)
|
|
}
|