]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: implement Msync for Windows using FlushViewOfFile
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 2 Oct 2019 09:25:24 +0000 (11:25 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 2 Oct 2019 09:45:12 +0000 (09:45 +0000)
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 <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/outbuf_windows.go

index 4366a83c332d3e2104d9bb30764dd13a537887f5..1cb05c301f32109010441659522f1c8200ee6b80 100644 (file)
@@ -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)
 }