port.go\
CGOFILES_freebsd=\
+ cgo_bsd.go\
cgo_unix.go\
GOFILES_darwin=\
port.go\
CGOFILES_darwin=\
+ cgo_bsd.go\
cgo_unix.go\
GOFILES_linux=\
GOFILES_linux+=cgo_stub.go
else
CGOFILES_linux=\
+ cgo_linux.go\
cgo_unix.go
endif
--- /dev/null
+// 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
+
+/*
+#include <netdb.h>
+*/
+import "C"
+
+func cgoAddrInfoMask() C.int {
+ return C.AI_MASK
+}
--- /dev/null
+// 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
+
+/*
+#include <netdb.h>
+*/
+import "C"
+
+func cgoAddrInfoMask() C.int {
+ return C.AI_CANONNAME | C.AI_V4MAPPED | C.AI_ALL
+}
// and similarly for IPv6), but in practice setting it causes
// getaddrinfo to return the wrong canonical name on Linux.
// So definitely leave it out.
- hints.ai_flags = C.AI_ALL | C.AI_V4MAPPED | C.AI_CANONNAME
+ hints.ai_flags = (C.AI_ALL | C.AI_V4MAPPED | C.AI_CANONNAME) & cgoAddrInfoMask()
h := C.CString(name)
defer C.free(unsafe.Pointer(h))