]> Cypherpunks.ru repositories - gostls13.git/commitdiff
net: adjust build tags for darwin libc calls
authorDan Peterson <danp@danp.net>
Sun, 6 Nov 2022 21:03:00 +0000 (17:03 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 7 Nov 2022 21:05:53 +0000 (21:05 +0000)
Support for direct libc calls was added in CL 446178 but the build
tags weren't quite activating it when cgo was not enabled. Adjust them
and add a new supporting file for darwin.

This should use the new direct libc calls with both CGO_ENABLED=0 and
CGO_ENABLED=1 when building for darwin.

Updates #12524

Change-Id: Ieee4b298dee13f389ed3a63c0a4a3a18c9180163
Reviewed-on: https://go-review.googlesource.com/c/go/+/448020
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dan Peterson <danp@danp.net>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/net/cgo_bsd.go
src/net/cgo_darwin.go [new file with mode: 0644]
src/net/cgo_stub.go
src/net/cgo_unix.go
src/net/cgo_unix_syscall.go
src/net/cgo_unix_test.go
src/net/netgo.go
src/net/netgo_unix_test.go

index 1456289b0691ba29a3167afde13757f3b6e82c7b..082e91faa8afb737bbbe92f95202872d560939da 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build cgo && !netgo && (darwin || dragonfly || freebsd)
+//go:build cgo && !netgo && (dragonfly || freebsd)
 
 package net
 
diff --git a/src/net/cgo_darwin.go b/src/net/cgo_darwin.go
new file mode 100644 (file)
index 0000000..129dd93
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2022 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 "internal/syscall/unix"
+
+const cgoAddrInfoFlags = (unix.AI_CANONNAME | unix.AI_V4MAPPED | unix.AI_ALL) & unix.AI_MASK
index 298d829f6fa6db090bb2ef20b055417c75bfe03e..c901d4bb80abd7d13f36e11a6f5d69cf0b25987b 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !cgo || netgo
+//go:build (!cgo && !darwin) || netgo
 
 package net
 
index a94472733815f0d20ea82ef7c247bd993c3beae6..4ca0fbee73ea2fd9f3966807ea7e69c5676fe36b 100644 (file)
@@ -7,7 +7,7 @@
 // Instead of C.foo it uses _C_foo, which is defined in either
 // cgo_unix_cgo.go or cgo_unix_syscall.go
 
-//go:build cgo && !netgo && unix
+//go:build !netgo && ((cgo && unix) || darwin)
 
 package net
 
index 7170f14c466bdf096c586c48ba0237505203dda0..c5c27967b1350dd7bb5bdd94b5e4970dbbfc111e 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build cgo && !netgo && darwin
+//go:build !netgo && darwin
 
 package net
 
index af9f9dc3f2c8f23e45e0dafaf850ea8d509a77ae..86726dd7e5c7095281035a228105655de8180f08 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build cgo && !netgo && unix
+//go:build (cgo || darwin) && !netgo && unix
 
 package net
 
index 75baa880354c5c3b64c4d68a0582c254a3e919ba..e478c88b30358670118fbbf3cdfb29a7cc55bbf1 100644 (file)
@@ -4,9 +4,9 @@
 
 // Default netGo to true if the netgo build tag is being used, or the
 // C library DNS routines are not available. Note that the C library
-// routines are always available on Windows.
+// routines are always available on Darwin and Windows.
 
-//go:build netgo || (!cgo && !windows)
+//go:build netgo || (!cgo && !darwin && !windows)
 
 package net
 
index 019772aa6aaab4ed183ca1089e44b6b89adba2e0..5ddebab1437596f8e68e4f00daa5ee8b4d72312c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build (!cgo || netgo) && (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris)
+//go:build (!cgo || netgo) && (dragonfly || freebsd || linux || netbsd || openbsd || solaris)
 
 package net