Skip to content

Commit

Permalink
Avoid syscall.Syscall use on OpenBSD
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jrick committed Feb 11, 2023
1 parent 505fc0f commit f5e8ebe
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions bolt_openbsd.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package bbolt

import (
"syscall"
"unsafe"
)

const (
msAsync = 1 << iota // perform asynchronous writes
msSync // perform synchronous writes
msInvalidate // invalidate cached data
"golang.org/x/sys/unix"
)

func msync(db *DB) error {
_, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate)
if errno != 0 {
return errno
}
return nil
return unix.Msync(db.data[:db.datasz], unix.MS_INVALIDATE)
}

func fdatasync(db *DB) error {
Expand Down

0 comments on commit f5e8ebe

Please sign in to comment.