From patchwork Mon Nov 6 15:44:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Svante Signell X-Patchwork-Id: 834797 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-466037-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="coCFAIfd"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yVxhl3J3yz9s7m for ; Tue, 7 Nov 2017 02:45:10 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:reply-to:to:cc:date:content-type :mime-version; q=dns; s=default; b=jjis70IaFPoc3io++ZubW/mpzB94O fJPiWxYclQVhWxhfm00M+ZNZRSDV2of2ftt/VHSx+3vsqWTrkb6Q4L2/2ryS93ul genJb4pgT03RpQ2jGtg2d5B5FWoqNrGFVqyFlgICSuTeimRi6ssjtWfFjS0hnAuo vtEJZpd71douy0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:reply-to:to:cc:date:content-type :mime-version; s=default; bh=cbJXJ5ck2bSlkMvKhruCkz+hEDA=; b=coC FAIfdGar3glJOpV4Hbf8J65+eNz5k2QWxThkVGc4/rOGbTIvwdEDzlC5eQWvl5/8 wvJ8zjob3rhuubLZqIbPiY8a00CsdDVx5Olk49JFdorOWWdONX+S5sbJDLHyOt4k iLXfrCuOsndsaMZyuP0yTP2PZclPUoMdbVObQI2Q= Received: (qmail 44529 invoked by alias); 6 Nov 2017 15:44:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 44158 invoked by uid 89); 6 Nov 2017 15:44:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Port, Certificate, Times, Pipe X-HELO: mail-lf0-f53.google.com Received: from mail-lf0-f53.google.com (HELO mail-lf0-f53.google.com) (209.85.215.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Nov 2017 15:44:42 +0000 Received: by mail-lf0-f53.google.com with SMTP id n69so11007322lfn.2 for ; Mon, 06 Nov 2017 07:44:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:reply-to:to:cc:date :organization:mime-version; bh=Qbby6qPNeaKApWo1OFR0Dm7mk07DFUmVhdtz+8poiAQ=; b=gaLFieJrsG0/OA/PAuLOGXiBqfi0N4SChl/nWkr/SdcPC1wR1wWNYE8FQBi1GRkIHM oTJHsQcliNKxezJvEQ2PAE6Y0PK2IoT7u4KZ8JyhkSYMZjyAhDUKR0s7z5qc8mqmD/ED rWYoc/o5eaXF/eWEe6TJ8XjWpRygZnQpKWbxeco+TN/gS1J+eEVEhurgdVkGVsG2fNjz BnnZ9q3WyQmaKx02qjn5Ije/vhK2abAxBinnaOnvbS0h9O3eEcwNf1L1J/cyyar6HyxX aWAhcAJID673PCzTKh0eMziMsgRT0YxQEnYtc9p3THGUU8TirpDa0tophavb+tAKdO1Y krig== X-Gm-Message-State: AJaThX7gVqRHgKytZoKpwE2K3XdnxtdUwlFeDq/EvdPaypreVJk4XYnw M4QyKOddigMd8IdoAL9vD60= X-Google-Smtp-Source: ABhQp+QPqSdYU0tjkFudMOAH6r6jCRKlfRZTvxiswUkhkCxrLTw8/mV1IDaK5JOMdZNAy1CPv3OPHw== X-Received: by 10.25.109.19 with SMTP id i19mr6238089lfc.75.1509983079291; Mon, 06 Nov 2017 07:44:39 -0800 (PST) Received: from G3620.lan ([178.78.231.178]) by smtp.gmail.com with ESMTPSA id t74sm2443206lfi.4.2017.11.06.07.44.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2017 07:44:38 -0800 (PST) Message-ID: <1509983091.28464.32.camel@gmail.com> Subject: Hurd port for gcc-7 go PATCH 4-10(15) From: Svante Signell Reply-To: svante.signell@gmail.com To: bug-hurd Cc: gcc-patches , Debian GCC Maintainers Date: Mon, 06 Nov 2017 16:44:51 +0100 Mime-Version: 1.0 * src_libgo_build.diff: configure.ac, Makefile.* and shell script patches. * src_libgo_go_crypto.diff: Certificate go files. * src_libgo_go_net.diff: OS-specific net go files. * src_libgo_go_os.diff: OS-specific os go files. * src_libgo_go_runtime.diff: OS-specific runtime go files. * src_libgo_go_syscall.diff: OS-specific syscall go files. * src_libgo_runtime.diff: OS-specific runtime C files. Index: gcc-7-7.2.0-12.1/src/libgo/go/net/cgo_gnu.go =================================================================== --- /dev/null +++ gcc-7-7.2.0-12.1/src/libgo/go/net/cgo_gnu.go @@ -0,0 +1,16 @@ +// Copyright 2011 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. + +// +build cgo,!netgo +// +build gnu + +package net + +/* +#include +*/ + +import "syscall" + +const cgoAddrInfoFlags = syscall.AI_CANONNAME | syscall.AI_V4MAPPED | syscall.AI_ALL Index: gcc-7-7.2.0-12.1/src/libgo/go/net/sendfile_gnu.go =================================================================== --- /dev/null +++ gcc-7-7.2.0-12.1/src/libgo/go/net/sendfile_gnu.go @@ -0,0 +1,79 @@ +// Copyright 2011 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. + +package net + +import ( + "io" + "os" + "syscall" +) + +// maxSendfileSize is the largest chunk size we ask the kernel to copy +// at a time. +const maxSendfileSize int = 4 << 20 + +// sendFile copies the contents of r to c using the sendfile +// system call to minimize copies. +// +// if handled == true, sendFile returns the number of bytes copied and any +// non-EOF error. +// +// if handled == false, sendFile performed no work. +func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { + var remain int64 = 1 << 62 // by default, copy until EOF + + lr, ok := r.(*io.LimitedReader) + if ok { + remain, r = lr.N, lr.R + if remain <= 0 { + return 0, nil, true + } + } + f, ok := r.(*os.File) + if !ok { + return 0, nil, false + } + + if err := c.writeLock(); err != nil { + return 0, err, true + } + defer c.writeUnlock() + + dst := c.sysfd + src := int(f.Fd()) + for remain > 0 { + n := maxSendfileSize + if int64(n) > remain { + n = int(remain) + } + n, err1 := syscall.Sendfile(dst, src, nil, n) + if n > 0 { + written += int64(n) + remain -= int64(n) + } + if n == 0 && err1 == nil { + break + } + if err1 == syscall.EAGAIN { + if err1 = c.pd.waitWrite(); err1 == nil { + continue + } + } + if err1 != nil { + // This includes syscall.ENOSYS (no kernel + // support) and syscall.EINVAL (fd types which + // don't implement sendfile) + err = err1 + break + } + } + if lr != nil { + lr.N = remain + } + if err != nil { + err = os.NewSyscallError("sendfile", err) + } + return written, err, written > 0 +} Index: gcc-7-7.2.0-12.1/src/libgo/go/net/sock_gnu.go =================================================================== --- /dev/null +++ gcc-7-7.2.0-12.1/src/libgo/go/net/sock_gnu.go @@ -0,0 +1,14 @@ +// Copyright 2014 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. + +// +build gnu + +package net + +import "syscall" + +func maxListenerBacklog() int { + // From /usr/include/i386-gnu/bits/socket.h + return syscall.SOMAXCONN +} Index: gcc-7-7.2.0-12.1/src/libgo/go/net/sockopt_gnu.go =================================================================== --- /dev/null +++ gcc-7-7.2.0-12.1/src/libgo/go/net/sockopt_gnu.go @@ -0,0 +1,45 @@ +// Copyright 2011 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. + +// +build gnu + +package net + +import ( + "os" + "syscall" +) + +func setDefaultSockopts(s, family, sotype int, ipv6only bool) error { + if family == syscall.AF_INET6 && sotype != syscall.SOCK_RAW { + // Allow both IP versions even if the OS default + // is otherwise. Note that some operating systems + // never admit this option. + syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, boolint(ipv6only)) + } + // Allow broadcast. + return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)) +} + +func setDefaultListenerSockopts(s int) error { + // Allow reuse of recently-used addresses. + return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)) +} + +func setDefaultMulticastSockopts(s int) error { + // Allow multicast UDP and raw IP datagram sockets to listen + // concurrently across multiple listeners. + if err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil { + return os.NewSyscallError("setsockopt", err) + } + // Allow reuse of recently-used ports. + // This option is supported only in descendants of 4.4BSD, + // to make an effective multicast application that requires + // quick draw possible. + // Not supported on GNU/Hurd + //if syscall.SO_REUSEPORT != 0 { + // return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1)) + //} + return nil +} Index: gcc-7-7.2.0-12.1/src/libgo/go/net/sockoptip_gnu.go =================================================================== --- /dev/null +++ gcc-7-7.2.0-12.1/src/libgo/go/net/sockoptip_gnu.go @@ -0,0 +1,30 @@ +// Copyright 2011 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. + +// +build gnu + +package net + +import ( + "os" + "syscall" +) + +func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error { + ip, err := interfaceToIPv4Addr(ifi) + if err != nil { + return os.NewSyscallError("setsockopt", err) + } + var a [4]byte + copy(a[:], ip.To4()) + if err := fd.incref(); err != nil { + return err + } + defer fd.decref() + return os.NewSyscallError("setsockopt", syscall.SetsockoptInet4Addr(fd.sysfd, syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, a)) +} + +func setIPv4MulticastLoopback(fd *netFD, v bool) error { + return syscall.ENOPROTOOPT +}