blob: d7f50358ef141e742dee34ca42168af0dc0d2291 [file] [log] [blame]
khenaidooab1f7bd2019-11-14 14:00:27 -05001package bbolt
2
3import (
4 "syscall"
5 "unsafe"
6)
7
8const (
9 msAsync = 1 << iota // perform asynchronous writes
10 msSync // perform synchronous writes
11 msInvalidate // invalidate cached data
12)
13
14func 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
22func fdatasync(db *DB) error {
23 if db.data != nil {
24 return msync(db)
25 }
26 return db.file.Sync()
27}