From 829931ec93ab7d5ab73f31be9da504abb6ae459e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 13 Aug 2021 17:21:54 -0700 Subject: libgo: various fixes for Solaris support Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/342189 --- libgo/go/internal/syscall/unix/getrandom_solaris.go | 3 ++- libgo/go/os/user/decls_solaris.go | 7 +++++-- libgo/go/runtime/crash_test.go | 8 ++++++++ libgo/go/syscall/exec_bsd.go | 4 ++-- libgo/go/syscall/exec_unix_test.go | 8 ++++---- libgo/go/syscall/export_aix_test.go | 5 +++-- libgo/go/syscall/export_unix_test.go | 10 ++++++---- libgo/go/syscall/libcall_linux_utimesnano.go | 3 +++ 8 files changed, 33 insertions(+), 15 deletions(-) (limited to 'libgo/go') diff --git a/libgo/go/internal/syscall/unix/getrandom_solaris.go b/libgo/go/internal/syscall/unix/getrandom_solaris.go index caf9b60..9d0f094 100644 --- a/libgo/go/internal/syscall/unix/getrandom_solaris.go +++ b/libgo/go/internal/syscall/unix/getrandom_solaris.go @@ -7,12 +7,13 @@ package unix import ( "sync/atomic" "syscall" - "unsafe" ) //extern getrandom func libc_getrandom(*byte, uintptr, uint32) uintptr +var getrandomUnsupported int32 // atomic + // GetRandomFlag is a flag supported by the getrandom system call. type GetRandomFlag uintptr diff --git a/libgo/go/os/user/decls_solaris.go b/libgo/go/os/user/decls_solaris.go index ccdf36b..43b6a04 100644 --- a/libgo/go/os/user/decls_solaris.go +++ b/libgo/go/os/user/decls_solaris.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build solaris -// +build cgo +//go:build solaris && cgo +// +build solaris,cgo package user @@ -22,3 +22,6 @@ func libc_getgrnam_r(name *byte, grp *syscall.Group, buf *byte, buflen syscall.S //extern __posix_getgrgid_r func libc_getgrgid_r(gid syscall.Gid_t, grp *syscall.Group, buf *byte, buflen syscall.Size_t, result **syscall.Group) int + +//extern getgrouplist +func libc_getgrouplist(user *byte, group syscall.Gid_t, groups *syscall.Gid_t, ngroups *int32) int diff --git a/libgo/go/runtime/crash_test.go b/libgo/go/runtime/crash_test.go index 15c6000..e3633af 100644 --- a/libgo/go/runtime/crash_test.go +++ b/libgo/go/runtime/crash_test.go @@ -744,6 +744,10 @@ func TestTimePprof(t *testing.T) { // Test that runtime.abort does so. func TestAbort(t *testing.T) { + if runtime.Compiler == "gccgo" && runtime.GOOS == "solaris" { + t.Skip("not supported by gofrontend on Solaris") + } + // Pass GOTRACEBACK to ensure we get runtime frames. output := runTestProg(t, "testprog", "Abort", "GOTRACEBACK=system") if want := "runtime.abort"; !strings.Contains(output, want) { @@ -805,6 +809,10 @@ func TestRuntimePanic(t *testing.T) { // Test that g0 stack overflows are handled gracefully. func TestG0StackOverflow(t *testing.T) { + if runtime.Compiler == "gccgo" { + t.Skip("g0 stack overflow not supported by gofrontend") + } + testenv.MustHaveExec(t) switch runtime.GOOS { diff --git a/libgo/go/syscall/exec_bsd.go b/libgo/go/syscall/exec_bsd.go index a081c09..ad65f63 100644 --- a/libgo/go/syscall/exec_bsd.go +++ b/libgo/go/syscall/exec_bsd.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build dragonfly || freebsd || hurd || netbsd || (openbsd && mips64) -// +build dragonfly freebsd hurd netbsd openbsd,mips64 +//go:build aix || darwin || dragonfly || freebsd || hurd || netbsd || openbsd || solaris +// +build aix darwin dragonfly freebsd hurd netbsd openbsd solaris package syscall diff --git a/libgo/go/syscall/exec_unix_test.go b/libgo/go/syscall/exec_unix_test.go index 8595722..3b78d20 100644 --- a/libgo/go/syscall/exec_unix_test.go +++ b/libgo/go/syscall/exec_unix_test.go @@ -180,7 +180,7 @@ func TestForeground(t *testing.T) { fpgrp := syscall.Pid_t(0) - errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp))) + errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, unsafe.Pointer(&fpgrp)) if errno != 0 { t.Fatalf("TIOCGPGRP failed with error code: %s", errno) } @@ -217,7 +217,7 @@ func TestForeground(t *testing.T) { // This call fails on darwin/arm64. The failure doesn't matter, though. // This is just best effort. - syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp))) + syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, unsafe.Pointer(&fpgrp)) } func TestForegroundSignal(t *testing.T) { @@ -231,7 +231,7 @@ func TestForegroundSignal(t *testing.T) { // equivalent. fpgrp := int32(0) - errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp))) + errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, unsafe.Pointer(&fpgrp)) if errno != 0 { t.Fatalf("TIOCGPGRP failed with error code: %s", errno) } @@ -242,7 +242,7 @@ func TestForegroundSignal(t *testing.T) { defer func() { signal.Ignore(syscall.SIGTTIN, syscall.SIGTTOU) - syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp))) + syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, unsafe.Pointer(&fpgrp)) signal.Reset() }() diff --git a/libgo/go/syscall/export_aix_test.go b/libgo/go/syscall/export_aix_test.go index 044337b..7ea5864 100644 --- a/libgo/go/syscall/export_aix_test.go +++ b/libgo/go/syscall/export_aix_test.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 aix // +build aix package syscall @@ -10,7 +11,7 @@ import ( "unsafe" ) -func Ioctl(fd, req, arg uintptr) (err Errno) { - _, err = raw_ioctl_ptr(int(fd), req, unsafe.Pointer(arg)) +func Ioctl(fd, req uintptr, arg unsafe.Pointer) (err Errno) { + _, err = raw_ioctl_ptr(int(fd), req, arg) return err } diff --git a/libgo/go/syscall/export_unix_test.go b/libgo/go/syscall/export_unix_test.go index b051e36..f32118b5 100644 --- a/libgo/go/syscall/export_unix_test.go +++ b/libgo/go/syscall/export_unix_test.go @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build dragonfly || freebsd || hurd || linux || netbsd || openbsd -// +build dragonfly freebsd hurd linux netbsd openbsd +//go:build dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris +// +build dragonfly freebsd hurd linux netbsd openbsd solaris package syscall -func Ioctl(fd, req, arg uintptr) (err Errno) { - _, _, err = Syscall(SYS_IOCTL, fd, req, arg) +import "unsafe" + +func Ioctl(fd, req uintptr, arg unsafe.Pointer) (err Errno) { + _, err = raw_ioctl_ptr(int(fd), req, arg) return err } diff --git a/libgo/go/syscall/libcall_linux_utimesnano.go b/libgo/go/syscall/libcall_linux_utimesnano.go index 90da2ae..5828338 100644 --- a/libgo/go/syscall/libcall_linux_utimesnano.go +++ b/libgo/go/syscall/libcall_linux_utimesnano.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build linux +// +build linux + // GNU/Linux version of UtimesNano. package syscall -- cgit v1.1