summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Poliwczak <mpoliwczak34@gmail.com>2023-05-11 08:21:21 +0000
committerGopher Robot <gobot@golang.org>2023-05-16 16:01:08 +0000
commit5534f04498cfa71a69a78b9065e7f9138b48f05f (patch)
treebeef615463126194da0c63951f20e7253701b20b
parent04e2472895e7021f632cf76a89872a011c519cef (diff)
downloadgo-git-5534f04498cfa71a69a78b9065e7f9138b48f05f.tar.gz
net: use and assert correct res state size at compile time when cgo available on darwin
Change-Id: I961bb18604dd1568ea21431545f43aa6a417b3d9 GitHub-Last-Rev: 735f3364a4f2182f3e3e1b84f39a042e86987967 GitHub-Pull-Request: golang/go#60046 Reviewed-on: https://go-review.googlesource.com/c/go/+/493415 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
-rw-r--r--src/internal/syscall/unix/net_darwin.go2
-rw-r--r--src/net/cgo_unix_cgo_darwin.go21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/internal/syscall/unix/net_darwin.go b/src/internal/syscall/unix/net_darwin.go
index 8b908ae600..5601b49750 100644
--- a/src/internal/syscall/unix/net_darwin.go
+++ b/src/internal/syscall/unix/net_darwin.go
@@ -119,7 +119,7 @@ func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err
func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
type ResState struct {
- unexported [70]uintptr
+ unexported [69]uintptr
}
//go:cgo_import_dynamic libresolv_res_9_ninit res_9_ninit "/usr/lib/libresolv.9.dylib"
diff --git a/src/net/cgo_unix_cgo_darwin.go b/src/net/cgo_unix_cgo_darwin.go
new file mode 100644
index 0000000000..40d5e426f2
--- /dev/null
+++ b/src/net/cgo_unix_cgo_darwin.go
@@ -0,0 +1,21 @@
+// Copyright 2023 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.
+
+//go:build !netgo && cgo && darwin
+
+package net
+
+/*
+#include <resolv.h>
+*/
+import "C"
+
+import (
+ "internal/syscall/unix"
+ "unsafe"
+)
+
+// This will cause a compile error when the size of
+// unix.ResState is too small.
+type _ [unsafe.Sizeof(unix.ResState{}) - unsafe.Sizeof(C.struct___res_state{})]byte