mirror of
https://github.com/golang/go
synced 2024-11-26 19:51:17 -07:00
runtime: enable runtime_mmap_test.go on AIX
AIX doesn't allow to mmap an address range which is already mmap. Therefore, once the region has been allocated, it must munmap before being able to play with it. Change-Id: I1547782f0379024f57869f1dda8c1c9bb12d831f Reviewed-on: https://go-review.googlesource.com/c/go/+/174059 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
8feeada50c
commit
f61353f2d9
@ -65,7 +65,7 @@ const (
|
||||
_PROT_WRITE = C.PROT_WRITE
|
||||
_PROT_EXEC = C.PROT_EXEC
|
||||
|
||||
_MAP_ANONYMOUS = C.MAP_ANONYMOUS
|
||||
_MAP_ANON = C.MAP_ANONYMOUS
|
||||
_MAP_PRIVATE = C.MAP_PRIVATE
|
||||
_MAP_FIXED = C.MAP_FIXED
|
||||
_MADV_DONTNEED = C.MADV_DONTNEED
|
||||
|
@ -22,7 +22,7 @@ const (
|
||||
_PROT_WRITE = 0x2
|
||||
_PROT_EXEC = 0x4
|
||||
|
||||
_MAP_ANONYMOUS = 0x10
|
||||
_MAP_ANON = 0x10
|
||||
_MAP_PRIVATE = 0x2
|
||||
_MAP_FIXED = 0x100
|
||||
_MADV_DONTNEED = 0x4
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
// Export guts for testing.
|
||||
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
// prevents us from allocating more stack.
|
||||
//go:nosplit
|
||||
func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {
|
||||
p, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANONYMOUS|_MAP_PRIVATE, -1, 0)
|
||||
p, err := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
|
||||
if err != 0 {
|
||||
if err == _EACCES {
|
||||
print("runtime: mmap: access denied\n")
|
||||
@ -46,11 +46,11 @@ func sysFree(v unsafe.Pointer, n uintptr, sysStat *uint64) {
|
||||
}
|
||||
|
||||
func sysFault(v unsafe.Pointer, n uintptr) {
|
||||
mmap(v, n, _PROT_NONE, _MAP_ANONYMOUS|_MAP_PRIVATE|_MAP_FIXED, -1, 0)
|
||||
mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE|_MAP_FIXED, -1, 0)
|
||||
}
|
||||
|
||||
func sysReserve(v unsafe.Pointer, n uintptr) unsafe.Pointer {
|
||||
p, err := mmap(v, n, _PROT_NONE, _MAP_ANONYMOUS|_MAP_PRIVATE, -1, 0)
|
||||
p, err := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
|
||||
if err != 0 {
|
||||
return nil
|
||||
}
|
||||
@ -63,7 +63,7 @@ func sysMap(v unsafe.Pointer, n uintptr, sysStat *uint64) {
|
||||
// AIX does not allow mapping a range that is already mapped.
|
||||
// So always unmap first even if it is already unmapped.
|
||||
munmap(v, n)
|
||||
p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANONYMOUS|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
|
||||
p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
|
||||
|
||||
if err == _ENOMEM {
|
||||
throw("runtime: out of memory")
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
|
||||
package runtime_test
|
||||
|
||||
@ -34,6 +34,11 @@ func TestPhysPageSize(t *testing.T) {
|
||||
t.Fatalf("Mmap: %v", err)
|
||||
}
|
||||
|
||||
if runtime.GOOS == "aix" {
|
||||
// AIX does not allow mapping a range that is already mapped.
|
||||
runtime.Munmap(unsafe.Pointer(uintptr(b)), 2*ps)
|
||||
}
|
||||
|
||||
// Mmap should fail at a half page into the buffer.
|
||||
_, err = runtime.Mmap(unsafe.Pointer(uintptr(b)+ps/2), ps, 0, runtime.MAP_ANON|runtime.MAP_PRIVATE|runtime.MAP_FIXED, -1, 0)
|
||||
if err == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user