sys_go1_11_darwin.go 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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 !go1.12
  5. package socket
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
  11. l := uint32(len(b))
  12. _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0)
  13. return int(l), errnoErr(errno)
  14. }
  15. func setsockopt(s uintptr, level, name int, b []byte) error {
  16. _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0)
  17. return errnoErr(errno)
  18. }
  19. func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
  20. n, _, errno := syscall.Syscall(syscall.SYS_RECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
  21. return int(n), errnoErr(errno)
  22. }
  23. func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
  24. n, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
  25. return int(n), errnoErr(errno)
  26. }