From 2623a412c42a81104b97ae8c81a5f66760fee4b6 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 19 Mar 2022 22:04:13 +0100 Subject: Update vendor (whatsapp) --- vendor/modernc.org/memory/mmap_unix.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'vendor/modernc.org/memory/mmap_unix.go') diff --git a/vendor/modernc.org/memory/mmap_unix.go b/vendor/modernc.org/memory/mmap_unix.go index 8fee87e6..d076ad03 100644 --- a/vendor/modernc.org/memory/mmap_unix.go +++ b/vendor/modernc.org/memory/mmap_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE-MMAP-GO file. +//go:build darwin || dragonfly || freebsd || linux || openbsd || solaris || netbsd // +build darwin dragonfly freebsd linux openbsd solaris netbsd // Modifications (c) 2017 The Memory Authors. @@ -11,7 +12,6 @@ package memory // import "modernc.org/memory" import ( "os" "syscall" - "unsafe" ) const pageSizeLog = 20 @@ -33,13 +33,17 @@ func unmap(addr uintptr, size int) error { // pageSize aligned. func mmap(size int) (uintptr, int, error) { size = roundup(size, osPageSize) - b, err := syscall.Mmap(-1, 0, size+pageSize, syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_SHARED|syscall.MAP_ANON) + // The actual mmap syscall varies by architecture. mmapSyscall provides same + // functionality as the unexported funtion syscall.mmap and is declared in + // mmap_*_*.go and mmap_fallback.go. To add support for a new architecture, + // check function mmap in src/syscall/syscall_*_*.go or + // src/syscall/zsyscall_*_*.go in Go's source code. + p, err := mmapSyscall(0, uintptr(size+pageSize), syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_PRIVATE|syscall.MAP_ANON, -1, 0) if err != nil { return 0, 0, err } - n := len(b) - p := uintptr(unsafe.Pointer(&b[0])) + n := size + pageSize if p&uintptr(osPageMask) != 0 { panic("internal error") } -- cgit v1.2.3