From 46437cea06b7abd9479371a7872ba5a1c948637e Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Sat, 11 Feb 2023 18:34:36 +0000 Subject: [PATCH] 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 --- bolt_openbsd.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/bolt_openbsd.go b/bolt_openbsd.go index d7f5035..bf47aa1 100644 --- a/bolt_openbsd.go +++ b/bolt_openbsd.go @@ -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 {