aboutsummaryrefslogtreecommitdiff
path: root/src/vendor
diff options
context:
space:
mode:
authorKeith Randall <keithr@alum.mit.edu>2018-11-07 21:25:42 -0800
committerKeith Randall <khr@golang.org>2018-11-14 22:39:08 +0000
commit82c260099d8178c55978e402385b8e19a6259011 (patch)
tree0d15cfb1e8267a8156816865108aaccc1798ce98 /src/vendor
parent8dba66dfeb8eb19b075d45a84dae9bcdddb347d6 (diff)
downloadgo-82c260099d8178c55978e402385b8e19a6259011.tar.gz
go-82c260099d8178c55978e402385b8e19a6259011.zip
x/net/route: use libc calls on Darwin
Starting with 1.12, we must use syscall versions of sysctl instead of the raw syscall. An identical CL went into the source copy at golang.org/x/net/route. This is just a cherry pick of that CL. (CL: https://go-review.googlesource.com/c/net/+/148597) Change-Id: I6286ab3e49f82512491afb5bcf349e89ab5645ab Reviewed-on: https://go-review.googlesource.com/c/149637 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/vendor')
-rw-r--r--src/vendor/golang_org/x/net/route/empty.s7
-rw-r--r--src/vendor/golang_org/x/net/route/syscall.go2
-rw-r--r--src/vendor/golang_org/x/net/route/syscall_go1_11_darwin.go28
-rw-r--r--src/vendor/golang_org/x/net/route/syscall_go1_12_darwin.go12
4 files changed, 48 insertions, 1 deletions
diff --git a/src/vendor/golang_org/x/net/route/empty.s b/src/vendor/golang_org/x/net/route/empty.s
new file mode 100644
index 0000000000..bff0231c7d
--- /dev/null
+++ b/src/vendor/golang_org/x/net/route/empty.s
@@ -0,0 +1,7 @@
+// Copyright 2018 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 darwin,go1.12
+
+// This exists solely so we can linkname in symbols from syscall.
diff --git a/src/vendor/golang_org/x/net/route/syscall.go b/src/vendor/golang_org/x/net/route/syscall.go
index 5f69ea63d9..72431b0341 100644
--- a/src/vendor/golang_org/x/net/route/syscall.go
+++ b/src/vendor/golang_org/x/net/route/syscall.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin dragonfly freebsd netbsd openbsd
+// +build dragonfly freebsd netbsd openbsd
package route
diff --git a/src/vendor/golang_org/x/net/route/syscall_go1_11_darwin.go b/src/vendor/golang_org/x/net/route/syscall_go1_11_darwin.go
new file mode 100644
index 0000000000..7228e443cd
--- /dev/null
+++ b/src/vendor/golang_org/x/net/route/syscall_go1_11_darwin.go
@@ -0,0 +1,28 @@
+// Copyright 2018 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 !go1.12
+
+package route
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var zero uintptr
+
+func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
+ var p unsafe.Pointer
+ if len(mib) > 0 {
+ p = unsafe.Pointer(&mib[0])
+ } else {
+ p = unsafe.Pointer(&zero)
+ }
+ _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), newlen)
+ if errno != 0 {
+ return error(errno)
+ }
+ return nil
+}
diff --git a/src/vendor/golang_org/x/net/route/syscall_go1_12_darwin.go b/src/vendor/golang_org/x/net/route/syscall_go1_12_darwin.go
new file mode 100644
index 0000000000..7922a6836f
--- /dev/null
+++ b/src/vendor/golang_org/x/net/route/syscall_go1_12_darwin.go
@@ -0,0 +1,12 @@
+// Copyright 2018 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 go1.12
+
+package route
+
+import _ "unsafe" // for linkname
+
+//go:linkname sysctl syscall.sysctl
+func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error