syscall_go1_11_darwin.go 688 B

12345678910111213141516171819202122232425262728
  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 route
  6. import (
  7. "syscall"
  8. "unsafe"
  9. )
  10. var zero uintptr
  11. func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
  12. var p unsafe.Pointer
  13. if len(mib) > 0 {
  14. p = unsafe.Pointer(&mib[0])
  15. } else {
  16. p = unsafe.Pointer(&zero)
  17. }
  18. _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), newlen)
  19. if errno != 0 {
  20. return error(errno)
  21. }
  22. return nil
  23. }