github.com/Andyfoo/golang/x/net@v0.0.0-20190901054642-57c1bf301704/internal/socket/sys_linkname.go (about)

     1  // Copyright 2018 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.
     4  
     5  // +build aix go1.12,darwin
     6  
     7  package socket
     8  
     9  import (
    10  	"syscall"
    11  	"unsafe"
    12  )
    13  
    14  //go:linkname syscall_getsockopt syscall.getsockopt
    15  func syscall_getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *uint32) error
    16  
    17  func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
    18  	l := uint32(len(b))
    19  	err := syscall_getsockopt(int(s), level, name, unsafe.Pointer(&b[0]), &l)
    20  	return int(l), err
    21  }
    22  
    23  //go:linkname syscall_setsockopt syscall.setsockopt
    24  func syscall_setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error
    25  
    26  func setsockopt(s uintptr, level, name int, b []byte) error {
    27  	return syscall_setsockopt(int(s), level, name, unsafe.Pointer(&b[0]), uintptr(len(b)))
    28  }
    29  
    30  //go:linkname syscall_recvmsg syscall.recvmsg
    31  func syscall_recvmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)
    32  
    33  func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
    34  	return syscall_recvmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags)
    35  }
    36  
    37  //go:linkname syscall_sendmsg syscall.sendmsg
    38  func syscall_sendmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)
    39  
    40  func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
    41  	return syscall_sendmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags)
    42  }