From ca4314d39efd5f9dfa12b2eff7a945d9ead0b69e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20Chigot?= Date: Wed, 27 Feb 2019 15:44:43 +0100 Subject: [PATCH] net: allow build on aix/ppc64 with cgo This commit adds C support for net package for aix/ppc64. Change-Id: I704710991fc013c6ec3511671def6791df4854f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/164038 Run-TryBot: Mikio Hara TryBot-Result: Gobot Gobot Reviewed-by: Mikio Hara --- src/net/cgo_aix.go | 24 ++++++++++++++++++++++++ src/net/cgo_sockold.go | 2 +- src/net/cgo_unix.go | 7 ++++++- src/net/cgo_unix_test.go | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/net/cgo_aix.go diff --git a/src/net/cgo_aix.go b/src/net/cgo_aix.go new file mode 100644 index 0000000000..d0ad414a32 --- /dev/null +++ b/src/net/cgo_aix.go @@ -0,0 +1,24 @@ +// 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. + +// +build cgo,!netgo + +package net + +/* +#include +#include + +#include +*/ +import "C" + +import "unsafe" + +const cgoAddrInfoFlags = C.AI_CANONNAME + +func cgoNameinfoPTR(b []byte, sa *C.struct_sockaddr, salen C.socklen_t) (int, error) { + gerrno, err := C.getnameinfo(sa, C.size_t(salen), (*C.char)(unsafe.Pointer(&b[0])), C.size_t(len(b)), nil, 0, C.NI_NAMEREQD) + return int(gerrno), err +} diff --git a/src/net/cgo_sockold.go b/src/net/cgo_sockold.go index e629a09f9c..e1e642bb41 100644 --- a/src/net/cgo_sockold.go +++ b/src/net/cgo_sockold.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. // +build cgo,!netgo -// +build darwin dragonfly freebsd netbsd openbsd +// +build aix darwin dragonfly freebsd netbsd openbsd package net diff --git a/src/net/cgo_unix.go b/src/net/cgo_unix.go index b7cbcfe77a..6420fd05e7 100644 --- a/src/net/cgo_unix.go +++ b/src/net/cgo_unix.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. // +build cgo,!netgo -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net @@ -14,6 +14,11 @@ package net #include #include #include + +// If nothing else defined EAI_OVERFLOW, make sure it has a value. +#ifndef EAI_OVERFLOW +#define EAI_OVERFLOW -12 +#endif */ import "C" diff --git a/src/net/cgo_unix_test.go b/src/net/cgo_unix_test.go index c3eab5b3b2..99d79a60c4 100644 --- a/src/net/cgo_unix_test.go +++ b/src/net/cgo_unix_test.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. // +build cgo,!netgo -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package net -- 2.50.0