Skip to content

Commit 1108915

Browse files
jrickahrtr
authored andcommitted
Avoid syscall.Syscall use on OpenBSD
Syscall numbers are not stable on OpenBSD, and hardcoding the msync syscall number will break bbolt on future versions of OpenBSD. Use the libc wrapper provided by golang.org/x/sys/unix instead. Signed-off-by: Josh Rickmar <[email protected]>
1 parent da2f2a5 commit 1108915

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

bolt_openbsd.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
package bbolt
22

33
import (
4-
"syscall"
5-
"unsafe"
6-
)
7-
8-
const (
9-
msAsync = 1 << iota // perform asynchronous writes
10-
msSync // perform synchronous writes
11-
msInvalidate // invalidate cached data
4+
"golang.org/x/sys/unix"
125
)
136

147
func msync(db *DB) error {
15-
_, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate)
16-
if errno != 0 {
17-
return errno
18-
}
19-
return nil
8+
return unix.Msync(db.data[:db.datasz], unix.MS_INVALIDATE)
209
}
2110

2211
func fdatasync(db *DB) error {

0 commit comments

Comments
 (0)