sys_linkname.go 1.4 KB

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