aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-03-19 14:00:59 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-03-19 14:00:59 +0000
commit9195aa172bbc20627f23bfb1612180c83a0a7bab (patch)
treee42ecb2ffbddc6bf438c711494028bc3b86f527c /libgo/go/runtime
parent3b595ecaeda647070c6c4ede0c09be78dfc4f763 (diff)
downloadgcc-9195aa172bbc20627f23bfb1612180c83a0a7bab.zip
gcc-9195aa172bbc20627f23bfb1612180c83a0a7bab.tar.gz
gcc-9195aa172bbc20627f23bfb1612180c83a0a7bab.tar.bz2
libgo: fix build on AIX
Since aix/ppc64 has been added to GC toolchain, a mix between new and old files were created in gcc toolchain. This commit corrects this merge for aix/ppc64 and aix/ppc. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167658 From-SVN: r269797
Diffstat (limited to 'libgo/go/runtime')
-rw-r--r--libgo/go/runtime/malloc.go6
-rw-r--r--libgo/go/runtime/mem_gccgo.go5
-rw-r--r--libgo/go/runtime/netpoll_aix.go1
-rw-r--r--libgo/go/runtime/os_aix.go17
-rw-r--r--libgo/go/runtime/stubs2.go1
-rw-r--r--libgo/go/runtime/timestub2.go2
6 files changed, 20 insertions, 12 deletions
diff --git a/libgo/go/runtime/malloc.go b/libgo/go/runtime/malloc.go
index b6a7ee1..c0b4caa 100644
--- a/libgo/go/runtime/malloc.go
+++ b/libgo/go/runtime/malloc.go
@@ -218,7 +218,7 @@ const (
// we further limit it to 31 bits.
//
// WebAssembly currently has a limit of 4GB linear memory.
- heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*sys.GoosAix
+ heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*(sys.GoosAix*_64bit)
// maxAlloc is the maximum size of an allocation. On 64-bit,
// it's theoretically possible to allocate 1<<heapAddrBits bytes. On
@@ -259,7 +259,7 @@ const (
// logHeapArenaBytes is log_2 of heapArenaBytes. For clarity,
// prefer using heapArenaBytes where possible (we need the
// constant to compute some other constants).
- logHeapArenaBytes = (6+20)*(_64bit*(1-sys.GoosWindows)*(1-sys.GoosAix)) + (2+20)*(_64bit*sys.GoosWindows) + (2+20)*(1-_64bit) + (8+20)*sys.GoosAix
+ logHeapArenaBytes = (6+20)*(_64bit*(1-sys.GoosWindows)*(1-sys.GoosAix)) + (2+20)*(_64bit*sys.GoosWindows) + (2+20)*(1-_64bit) + (8+20)*(sys.GoosAix*_64bit)
// heapArenaBitmapBytes is the size of each heap arena's bitmap.
heapArenaBitmapBytes = heapArenaBytes / (sys.PtrSize * 8 / 2)
@@ -282,7 +282,7 @@ const (
//
// We use the L1 map on aix/ppc64 to keep the same L2 value
// as on Linux.
- arenaL1Bits = 6*(_64bit*sys.GoosWindows) + 12*sys.GoosAix
+ arenaL1Bits = 6*(_64bit*sys.GoosWindows) + 12*(sys.GoosAix*_64bit)
// arenaL2Bits is the number of bits of the arena number
// covered by the second level arena index.
diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go
index 44f4648..9874678 100644
--- a/libgo/go/runtime/mem_gccgo.go
+++ b/libgo/go/runtime/mem_gccgo.go
@@ -187,6 +187,11 @@ func sysReserve(v unsafe.Pointer, n uintptr) unsafe.Pointer {
func sysMap(v unsafe.Pointer, n uintptr, sysStat *uint64) {
mSysStatInc(sysStat, n)
+ if GOOS == "aix" {
+ // 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_ANON|_MAP_FIXED|_MAP_PRIVATE, mmapFD, 0)
if err == _ENOMEM {
throw("runtime: out of memory")
diff --git a/libgo/go/runtime/netpoll_aix.go b/libgo/go/runtime/netpoll_aix.go
index 86c3e96..70bf9eb 100644
--- a/libgo/go/runtime/netpoll_aix.go
+++ b/libgo/go/runtime/netpoll_aix.go
@@ -37,7 +37,6 @@ const _POLLIN = 0x0001
const _POLLOUT = 0x0002
const _POLLHUP = 0x2000
const _POLLERR = 0x4000
-const _O_NONBLOCK = 0x4
var (
pfds []pollfd
diff --git a/libgo/go/runtime/os_aix.go b/libgo/go/runtime/os_aix.go
index 1003616..9211f21 100644
--- a/libgo/go/runtime/os_aix.go
+++ b/libgo/go/runtime/os_aix.go
@@ -62,12 +62,19 @@ func semasleep(ns int64) int32 {
if clock_gettime(_CLOCK_REALTIME, &ts) != 0 {
throw("clock_gettime")
}
- ts.tv_sec += ns / 1e9
- ts.tv_nsec += ns % 1e9
- if ts.tv_nsec >= 1e9 {
- ts.tv_sec++
- ts.tv_nsec -= 1e9
+
+ sec := int64(ts.tv_sec) + ns/1e9
+ nsec := int64(ts.tv_nsec) + ns%1e9
+ if nsec >= 1e9 {
+ sec++
+ nsec -= 1e9
+ }
+ if sec != int64(timespec_sec_t(sec)) {
+ // Handle overflows (timespec_sec_t is 32-bit in 32-bit applications)
+ sec = 1<<31 - 1
}
+ ts.tv_sec = timespec_sec_t(sec)
+ ts.tv_nsec = timespec_nsec_t(nsec)
if sem_timedwait((*semt)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 {
err := errno()
diff --git a/libgo/go/runtime/stubs2.go b/libgo/go/runtime/stubs2.go
index 304c8e4..1cb910c 100644
--- a/libgo/go/runtime/stubs2.go
+++ b/libgo/go/runtime/stubs2.go
@@ -7,7 +7,6 @@
// +build !nacl
// +build !js
// +build !darwin
-// +build !aix
package runtime
diff --git a/libgo/go/runtime/timestub2.go b/libgo/go/runtime/timestub2.go
index 00c2c55..7a28603 100644
--- a/libgo/go/runtime/timestub2.go
+++ b/libgo/go/runtime/timestub2.go
@@ -5,8 +5,6 @@
// +build !darwin
// +build !windows
// +build !freebsd
-// +build !aix
-
package runtime
func walltime() (sec int64, nsec int32)