summaryrefslogtreecommitdiffstats
path: root/vendor/modernc.org/memory
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/modernc.org/memory')
-rw-r--r--vendor/modernc.org/memory/CONTRIBUTORS1
-rw-r--r--vendor/modernc.org/memory/LICENSE-GO27
-rw-r--r--vendor/modernc.org/memory/Makefile11
-rw-r--r--vendor/modernc.org/memory/counters.go1
-rw-r--r--vendor/modernc.org/memory/memory32.go3
-rw-r--r--vendor/modernc.org/memory/memory64.go3
-rw-r--r--vendor/modernc.org/memory/mmap_fallback.go17
-rw-r--r--vendor/modernc.org/memory/mmap_freebsd_32.go21
-rw-r--r--vendor/modernc.org/memory/mmap_freebsd_64.go21
-rw-r--r--vendor/modernc.org/memory/mmap_linux_32.go33
-rw-r--r--vendor/modernc.org/memory/mmap_linux_64.go24
-rw-r--r--vendor/modernc.org/memory/mmap_linux_s390x.go23
-rw-r--r--vendor/modernc.org/memory/mmap_netbsd_32.go21
-rw-r--r--vendor/modernc.org/memory/mmap_netbsd_64.go21
-rw-r--r--vendor/modernc.org/memory/mmap_unix.go12
-rw-r--r--vendor/modernc.org/memory/nocounters.go1
-rw-r--r--vendor/modernc.org/memory/trace_disabled.go1
-rw-r--r--vendor/modernc.org/memory/trace_enabled.go1
18 files changed, 235 insertions, 7 deletions
diff --git a/vendor/modernc.org/memory/CONTRIBUTORS b/vendor/modernc.org/memory/CONTRIBUTORS
index 988458ca..72167486 100644
--- a/vendor/modernc.org/memory/CONTRIBUTORS
+++ b/vendor/modernc.org/memory/CONTRIBUTORS
@@ -8,3 +8,4 @@
Jan Mercl <0xjnml@gmail.com>
Steffen Butzer <steffen(dot)butzer@outlook.com>
+ZHU Zijia <piggynl@outlook.com>
diff --git a/vendor/modernc.org/memory/LICENSE-GO b/vendor/modernc.org/memory/LICENSE-GO
new file mode 100644
index 00000000..6a66aea5
--- /dev/null
+++ b/vendor/modernc.org/memory/LICENSE-GO
@@ -0,0 +1,27 @@
+Copyright (c) 2009 The Go Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/modernc.org/memory/Makefile b/vendor/modernc.org/memory/Makefile
index fbb3e4ee..d0c9c254 100644
--- a/vendor/modernc.org/memory/Makefile
+++ b/vendor/modernc.org/memory/Makefile
@@ -36,14 +36,23 @@ editor:
gofmt -l -s -w *.go
GOOS=darwin GOARCH=amd64 go build
GOOS=darwin GOARCH=arm64 go build
+ GOOS=freebsd GOARCH=386 go build
+ GOOS=freebsd GOARCH=amd64 go build
GOOS=linux GOARCH=386 go build
GOOS=linux GOARCH=amd64 go build
GOOS=linux GOARCH=arm go build
GOOS=linux GOARCH=arm64 go build
+ GOOS=linux GOARCH=mips go build
+ GOOS=linux GOARCH=mips64le go build
+ GOOS=linux GOARCH=mipsle go build
+ GOOS=linux GOARCH=riscv64 go build
GOOS=linux GOARCH=s390x go build
+ GOOS=netbsd GOARCH=386 go build
+ GOOS=netbsd GOARCH=amd64 go build
+ GOOS=openbsd GOARCH=386 go build
+ GOOS=openbsd GOARCH=amd64 go build
GOOS=windows GOARCH=386 go build
GOOS=windows GOARCH=amd64 go build
- go test 2>&1 | tee log
internalError:
egrep -ho '"internal error.*"' *.go | sort | cat -n
diff --git a/vendor/modernc.org/memory/counters.go b/vendor/modernc.org/memory/counters.go
index ca4024fc..d50a3612 100644
--- a/vendor/modernc.org/memory/counters.go
+++ b/vendor/modernc.org/memory/counters.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build memory.counters
// +build memory.counters
package memory // import "modernc.org/memory"
diff --git a/vendor/modernc.org/memory/memory32.go b/vendor/modernc.org/memory/memory32.go
index f13a8ae6..ae1a49e7 100644
--- a/vendor/modernc.org/memory/memory32.go
+++ b/vendor/modernc.org/memory/memory32.go
@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build 386 || arm || armbe || mips || mipsle || ppc || ppc64le || s390 || s390x || sparc
// +build 386 arm armbe mips mipsle ppc ppc64le s390 s390x sparc
package memory // import "modernc.org/memory"
-type rawmem [1<<31 - 1]byte
+type rawmem [1<<31 - 2]byte
diff --git a/vendor/modernc.org/memory/memory64.go b/vendor/modernc.org/memory/memory64.go
index 2c7cfee1..57c88365 100644
--- a/vendor/modernc.org/memory/memory64.go
+++ b/vendor/modernc.org/memory/memory64.go
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build amd64 amd64p32 arm64 arm64be mips64 mips64le mips64p32 mips64p32le ppc64 sparc64
+//go:build amd64 || amd64p32 || arm64 || arm64be || mips64 || mips64le || mips64p32 || mips64p32le || ppc64 || sparc64 || riscv64
+// +build amd64 amd64p32 arm64 arm64be mips64 mips64le mips64p32 mips64p32le ppc64 sparc64 riscv64
package memory // import "modernc.org/memory"
diff --git a/vendor/modernc.org/memory/mmap_fallback.go b/vendor/modernc.org/memory/mmap_fallback.go
new file mode 100644
index 00000000..35b2f2b0
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_fallback.go
@@ -0,0 +1,17 @@
+// 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 (darwin && (amd64 || arm64)) || (openbsd && (386 || amd64))
+
+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
new file mode 100644
index 00000000..47b29962
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_freebsd_32.go
@@ -0,0 +1,21 @@
+// 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
+
+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
new file mode 100644
index 00000000..87a4c238
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_freebsd_64.go
@@ -0,0 +1,21 @@
+// 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
+
+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_linux_32.go b/vendor/modernc.org/memory/mmap_linux_32.go
new file mode 100644
index 00000000..996805c4
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_linux_32.go
@@ -0,0 +1,33 @@
+// 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)
+
+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
new file mode 100644
index 00000000..9f65896d
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_linux_64.go
@@ -0,0 +1,24 @@
+// 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)
+
+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
new file mode 100644
index 00000000..bf7260e5
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_linux_s390x.go
@@ -0,0 +1,23 @@
+// 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
new file mode 100644
index 00000000..bd1a32c8
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_netbsd_32.go
@@ -0,0 +1,21 @@
+// 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
+
+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
new file mode 100644
index 00000000..ced5dbc9
--- /dev/null
+++ b/vendor/modernc.org/memory/mmap_netbsd_64.go
@@ -0,0 +1,21 @@
+// 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
+
+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_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")
}
diff --git a/vendor/modernc.org/memory/nocounters.go b/vendor/modernc.org/memory/nocounters.go
index 40af6a9a..090eb958 100644
--- a/vendor/modernc.org/memory/nocounters.go
+++ b/vendor/modernc.org/memory/nocounters.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !memory.counters
// +build !memory.counters
package memory // import "modernc.org/memory"
diff --git a/vendor/modernc.org/memory/trace_disabled.go b/vendor/modernc.org/memory/trace_disabled.go
index 76e60766..eeebc9c7 100644
--- a/vendor/modernc.org/memory/trace_disabled.go
+++ b/vendor/modernc.org/memory/trace_disabled.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build !memory.trace
// +build !memory.trace
package memory // import "modernc.org/memory"
diff --git a/vendor/modernc.org/memory/trace_enabled.go b/vendor/modernc.org/memory/trace_enabled.go
index 55e65f4a..37b8e232 100644
--- a/vendor/modernc.org/memory/trace_enabled.go
+++ b/vendor/modernc.org/memory/trace_enabled.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build memory.trace
// +build memory.trace
package memory // import "modernc.org/memory"