libgo: update to Go 1.11
[official-gcc.git] / libgo / go / net / cgo_sockold.go
blob25d4f67b4cbe8d820be863cc4ce5b4728e0985ea
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build cgo,!netgo
6 // +build aix darwin dragonfly freebsd netbsd openbsd
8 package net
11 #include <sys/types.h>
12 #include <sys/socket.h>
14 #include <netinet/in.h>
17 import (
18 "syscall"
19 "unsafe"
22 func cgoSockaddrInet4(ip IP) *syscall.RawSockaddr {
23 sa := syscall.RawSockaddrInet4{Len: syscall.SizeofSockaddrInet4, Family: syscall.AF_INET}
24 copy(sa.Addr[:], ip)
25 return (*syscall.RawSockaddr)(unsafe.Pointer(&sa))
28 func cgoSockaddrInet6(ip IP, zone int) *syscall.RawSockaddr {
29 sa := syscall.RawSockaddrInet6{Len: syscall.SizeofSockaddrInet6, Family: syscall.AF_INET6, Scope_id: uint32(zone)}
30 copy(sa.Addr[:], ip)
31 return (*syscall.RawSockaddr)(unsafe.Pointer(&sa))