aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-02-07 04:45:01 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-02-07 04:45:01 +0000
commit4a3e25712f25271876e83dfafe8ff2df4f643df7 (patch)
treef08bcfb2d4ad242945fd0534e39ed5753e4aab62 /libgo/go/net
parent4321f202f985f659e0150ee72ed3e14e554f9735 (diff)
downloadgcc-4a3e25712f25271876e83dfafe8ff2df4f643df7.zip
gcc-4a3e25712f25271876e83dfafe8ff2df4f643df7.tar.gz
gcc-4a3e25712f25271876e83dfafe8ff2df4f643df7.tar.bz2
os, net, crypto/x509: add hurd support
Patch by Svante Signell. Reviewed-on: https://go-review.googlesource.com/c/161519 From-SVN: r268604
Diffstat (limited to 'libgo/go/net')
-rw-r--r--libgo/go/net/cgo_hurd.go17
-rw-r--r--libgo/go/net/sendfile_glibc.go (renamed from libgo/go/net/sendfile_linux.go)2
-rw-r--r--libgo/go/net/sockopt_hurd.go41
3 files changed, 60 insertions, 0 deletions
diff --git a/libgo/go/net/cgo_hurd.go b/libgo/go/net/cgo_hurd.go
new file mode 100644
index 0000000..98e4cfa
--- /dev/null
+++ b/libgo/go/net/cgo_hurd.go
@@ -0,0 +1,17 @@
+// Copyright 2019 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.
+// This file is derived from cgo_bsd.go
+
+// +build cgo,!netgo
+// +build hurd
+
+package net
+
+/*
+#include <netdb.h>
+*/
+
+import "syscall"
+
+const cgoAddrInfoFlags = syscall.AI_CANONNAME | syscall.AI_V4MAPPED | syscall.AI_ALL
diff --git a/libgo/go/net/sendfile_linux.go b/libgo/go/net/sendfile_glibc.go
index 297e625..a71cfc9 100644
--- a/libgo/go/net/sendfile_linux.go
+++ b/libgo/go/net/sendfile_glibc.go
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build hurd linux
+
package net
import (
diff --git a/libgo/go/net/sockopt_hurd.go b/libgo/go/net/sockopt_hurd.go
new file mode 100644
index 0000000..c6de7a9
--- /dev/null
+++ b/libgo/go/net/sockopt_hurd.go
@@ -0,0 +1,41 @@
+// Copyright 2019 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 (
+ "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.
+ if err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1); err != nil {
+ return os.NewSyscallError("setsockopt", err)
+ }
+ return nil
+}
+
+func setDefaultListenerSockopts(s int) error {
+ // Allow reuse of recently-used addresses.
+ if err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil {
+ return os.NewSyscallError("setsockopt", err)
+ }
+ return nil
+}
+
+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)
+ }
+ return nil
+}