gcc/libgo/go/net/cgo_resnew.go
Ian Lance Taylor 27d6b51071 libgo: add hurd build tags
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160822

From-SVN: r268459
2019-02-01 21:57:36 +00:00

37 lines
871 B
Go

// Copyright 2015 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
// +build aix darwin hurd linux,!android netbsd solaris
package net
/*
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
*/
import (
"syscall"
)
//extern getnameinfo
func libc_getnameinfo(*syscall.RawSockaddr, syscall.Socklen_t, *byte, syscall.Size_t, *byte, syscall.Size_t, int) int
func cgoNameinfoPTR(b []byte, sa *syscall.RawSockaddr, salen syscall.Socklen_t) (int, error) {
syscall.Entersyscall()
gerrno := libc_getnameinfo(sa, salen, &b[0], syscall.Size_t(len(b)), nil, 0, syscall.NI_NAMEREQD)
syscall.Exitsyscall()
var err error
if gerrno == syscall.EAI_SYSTEM {
errno := syscall.GetErrno()
if errno != 0 {
err = errno
}
}
return gerrno, err
}