On Fri, Nov 6, 2015 at 5:01 AM, Rainer Orth <r...@cebitec.uni-bielefeld.de> wrote: > Ian Lance Taylor <i...@golang.org> writes: > >> I have committed a patch to libgo to update it to the Go 1.5 release. >> >> As usual for libgo updates, the actual patch is too large to attach to >> this e-mail message. I've attached the changes to the gccgo-specific >> files. >> >> Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed >> to mainline. >> >> This may cause trouble on non-GNU/Linux operating systems. Please let >> me know about any problems you encounter. > > It does indeed (first tried on i386-pc-solaris2.10): > > * > > /vol/gcc/src/hg/trunk/local/libgo/runtime/go-varargs.c: In function > '__go_ioctl': > /vol/gcc/src/hg/trunk/local/libgo/runtime/go-varargs.c:63:10: error: implicit > declaration of function 'ioctl' [-Werror=implicit-function-declaration] > return ioctl (d, request, arg); > ^ > > Needs <unistd.h>, the following patch works: > > > > * > > /vol/gcc/src/hg/trunk/local/libgo/go/syscall/exec_bsd.go:107:7: error: > incompatible types in assignment (cannot use type int as type Pid_t) > r1 = raw_getpid() > ^ > > I can cast to Pid_t and this works. The underlying error to me seems > that raw_getpid the in the generated libcalls.go is wrong, casting > c_getpid return value to int while pid_t can be long. > > * > > /vol/gcc/src/hg/trunk/local/libgo/go/net/hook_cloexec.go:13:70: error: > reference to undefined identifier 'syscall.Accept4' > accept4Func func(int, int) (int, syscall.Sockaddr, error) = syscall.Accept4 > ^ > > No accept4 on Solaris (and certainly other systems, thence configure > test), but used unconditionally. > > * > > /vol/gcc/src/hg/trunk/local/libgo/go/net/sendfile_solaris.go:78:22: error: > reference to undefined identifier 'syscall.Sendfile' > n, err1 := syscall.Sendfile(dst, src, &pos1, n) > ^ > > Only in go/syscall/libcall_linux.go!? > > * > > /vol/gcc/src/hg/trunk/local/libgo/go/net/tcpsockopt_solaris.go:34:103: error: > reference to undefined identifier 'syscall.TCP_KEEPALIVE_THRESHOLD' > return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, > syscall.IPPROTO_TCP, syscall.TCP_KEEPALIVE_THRESHOLD, msecs)) > > ^ > > Not in Solaris 10, only Solaris 11 and 12 have it.
Thanks for the notes. I committed this patch to address these problems. Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 229832) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -47f256e1ed527b2eb4041acf90d33e6abc5e1685 +10c1d6756ed1dcc814c49921c2a5e27f4677e0e6 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/Makefile.am =================================================================== --- libgo/Makefile.am (revision 229832) +++ libgo/Makefile.am (working copy) @@ -787,10 +787,14 @@ endif endif if LIBGO_IS_LINUX -go_net_cloexec_file = go/net/sock_cloexec.go +go_net_cloexec_file = go/net/sock_cloexec.go go/net/hook_cloexec.go +else +if LIBGO_IS_FREEBSD +go_net_cloexec_file = go/net/sock_cloexec.go go/net/hook_cloexec.go else go_net_cloexec_file = go/net/sys_cloexec.go endif +endif if LIBGO_IS_OPENBSD go_net_tcpsockopt_file = go/net/tcpsockopt_openbsd.go @@ -825,7 +829,6 @@ go_net_common_files = \ go/net/file.go \ go/net/file_unix.go \ go/net/hook.go \ - go/net/hook_cloexec.go \ go/net/hook_unix.go \ go/net/hosts.go \ go/net/interface.go \ @@ -1985,6 +1988,12 @@ else syscall_exec_test_file = endif +if LIBGO_IS_LINUX +syscall_os_file = +else +syscall_os_file = go/syscall/libcall_bsd.go +endif + go_base_syscall_files = \ go/syscall/env_unix.go \ go/syscall/syscall_errno.go \ @@ -2003,6 +2012,7 @@ go_base_syscall_files = \ $(syscall_sleep_file) \ $(syscall_errstr_file) \ $(syscall_size_file) \ + $(syscall_os_file) \ $(syscall_socket_file) \ $(syscall_socket_os_file) \ $(syscall_socket_type_file) \ Index: libgo/go/net/tcpsockopt_solaris.go =================================================================== --- libgo/go/net/tcpsockopt_solaris.go (revision 229832) +++ libgo/go/net/tcpsockopt_solaris.go (working copy) @@ -1,7 +1,9 @@ -// Copyright 2015 The Go Authors. All rights reserved. +// Copyright 2013 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 file. +// TCP socket options for solaris + package net import ( @@ -10,26 +12,16 @@ import ( "time" ) +// Set keep alive period. func setKeepAlivePeriod(fd *netFD, d time.Duration) error { if err := fd.incref(); err != nil { return err } defer fd.decref() - // The kernel expects milliseconds so round to next highest - // millisecond. - d += (time.Millisecond - time.Nanosecond) - msecs := int(d / time.Millisecond) - - // Normally we'd do - // syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, secs) - // here, but we can't because Solaris does not have TCP_KEEPINTVL. - // Solaris has TCP_KEEPALIVE_ABORT_THRESHOLD, but it's not the same - // thing, it refers to the total time until aborting (not between - // probes), and it uses an exponential backoff algorithm instead of - // waiting the same time between probes. We can't hope for the best - // and do it anyway, like on Darwin, because Solaris might eventually - // allocate a constant with a different meaning for the value of - // TCP_KEEPINTVL on illumos. - return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.TCP_KEEPALIVE_THRESHOLD, msecs)) + // The kernel expects seconds so round to next highest second. + d += (time.Second - time.Nanosecond) + secs := int(d.Seconds()) + + return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd.sysfd, syscall.IPPROTO_TCP, syscall.SO_KEEPALIVE, secs)) } Index: libgo/go/syscall/exec_bsd.go =================================================================== --- libgo/go/syscall/exec_bsd.go (revision 229832) +++ libgo/go/syscall/exec_bsd.go (working copy) @@ -102,11 +102,9 @@ func forkAndExecInChild(argv0 *byte, arg } if sys.Foreground { - pgrp := sys.Pgid + pgrp := Pid_t(sys.Pgid) if pgrp == 0 { - r1 = raw_getpid() - - pgrp = int(r1) + pgrp = raw_getpid() } // Place process group in foreground. Index: libgo/go/syscall/exec_linux.go =================================================================== --- libgo/go/syscall/exec_linux.go (revision 229832) +++ libgo/go/syscall/exec_linux.go (working copy) @@ -171,14 +171,9 @@ func forkAndExecInChild(argv0 *byte, arg } if sys.Foreground { - pgrp := int32(sys.Pgid) + pgrp := Pid_t(sys.Pgid) if pgrp == 0 { - r1 = uintptr(raw_getpid()) - if err1 != 0 { - goto childerror - } - - pgrp = int32(r1) + pgrp = raw_getpid() } // Place process group in foreground. @@ -236,7 +231,7 @@ func forkAndExecInChild(argv0 *byte, arg // using SIGKILL. r1 := raw_getppid() if r1 != ppid { - pid = raw_getpid() + pid := raw_getpid() err1 = raw_kill(pid, sys.Pdeathsig) if err1 != 0 { goto childerror Index: libgo/go/syscall/exec_unix.go =================================================================== --- libgo/go/syscall/exec_unix.go (revision 229832) +++ libgo/go/syscall/exec_unix.go (working copy) @@ -17,10 +17,10 @@ import ( //sysnb raw_fork() (pid Pid_t, err Errno) //fork() Pid_t -//sysnb raw_getpid() (pid int) +//sysnb raw_getpid() (pid Pid_t) //getpid() Pid_t -//sysnb raw_getppid() (pid int) +//sysnb raw_getppid() (pid Pid_t) //getppid() Pid_t //sysnb raw_setsid() (err Errno) @@ -59,7 +59,7 @@ import ( //sysnb raw_dup2(oldfd int, newfd int) (err Errno) //dup2(oldfd _C_int, newfd _C_int) _C_int -//sysnb raw_kill(pid int, sig Signal) (err Errno) +//sysnb raw_kill(pid Pid_t, sig Signal) (err Errno) //kill(pid Pid_t, sig _C_int) _C_int //sysnb raw_setgroups(size int, list unsafe.Pointer) (err Errno) Index: libgo/go/syscall/exec_unix_test.go =================================================================== --- libgo/go/syscall/exec_unix_test.go (revision 229832) +++ libgo/go/syscall/exec_unix_test.go (working copy) @@ -169,7 +169,7 @@ func TestForeground(t *testing.T) { t.Skipf("Can't test Foreground. Couldn't open /dev/tty: %s", err) } - fpgrp := 0 + fpgrp := syscall.Pid_t(0) errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp))) if errno != 0 { Index: libgo/go/syscall/libcall_bsd.go =================================================================== --- libgo/go/syscall/libcall_bsd.go (revision 0) +++ libgo/go/syscall/libcall_bsd.go (working copy) @@ -0,0 +1,27 @@ +// Copyright 2015 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 file. + +// BSD library calls. + +package syscall + +import "unsafe" + +//sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error) +//sendfile(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t +func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { + if raceenabled { + raceReleaseMerge(unsafe.Pointer(&ioSync)) + } + var soff Offset_t + var psoff *Offset_t + if offset != nil { + psoff = &soff + } + written, err = sendfile(outfd, infd, psoff, count) + if offset != nil { + *offset = int64(soff) + } + return +} Index: libgo/runtime/go-varargs.c =================================================================== --- libgo/runtime/go-varargs.c (revision 229832) +++ libgo/runtime/go-varargs.c (working copy) @@ -8,6 +8,7 @@ #include <errno.h> #include <stdint.h> +#include <unistd.h> #include <sys/types.h> #include <fcntl.h> #include <sys/ioctl.h>