github.com/ooni/psiphon/tunnel-core@v0.0.0-20230105123940-fe12a24c96ee/oovendor/bolt/bolt_openbsd.go (about)

     1  package bolt
     2  
     3  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
    12  )
    13  
    14  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
    20  }
    21  
    22  func fdatasync(db *DB) error {
    23  	if db.data != nil {
    24  		return msync(db)
    25  	}
    26  	return db.file.Sync()
    27  }