From 274f4cef9329262dcfd4a715ab6c2ebc908d6209 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 2 Oct 2019 11:25:24 +0200 Subject: [PATCH] cmd/link: implement Msync for Windows using FlushViewOfFile CL 196846 implemented memory mapped output files but forgot to provide an implementation for Msync. This rectifies that with a simple call to FlushViewOfFile. Change-Id: I5aebef9baf3a2a6ad54ceda096952a5d7d660bfe Reviewed-on: https://go-review.googlesource.com/c/go/+/198418 Run-TryBot: Jason A. Donenfeld Reviewed-by: Alex Brainman TryBot-Result: Gobot Gobot --- src/cmd/link/internal/ld/outbuf_windows.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/link/internal/ld/outbuf_windows.go b/src/cmd/link/internal/ld/outbuf_windows.go index 4366a83c332..1cb05c301f3 100644 --- a/src/cmd/link/internal/ld/outbuf_windows.go +++ b/src/cmd/link/internal/ld/outbuf_windows.go @@ -42,6 +42,8 @@ func (out *OutBuf) Munmap() { } func (out *OutBuf) Msync() error { - // does nothing on windows - return nil + if out.buf == nil { + return nil + } + return syscall.FlushViewOfFile(uintptr(unsafe.Pointer(&out.buf[0])), 0) }