diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-09-22 11:53:19 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-09-22 11:53:19 -0600 |
commit | d285804df1760edf4c602ecd901be5d5e67bf982 (patch) | |
tree | a69b6978e0c1231f5f051aabe6d16c7e9744c2c6 /bolt_openbsd.go | |
parent | Merge pull request #258 from davecgh/davec_build (diff) | |
parent | Fix bolt on OpenBSD. (diff) | |
download | dedo-d285804df1760edf4c602ecd901be5d5e67bf982.tar.gz dedo-d285804df1760edf4c602ecd901be5d5e67bf982.tar.xz |
Merge pull request #259 from davecgh/jrick_msync
Fix bolt on OpenBSD
Diffstat (limited to 'bolt_openbsd.go')
-rw-r--r-- | bolt_openbsd.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bolt_openbsd.go b/bolt_openbsd.go new file mode 100644 index 0000000..7c1bef1 --- /dev/null +++ b/bolt_openbsd.go @@ -0,0 +1,29 @@ +package bolt + +import ( + "syscall" + "unsafe" +) + +const ( + msAsync = 1 << iota // perform asynchronous writes + msSync // perform synchronous writes + msInvalidate // invalidate cached data +) + +var odirect int + +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 +} + +func fdatasync(db *DB) error { + if db.data != nil { + return msync(db) + } + return db.file.Sync() +} |