github.com/wencode/hack@v0.2.9/mmap/flush_func.go (about) 1 // +build !amd64 2 3 package mmap 4 5 import ( 6 "os" 7 "syscall" 8 ) 9 10 var ( 11 pageSize uintptr = uintptr(os.Getpagesize()) 12 pageSizeMask uintptr = ^(pageSize - 1) 13 ) 14 15 func Flush(addr, length uintptr) uintptr { 16 for pageAddr := uintptr(addr & pageSizeMask); pageAddr < addr+length; pageAddr += pageSize { 17 _, _, err := syscall.Syscall(syscall.SYS_MSYNC, pageAddr, pageSize, syscall.MS_SYNC) 18 if err != 0 { 19 return uintptr(err) 20 } 21 } 22 return 0 23 }