summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/net/route/syscall.go
blob: 5f69ea63d91e1c05907df70de320d54a1cb67493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build darwin dragonfly freebsd netbsd openbsd

package route

import (
	"syscall"
	"unsafe"
)

var zero uintptr

func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
	var p unsafe.Pointer
	if len(mib) > 0 {
		p = unsafe.Pointer(&mib[0])
	} else {
		p = unsafe.Pointer(&zero)
	}
	_, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), newlen)
	if errno != 0 {
		return error(errno)
	}
	return nil
}