syscall_solaris.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2016 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. package ipv4
  5. import (
  6. "syscall"
  7. "unsafe"
  8. )
  9. //go:cgo_import_dynamic libc___xnet_getsockopt __xnet_getsockopt "libsocket.so"
  10. //go:cgo_import_dynamic libc_setsockopt setsockopt "libsocket.so"
  11. //go:linkname procGetsockopt libc___xnet_getsockopt
  12. //go:linkname procSetsockopt libc_setsockopt
  13. var (
  14. procGetsockopt uintptr
  15. procSetsockopt uintptr
  16. )
  17. func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (uintptr, uintptr, syscall.Errno)
  18. func getsockopt(s uintptr, level, name int, v unsafe.Pointer, l *uint32) error {
  19. _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procGetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0)
  20. if errno != 0 {
  21. return error(errno)
  22. }
  23. return nil
  24. }
  25. func setsockopt(s uintptr, level, name int, v unsafe.Pointer, l uint32) error {
  26. if _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procSetsockopt)), 5, s, uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 {
  27. return error(errno)
  28. }
  29. return nil
  30. }