diff options
Diffstat (limited to 'vendor/modernc.org/memory')
| -rw-r--r-- | vendor/modernc.org/memory/LICENSE-LOGO | 1 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/Makefile | 29 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/README.md | 4 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/logo.png | bin | 0 -> 11369 bytes | |||
| -rw-r--r-- | vendor/modernc.org/memory/memory.go | 20 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_darwin.go | 19 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_freebsd_32.go | 22 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_freebsd_64.go | 22 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_illumos_amd64.go | 91 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_linux_32.go | 35 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_linux_64.go | 26 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_linux_s390x.go | 23 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_netbsd_32.go | 22 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_netbsd_64.go | 22 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_openbsd.go | 97 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_unix.go | 22 | ||||
| -rw-r--r-- | vendor/modernc.org/memory/mmap_windows.go | 2 |
17 files changed, 42 insertions, 415 deletions
diff --git a/vendor/modernc.org/memory/LICENSE-LOGO b/vendor/modernc.org/memory/LICENSE-LOGO new file mode 100644 index 000000000..ec496d173 --- /dev/null +++ b/vendor/modernc.org/memory/LICENSE-LOGO @@ -0,0 +1 @@ +https://commons.wikimedia.org/wiki/File:Memory_infra_logo.png diff --git a/vendor/modernc.org/memory/Makefile b/vendor/modernc.org/memory/Makefile index f844f1314..40a91322c 100644 --- a/vendor/modernc.org/memory/Makefile +++ b/vendor/modernc.org/memory/Makefile @@ -37,30 +37,59 @@ editor: build_all_targets: GOOS=darwin GOARCH=amd64 go build + GOOS=darwin GOARCH=amd64 staticcheck GOOS=darwin GOARCH=arm64 go build + GOOS=darwin GOARCH=arm64 staticcheck GOOS=freebsd GOARCH=386 go build + GOOS=freebsd GOARCH=386 staticcheck GOOS=freebsd GOARCH=amd64 go build + GOOS=freebsd GOARCH=amd64 staticcheck GOOS=freebsd GOARCH=arm go build + GOOS=freebsd GOARCH=arm staticcheck GOOS=freebsd GOARCH=arm64 go build + GOOS=freebsd GOARCH=arm64 staticcheck GOOS=illumos GOARCH=amd64 go build + GOOS=illumos GOARCH=amd64 staticcheck GOOS=linux GOARCH=386 go build + GOOS=linux GOARCH=386 staticcheck GOOS=linux GOARCH=amd64 go build + GOOS=linux GOARCH=amd64 staticcheck GOOS=linux GOARCH=arm go build + GOOS=linux GOARCH=arm staticcheck GOOS=linux GOARCH=arm64 go build + GOOS=linux GOARCH=arm64 staticcheck GOOS=linux GOARCH=loong64 go build + GOOS=linux GOARCH=loong64 staticcheck GOOS=linux GOARCH=mips go build + GOOS=linux GOARCH=mips staticcheck GOOS=linux GOARCH=mips64le go build + GOOS=linux GOARCH=mips64le staticcheck GOOS=linux GOARCH=mipsle go build + GOOS=linux GOARCH=mipsle staticcheck + GOOS=linux GOARCH=ppc64le go build + GOOS=linux GOARCH=ppc64le staticcheck GOOS=linux GOARCH=riscv64 go build + GOOS=linux GOARCH=riscv64 staticcheck GOOS=linux GOARCH=s390x go build + GOOS=linux GOARCH=s390x staticcheck GOOS=netbsd GOARCH=386 go build + GOOS=netbsd GOARCH=386 staticcheck GOOS=netbsd GOARCH=amd64 go build + GOOS=netbsd GOARCH=amd64 staticcheck GOOS=netbsd GOARCH=arm go build + GOOS=netbsd GOARCH=arm staticcheck GOOS=openbsd GOARCH=386 go build + GOOS=openbsd GOARCH=386 staticcheck GOOS=openbsd GOARCH=amd64 go build + GOOS=openbsd GOARCH=amd64 staticcheck GOOS=openbsd GOARCH=arm64 go build + GOOS=openbsd GOARCH=arm64 staticcheck GOOS=windows GOARCH=386 go build + GOOS=windows GOARCH=386 staticcheck GOOS=windows GOARCH=amd64 go build + GOOS=windows GOARCH=amd64 staticcheck + GOOS=windows GOARCH=arm64 go build + GOOS=windows GOARCH=arm64 staticcheck internalError: egrep -ho '"internal error.*"' *.go | sort | cat -n diff --git a/vendor/modernc.org/memory/README.md b/vendor/modernc.org/memory/README.md index 9354a3650..02c301256 100644 --- a/vendor/modernc.org/memory/README.md +++ b/vendor/modernc.org/memory/README.md @@ -1,4 +1,4 @@ -# memory + Package memory implements a memory allocator. @@ -10,4 +10,4 @@ Installation $ go get modernc.org/memory -Documentation: [godoc.org/modernc.org/memory](http://godoc.org/modernc.org/memory) +[](https://pkg.go.dev/modernc.org/memory) diff --git a/vendor/modernc.org/memory/logo.png b/vendor/modernc.org/memory/logo.png Binary files differnew file mode 100644 index 000000000..ba4eb2013 --- /dev/null +++ b/vendor/modernc.org/memory/logo.png diff --git a/vendor/modernc.org/memory/memory.go b/vendor/modernc.org/memory/memory.go index c6d02df80..e25acda9b 100644 --- a/vendor/modernc.org/memory/memory.go +++ b/vendor/modernc.org/memory/memory.go @@ -57,7 +57,6 @@ import ( "fmt" "math/bits" "os" - "reflect" "unsafe" ) @@ -352,12 +351,7 @@ func (a *Allocator) Calloc(size int) (r []byte, err error) { return nil, err } - var b []byte - sh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - sh.Cap = usableSize(p) - sh.Data = p - sh.Len = size - return b, nil + return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil } // Close releases all OS resources used by a and sets it to its zero value. @@ -396,11 +390,7 @@ func (a *Allocator) Malloc(size int) (r []byte, err error) { return nil, err } - sh := (*reflect.SliceHeader)(unsafe.Pointer(&r)) - sh.Cap = usableSize(p) - sh.Data = p - sh.Len = size - return r, nil + return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil } // Realloc changes the size of the backing array of b to size bytes or returns @@ -422,11 +412,7 @@ func (a *Allocator) Realloc(b []byte, size int) (r []byte, err error) { return nil, err } - sh := (*reflect.SliceHeader)(unsafe.Pointer(&r)) - sh.Cap = usableSize(p) - sh.Data = p - sh.Len = size - return r, nil + return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil } // UsableSize reports the size of the memory block allocated at p, which must diff --git a/vendor/modernc.org/memory/mmap_darwin.go b/vendor/modernc.org/memory/mmap_darwin.go deleted file mode 100644 index d597cb45c..000000000 --- a/vendor/modernc.org/memory/mmap_darwin.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Memory Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build amd64 || arm64 -// +build amd64 arm64 - -package memory - -import ( - _ "unsafe" -) - -// Function syscall.mmap for darwin and openbsd calls internal/abi.FuncPCABI0, -// which is implemented as a compile intrinsic so the code cannot be reused. -// Using go:linkname directive to link mmapSyscall to syscall.mmap - -//go:linkname mmapSyscall syscall.mmap -func mmapSyscall(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) diff --git a/vendor/modernc.org/memory/mmap_freebsd_32.go b/vendor/modernc.org/memory/mmap_freebsd_32.go deleted file mode 100644 index 8b88f1b0e..000000000 --- a/vendor/modernc.org/memory/mmap_freebsd_32.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-GO file. - -//go:build (freebsd && 386) || (freebsd && arm) -// +build freebsd,386 freebsd,arm - -package memory - -import ( - "syscall" -) - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_freebsd_386.go -func mmapSyscall(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { - r0, _, e1 := syscall.Syscall9(syscall.SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0) - ret = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/modernc.org/memory/mmap_freebsd_64.go b/vendor/modernc.org/memory/mmap_freebsd_64.go deleted file mode 100644 index 9a988bca1..000000000 --- a/vendor/modernc.org/memory/mmap_freebsd_64.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-GO file. - -//go:build (freebsd && amd64) || (freebsd && arm64) -// +build freebsd,amd64 freebsd,arm64 - -package memory - -import ( - "syscall" -) - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_freebsd_amd64.go;l=1337-1346 -func mmapSyscall(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { - r0, _, e1 := syscall.Syscall6(syscall.SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) - ret = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/modernc.org/memory/mmap_illumos_amd64.go b/vendor/modernc.org/memory/mmap_illumos_amd64.go deleted file mode 100644 index 1006fe812..000000000 --- a/vendor/modernc.org/memory/mmap_illumos_amd64.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2011 Evan Shaw. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-MMAP-GO file. - -// Modifications (c) 2022 The Memory Authors. - -package memory // import "modernc.org/memory" - -import ( - "os" - "syscall" - _ "unsafe" -) - -const ( - pageSizeLog = 20 - - // $ find /usr/include -name syscall.h - // /usr/include/sys/syscall.h - // $ grep -ni munmap /usr/include/sys/syscall.h - // 293:#define SYS_munmap 117 - // $ grep -ni mmap /usr/include/sys/syscall.h - // 291:#define SYS_mmap 115 - // 303:#define SYS_mmapobj 127 - // 442:#define SYS_mmap64 214 - // $ - // $ uname -a - // SunOS omnios64 5.11 omnios-r151044-d3b715b9d1 i86pc i386 i86pc - // $ - sys_MUNMAP = 117 - sys_MMAP = 214 -) - -var ( - osPageMask = osPageSize - 1 - osPageSize = os.Getpagesize() -) - -//go:linkname mmapSyscall syscall.mmap -func mmapSyscall(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) - -func unmap(addr uintptr, size int) error { - _, _, errno := syscall.Syscall(sys_MUNMAP, addr, uintptr(size), 0) - if errno != 0 { - return errno - } - - return nil -} - -// pageSize aligned. -func mmap(size int) (uintptr, int, error) { - size = roundup(size, osPageSize) - // 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 := size + pageSize - if p&uintptr(osPageMask) != 0 { - panic("internal error") - } - - mod := int(p) & pageMask - if mod != 0 { - m := pageSize - mod - if err := unmap(p, m); err != nil { - return 0, 0, err - } - - n -= m - p += uintptr(m) - } - - if p&uintptr(pageMask) != 0 { - panic("internal error") - } - - if n-size != 0 { - if err := unmap(p+uintptr(size), n-size); err != nil { - return 0, 0, err - } - } - - return p, size, nil -} diff --git a/vendor/modernc.org/memory/mmap_linux_32.go b/vendor/modernc.org/memory/mmap_linux_32.go deleted file mode 100644 index 207ad417d..000000000 --- a/vendor/modernc.org/memory/mmap_linux_32.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-GO file. - -//go:build linux && (386 || arm || mips || mipsle) -// +build linux -// +build 386 arm mips mipsle - -package memory - -import ( - "syscall" -) - -// Function syscall.mmap and syscall.mmap2 are same for linux/386, linux/arm, -// linux/mips and linux/mipsle - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/syscall_linux_386.go;l=99-105 -func mmapSyscall(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { - page := uintptr(offset / 4096) - if offset != int64(page)*4096 { - return 0, syscall.EINVAL - } - return mmap2Syscall(addr, length, prot, flags, fd, page) -} - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_linux_386.go;l=1361-1370 -func mmap2Syscall(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) { - r0, _, e1 := syscall.Syscall6(syscall.SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset)) - xaddr = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/modernc.org/memory/mmap_linux_64.go b/vendor/modernc.org/memory/mmap_linux_64.go deleted file mode 100644 index 6b7e93dc1..000000000 --- a/vendor/modernc.org/memory/mmap_linux_64.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-GO file. - -//go:build linux && (amd64 || arm64 || mips64 || mips64le || riscv64 || ppc64le || loong64) -// +build linux -// +build amd64 arm64 mips64 mips64le riscv64 ppc64le loong64 - -package memory - -import ( - "syscall" -) - -// Function syscall.mmap is same for linux/amd64, linux/arm64, linux/mips64, -// linux/mips64le and linux/riscv64. - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_linux_amd64.go;l=1575-1584 -func mmapSyscall(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { - r0, _, e1 := syscall.Syscall6(syscall.SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)) - xaddr = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/modernc.org/memory/mmap_linux_s390x.go b/vendor/modernc.org/memory/mmap_linux_s390x.go deleted file mode 100644 index bf7260e52..000000000 --- a/vendor/modernc.org/memory/mmap_linux_s390x.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-GO file. - -package memory - -import ( - "syscall" - "unsafe" -) - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/syscall_linux_s390x.go;l=105-115 -// Linux on s390x uses the old mmap interface, which requires arguments to be passed in a struct. -// mmap2 also requires arguments to be passed in a struct; it is currently not exposed in <asm/unistd.h>. -func mmapSyscall(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) { - mmap_args := [6]uintptr{addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset)} - r0, _, e1 := syscall.Syscall(syscall.SYS_MMAP, uintptr(unsafe.Pointer(&mmap_args[0])), 0, 0) - xaddr = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/modernc.org/memory/mmap_netbsd_32.go b/vendor/modernc.org/memory/mmap_netbsd_32.go deleted file mode 100644 index 2c17038ae..000000000 --- a/vendor/modernc.org/memory/mmap_netbsd_32.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-GO file. - -//go:build (netbsd && 386) || (netbsd && arm) -// +build netbsd,386 netbsd,arm - -package memory - -import ( - "syscall" -) - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_freebsd_386.go -func mmapSyscall(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { - r0, _, e1 := syscall.Syscall9(syscall.SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) - ret = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/modernc.org/memory/mmap_netbsd_64.go b/vendor/modernc.org/memory/mmap_netbsd_64.go deleted file mode 100644 index 5c09a7bb0..000000000 --- a/vendor/modernc.org/memory/mmap_netbsd_64.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-GO file. - -//go:build netbsd && amd64 -// +build netbsd,amd64 - -package memory - -import ( - "syscall" -) - -// https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_netbsd_amd64.go;l=1190 -func mmapSyscall(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { - r0, _, e1 := syscall.Syscall9(syscall.SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0) - ret = uintptr(r0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/modernc.org/memory/mmap_openbsd.go b/vendor/modernc.org/memory/mmap_openbsd.go deleted file mode 100644 index 24cc0a424..000000000 --- a/vendor/modernc.org/memory/mmap_openbsd.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2011 Evan Shaw. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE-MMAP-GO file. - -// Modifications (c) 2024 The Memory Authors. -// Copyright 2024 The Memory Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build openbsd && (386 || amd64 || arm64) - -package memory - -import ( - "fmt" - "os" - "sync" - "unsafe" - - "golang.org/x/sys/unix" -) - -// track what can be unmapped -var allocmap map[uintptr][]byte -var m sync.Mutex - -const pageSizeLog = 20 - -var ( - osPageMask = osPageSize - 1 - osPageSize = os.Getpagesize() -) - -func init() { - allocmap = make(map[uintptr][]byte) -} - -func unmap(addr uintptr, size int) error { - if trace { - fmt.Fprintf(os.Stderr, "unmap %#x\n", addr) - } - - a, ok := allocmap[addr] - if !ok { - if trace { - fmt.Fprintf(os.Stderr, "unmap %#x: not found\n", addr) - } - // panic("unmap called on unknown mapping") - return nil - } - - if err := unix.Munmap(a); err != nil { - if trace { - fmt.Fprintf(os.Stderr, "unmap: %s\n", err.Error()) - } - // panic(err.Error()) - return err - } - - m.Lock() - delete(allocmap, addr) - m.Unlock() - - return nil -} - -func mmap(size int) (uintptr, int, error) { - roundsize := roundup(size, osPageSize) + pageSize - - b, err := unix.Mmap(-1, 0, roundsize, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_PRIVATE|unix.MAP_ANON) - if err != nil { - return 0, 0, err - } - - p := uintptr(unsafe.Pointer(&b[0])) - - if trace { - fmt.Fprintf(os.Stderr, "mmap actual @%#x size: %#x\n", p, roundsize) - } - - // waste all the space until the next page - r := (p + uintptr(pageSize)) &^ uintptr(pageMask) - nsize := (roundsize) - int((r - p)) - if nsize < size { - panic("didn't allocate enough to meet initial request!") - } - - if trace { - fmt.Fprintf(os.Stderr, "mmap page-rounded @%#x size: %#x\n", r, nsize) - } - - m.Lock() - allocmap[r] = b - m.Unlock() - - return r, nsize, nil -} diff --git a/vendor/modernc.org/memory/mmap_unix.go b/vendor/modernc.org/memory/mmap_unix.go index de57b8823..ef6c9a539 100644 --- a/vendor/modernc.org/memory/mmap_unix.go +++ b/vendor/modernc.org/memory/mmap_unix.go @@ -2,16 +2,16 @@ // 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 || (solaris && !illumos) || netbsd -// +build darwin dragonfly freebsd linux solaris,!illumos netbsd +//go:build unix // Modifications (c) 2017 The Memory Authors. package memory // import "modernc.org/memory" import ( + "golang.org/x/sys/unix" "os" - "syscall" + "unsafe" ) const pageSizeLog = 20 @@ -22,28 +22,18 @@ var ( ) func unmap(addr uintptr, size int) error { - _, _, errno := syscall.Syscall(syscall.SYS_MUNMAP, addr, uintptr(size), 0) - if errno != 0 { - return errno - } - - return nil + return unix.MunmapPtr(unsafe.Pointer(addr), uintptr(size)) } // pageSize aligned. func mmap(size int) (uintptr, int, error) { size = roundup(size, osPageSize) - - // 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) + up, err := unix.MmapPtr(-1, 0, nil, uintptr(size+pageSize), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_PRIVATE|unix.MAP_ANON) if err != nil { return 0, 0, err } + p := uintptr(up) n := size + pageSize if p&uintptr(osPageMask) != 0 { panic("internal error") diff --git a/vendor/modernc.org/memory/mmap_windows.go b/vendor/modernc.org/memory/mmap_windows.go index f085a22ce..f88e51606 100644 --- a/vendor/modernc.org/memory/mmap_windows.go +++ b/vendor/modernc.org/memory/mmap_windows.go @@ -5,8 +5,8 @@ package memory // import "modernc.org/memory" import ( - "os" syscall "golang.org/x/sys/windows" + "os" ) const ( |
