diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-02-15 01:57:51 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-02-15 01:57:51 +0000 |
commit | 8a9f2a6bbd6bdf164ca987edac34ac72447881a5 (patch) | |
tree | 0722c462bd08d8478a0d1861b10b9f966193505e /libgo/go | |
parent | c8530c410972f09b88bb143e5e5a4910bd72b2ee (diff) | |
download | gcc-8a9f2a6bbd6bdf164ca987edac34ac72447881a5.zip gcc-8a9f2a6bbd6bdf164ca987edac34ac72447881a5.tar.gz gcc-8a9f2a6bbd6bdf164ca987edac34ac72447881a5.tar.bz2 |
compiler, runtime: harmonize types referenced by both C and Go
Compiling with LTO revealed a number of cases in the runtime and
standard library where C and Go disagreed about the type of an object or
function (or where Go and code generated by the compiler disagreed). In
all cases the underlying representation was the same (e.g., uintptr vs.
void*), so this wasn't causing actual problems, but it did result in a
number of annoying warnings when compiling with LTO.
Reviewed-on: https://go-review.googlesource.com/c/160700
From-SVN: r268923
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/runtime/mgc.go | 2 | ||||
-rw-r--r-- | libgo/go/runtime/netpoll.go | 22 | ||||
-rw-r--r-- | libgo/go/runtime/proc.go | 2 | ||||
-rw-r--r-- | libgo/go/runtime/stubs.go | 3 | ||||
-rw-r--r-- | libgo/go/syscall/syscall_unix.go | 47 | ||||
-rw-r--r-- | libgo/go/syscall/wait.c | 16 |
6 files changed, 31 insertions, 61 deletions
diff --git a/libgo/go/runtime/mgc.go b/libgo/go/runtime/mgc.go index 0973f1d..b8c91ac 100644 --- a/libgo/go/runtime/mgc.go +++ b/libgo/go/runtime/mgc.go @@ -238,7 +238,7 @@ func setGCPercent(in int32) (out int32) { var gcphase uint32 // The compiler knows about this variable. -// If you change it, you must change builtin/runtime.go, too. +// If you change it, you must change gofrontend/wb.cc, too. // If you change the first four bytes, you must also change the write // barrier insertion code. var writeBarrier struct { diff --git a/libgo/go/runtime/netpoll.go b/libgo/go/runtime/netpoll.go index 6d39114..3515922 100644 --- a/libgo/go/runtime/netpoll.go +++ b/libgo/go/runtime/netpoll.go @@ -112,7 +112,7 @@ func poll_runtime_isPollServerDescriptor(fd uintptr) bool { } //go:linkname poll_runtime_pollOpen internal..z2fpoll.runtime_pollOpen -func poll_runtime_pollOpen(fd uintptr) (*pollDesc, int) { +func poll_runtime_pollOpen(fd uintptr) (uintptr, int) { pd := pollcache.alloc() lock(&pd.lock) if pd.wg != 0 && pd.wg != pdReady { @@ -133,11 +133,12 @@ func poll_runtime_pollOpen(fd uintptr) (*pollDesc, int) { var errno int32 errno = netpollopen(fd, pd) - return pd, int(errno) + return uintptr(unsafe.Pointer(pd)), int(errno) } //go:linkname poll_runtime_pollClose internal..z2fpoll.runtime_pollClose -func poll_runtime_pollClose(pd *pollDesc) { +func poll_runtime_pollClose(ctx uintptr) { + pd := (*pollDesc)(unsafe.Pointer(ctx)) if !pd.closing { throw("runtime: close polldesc w/o unblock") } @@ -159,7 +160,8 @@ func (c *pollCache) free(pd *pollDesc) { } //go:linkname poll_runtime_pollReset internal..z2fpoll.runtime_pollReset -func poll_runtime_pollReset(pd *pollDesc, mode int) int { +func poll_runtime_pollReset(ctx uintptr, mode int) int { + pd := (*pollDesc)(unsafe.Pointer(ctx)) err := netpollcheckerr(pd, int32(mode)) if err != 0 { return err @@ -173,7 +175,8 @@ func poll_runtime_pollReset(pd *pollDesc, mode int) int { } //go:linkname poll_runtime_pollWait internal..z2fpoll.runtime_pollWait -func poll_runtime_pollWait(pd *pollDesc, mode int) int { +func poll_runtime_pollWait(ctx uintptr, mode int) int { + pd := (*pollDesc)(unsafe.Pointer(ctx)) err := netpollcheckerr(pd, int32(mode)) if err != 0 { return err @@ -195,7 +198,8 @@ func poll_runtime_pollWait(pd *pollDesc, mode int) int { } //go:linkname poll_runtime_pollWaitCanceled internal..z2fpoll.runtime_pollWaitCanceled -func poll_runtime_pollWaitCanceled(pd *pollDesc, mode int) { +func poll_runtime_pollWaitCanceled(ctx uintptr, mode int) { + pd := (*pollDesc)(unsafe.Pointer(ctx)) // This function is used only on windows after a failed attempt to cancel // a pending async IO operation. Wait for ioready, ignore closing or timeouts. for !netpollblock(pd, int32(mode), true) { @@ -203,7 +207,8 @@ func poll_runtime_pollWaitCanceled(pd *pollDesc, mode int) { } //go:linkname poll_runtime_pollSetDeadline internal..z2fpoll.runtime_pollSetDeadline -func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) { +func poll_runtime_pollSetDeadline(ctx uintptr, d int64, mode int) { + pd := (*pollDesc)(unsafe.Pointer(ctx)) lock(&pd.lock) if pd.closing { unlock(&pd.lock) @@ -288,7 +293,8 @@ func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) { } //go:linkname poll_runtime_pollUnblock internal..z2fpoll.runtime_pollUnblock -func poll_runtime_pollUnblock(pd *pollDesc) { +func poll_runtime_pollUnblock(ctx uintptr) { + pd := (*pollDesc)(unsafe.Pointer(ctx)) lock(&pd.lock) if pd.closing { throw("runtime: unblock on closing polldesc") diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go index b4fa88f..e937563 100644 --- a/libgo/go/runtime/proc.go +++ b/libgo/go/runtime/proc.go @@ -153,7 +153,7 @@ var runtimeInitTime int64 var initSigmask sigset // The main goroutine. -func main() { +func main(unsafe.Pointer) { g := getg() // Max stack size is 1 GB on 64-bit, 250 MB on 32-bit. diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go index f2b0ee8a..9f5191b 100644 --- a/libgo/go/runtime/stubs.go +++ b/libgo/go/runtime/stubs.go @@ -283,8 +283,7 @@ func eqstring(x, y string) bool { // For gccgo this is in the C code. func osyield() -// For gccgo this can be called directly. -//extern syscall +//extern __go_syscall6 func syscall(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr // For gccgo, to communicate from the C code to the Go code. diff --git a/libgo/go/syscall/syscall_unix.go b/libgo/go/syscall/syscall_unix.go index 450173a..b786dc5 100644 --- a/libgo/go/syscall/syscall_unix.go +++ b/libgo/go/syscall/syscall_unix.go @@ -19,11 +19,8 @@ var ( Stderr = 2 ) -//extern syscall -func c_syscall32(trap int32, a1, a2, a3, a4, a5, a6 int32) int32 - -//extern syscall -func c_syscall64(trap int64, a1, a2, a3, a4, a5, a6 int64) int64 +//extern __go_syscall6 +func syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr const ( darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8 @@ -38,14 +35,7 @@ const ( func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { Entersyscall() SetErrno(0) - var r uintptr - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), 0, 0, 0) - r = uintptr(r1) - } + r := syscall6(trap, a1, a2, a3, 0, 0, 0) err = GetErrno() Exitsyscall() return r, 0, err @@ -54,47 +44,22 @@ func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { Entersyscall() SetErrno(0) - var r uintptr - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), - int32(a4), int32(a5), int32(a6)) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), - int64(a4), int64(a5), int64(a6)) - r = uintptr(r1) - } + r := syscall6(trap, a1, a2, a3, a4, a5, a6) err = GetErrno() Exitsyscall() return r, 0, err } func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { - var r uintptr SetErrno(0) - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), 0, 0, 0) - r = uintptr(r1) - } + r := syscall6(trap, a1, a2, a3, 0, 0, 0) err = GetErrno() return r, 0, err } func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { - var r uintptr SetErrno(0) - if unsafe.Sizeof(r) == 4 { - r1 := c_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), - int32(a4), int32(a5), int32(a6)) - r = uintptr(r1) - } else { - r1 := c_syscall64(int64(trap), int64(a1), int64(a2), int64(a3), - int64(a4), int64(a5), int64(a6)) - r = uintptr(r1) - } + r := syscall6(trap, a1, a2, a3, a4, a5, a6) err = GetErrno() return r, 0, err } diff --git a/libgo/go/syscall/wait.c b/libgo/go/syscall/wait.c index 9555a41..0b234d0 100644 --- a/libgo/go/syscall/wait.c +++ b/libgo/go/syscall/wait.c @@ -65,10 +65,10 @@ CoreDump (uint32_t *w) return WCOREDUMP (*w) != 0; } -extern int ExitStatus (uint32_t *w) +extern intgo ExitStatus (uint32_t *w) __asm__ (GOSYM_PREFIX "syscall.WaitStatus.ExitStatus"); -int +intgo ExitStatus (uint32_t *w) { if (!WIFEXITED (*w)) @@ -76,10 +76,10 @@ ExitStatus (uint32_t *w) return WEXITSTATUS (*w); } -extern int Signal (uint32_t *w) +extern intgo Signal (uint32_t *w) __asm__ (GOSYM_PREFIX "syscall.WaitStatus.Signal"); -int +intgo Signal (uint32_t *w) { if (!WIFSIGNALED (*w)) @@ -87,10 +87,10 @@ Signal (uint32_t *w) return WTERMSIG (*w); } -extern int StopSignal (uint32_t *w) +extern intgo StopSignal (uint32_t *w) __asm__ (GOSYM_PREFIX "syscall.WaitStatus.StopSignal"); -int +intgo StopSignal (uint32_t *w) { if (!WIFSTOPPED (*w)) @@ -98,10 +98,10 @@ StopSignal (uint32_t *w) return WSTOPSIG (*w); } -extern int TrapCause (uint32_t *w) +extern intgo TrapCause (uint32_t *w) __asm__ (GOSYM_PREFIX "syscall.WaitStatus.TrapCause"); -int +intgo TrapCause (uint32_t *w __attribute__ ((unused))) { #ifndef __linux__ |