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 <jrick@zettaport.com>
  • Loading branch information
jrick authored and ahrtr committed Feb 16, 2023
1 parent da2f2a5 commit 1108915
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 1108915

Please sign in to comment.