mirror of
https://github.com/golang/sys.git
synced 2026-01-29 07:02:06 +03:00
unix: add Uvmexp and SysctlUvmexp for NetBSD
NetBSD has both struct uvmexp (used internally) and struct uvmexp_sysctl (preferred for interfacing from user code). Expose the latter as type Uvmexp with the same interface as on OpenBSD. I am not sure if it makes sense to even have a name parameter for SysctlUvmexp, since the only valid value can be "vm.uvmext2". Change-Id: I40a743536c28e3fb7a54253768db35b1629fabfe Reviewed-on: https://go-review.googlesource.com/c/sys/+/460156 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
committed by
Benny Siegert
parent
b751db56c7
commit
b60007cc4e
@@ -110,6 +110,20 @@ func direntNamlen(buf []byte) (uint64, bool) {
|
||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
|
||||
}
|
||||
|
||||
func SysctlUvmexp(name string) (*Uvmexp, error) {
|
||||
mib, err := sysctlmib(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
n := uintptr(SizeofUvmexp)
|
||||
var u Uvmexp
|
||||
if err := sysctl(mib, (*byte)(unsafe.Pointer(&u)), &n, nil, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &u, nil
|
||||
}
|
||||
|
||||
func Pipe(p []int) (err error) {
|
||||
return Pipe2(p, 0)
|
||||
}
|
||||
|
||||
15
unix/sysctl_netbsd_test.go
Normal file
15
unix/sysctl_netbsd_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2023 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.
|
||||
|
||||
package unix
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestSysctlUvmexp(t *testing.T) {
|
||||
uvm, err := SysctlUvmexp("vm.uvmexp2")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("%#v", uvm)
|
||||
}
|
||||
@@ -41,6 +41,7 @@ package unix
|
||||
#include <sys/un.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/wait.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
#include <net/bpf.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
@@ -297,6 +298,12 @@ type Sysctlnode C.struct_sysctlnode
|
||||
|
||||
type Utsname C.struct_utsname
|
||||
|
||||
// Uvmexp
|
||||
|
||||
const SizeofUvmexp = C.sizeof_struct_uvmexp_sysctl
|
||||
|
||||
type Uvmexp C.struct_uvmexp_sysctl
|
||||
|
||||
// Clockinfo
|
||||
|
||||
const SizeofClockinfo = C.sizeof_struct_clockinfo
|
||||
|
||||
@@ -491,6 +491,90 @@ type Utsname struct {
|
||||
Machine [256]byte
|
||||
}
|
||||
|
||||
const SizeofUvmexp = 0x278
|
||||
|
||||
type Uvmexp struct {
|
||||
Pagesize int64
|
||||
Pagemask int64
|
||||
Pageshift int64
|
||||
Npages int64
|
||||
Free int64
|
||||
Active int64
|
||||
Inactive int64
|
||||
Paging int64
|
||||
Wired int64
|
||||
Zeropages int64
|
||||
Reserve_pagedaemon int64
|
||||
Reserve_kernel int64
|
||||
Freemin int64
|
||||
Freetarg int64
|
||||
Inactarg int64
|
||||
Wiredmax int64
|
||||
Nswapdev int64
|
||||
Swpages int64
|
||||
Swpginuse int64
|
||||
Swpgonly int64
|
||||
Nswget int64
|
||||
Unused1 int64
|
||||
Cpuhit int64
|
||||
Cpumiss int64
|
||||
Faults int64
|
||||
Traps int64
|
||||
Intrs int64
|
||||
Swtch int64
|
||||
Softs int64
|
||||
Syscalls int64
|
||||
Pageins int64
|
||||
Swapins int64
|
||||
Swapouts int64
|
||||
Pgswapin int64
|
||||
Pgswapout int64
|
||||
Forks int64
|
||||
Forks_ppwait int64
|
||||
Forks_sharevm int64
|
||||
Pga_zerohit int64
|
||||
Pga_zeromiss int64
|
||||
Zeroaborts int64
|
||||
Fltnoram int64
|
||||
Fltnoanon int64
|
||||
Fltpgwait int64
|
||||
Fltpgrele int64
|
||||
Fltrelck int64
|
||||
Fltrelckok int64
|
||||
Fltanget int64
|
||||
Fltanretry int64
|
||||
Fltamcopy int64
|
||||
Fltnamap int64
|
||||
Fltnomap int64
|
||||
Fltlget int64
|
||||
Fltget int64
|
||||
Flt_anon int64
|
||||
Flt_acow int64
|
||||
Flt_obj int64
|
||||
Flt_prcopy int64
|
||||
Flt_przero int64
|
||||
Pdwoke int64
|
||||
Pdrevs int64
|
||||
Unused4 int64
|
||||
Pdfreed int64
|
||||
Pdscans int64
|
||||
Pdanscan int64
|
||||
Pdobscan int64
|
||||
Pdreact int64
|
||||
Pdbusy int64
|
||||
Pdpageouts int64
|
||||
Pdpending int64
|
||||
Pddeact int64
|
||||
Anonpages int64
|
||||
Filepages int64
|
||||
Execpages int64
|
||||
Colorhit int64
|
||||
Colormiss int64
|
||||
Ncolors int64
|
||||
Bootpages int64
|
||||
Poolpages int64
|
||||
}
|
||||
|
||||
const SizeofClockinfo = 0x14
|
||||
|
||||
type Clockinfo struct {
|
||||
|
||||
@@ -499,6 +499,90 @@ type Utsname struct {
|
||||
Machine [256]byte
|
||||
}
|
||||
|
||||
const SizeofUvmexp = 0x278
|
||||
|
||||
type Uvmexp struct {
|
||||
Pagesize int64
|
||||
Pagemask int64
|
||||
Pageshift int64
|
||||
Npages int64
|
||||
Free int64
|
||||
Active int64
|
||||
Inactive int64
|
||||
Paging int64
|
||||
Wired int64
|
||||
Zeropages int64
|
||||
Reserve_pagedaemon int64
|
||||
Reserve_kernel int64
|
||||
Freemin int64
|
||||
Freetarg int64
|
||||
Inactarg int64
|
||||
Wiredmax int64
|
||||
Nswapdev int64
|
||||
Swpages int64
|
||||
Swpginuse int64
|
||||
Swpgonly int64
|
||||
Nswget int64
|
||||
Unused1 int64
|
||||
Cpuhit int64
|
||||
Cpumiss int64
|
||||
Faults int64
|
||||
Traps int64
|
||||
Intrs int64
|
||||
Swtch int64
|
||||
Softs int64
|
||||
Syscalls int64
|
||||
Pageins int64
|
||||
Swapins int64
|
||||
Swapouts int64
|
||||
Pgswapin int64
|
||||
Pgswapout int64
|
||||
Forks int64
|
||||
Forks_ppwait int64
|
||||
Forks_sharevm int64
|
||||
Pga_zerohit int64
|
||||
Pga_zeromiss int64
|
||||
Zeroaborts int64
|
||||
Fltnoram int64
|
||||
Fltnoanon int64
|
||||
Fltpgwait int64
|
||||
Fltpgrele int64
|
||||
Fltrelck int64
|
||||
Fltrelckok int64
|
||||
Fltanget int64
|
||||
Fltanretry int64
|
||||
Fltamcopy int64
|
||||
Fltnamap int64
|
||||
Fltnomap int64
|
||||
Fltlget int64
|
||||
Fltget int64
|
||||
Flt_anon int64
|
||||
Flt_acow int64
|
||||
Flt_obj int64
|
||||
Flt_prcopy int64
|
||||
Flt_przero int64
|
||||
Pdwoke int64
|
||||
Pdrevs int64
|
||||
Unused4 int64
|
||||
Pdfreed int64
|
||||
Pdscans int64
|
||||
Pdanscan int64
|
||||
Pdobscan int64
|
||||
Pdreact int64
|
||||
Pdbusy int64
|
||||
Pdpageouts int64
|
||||
Pdpending int64
|
||||
Pddeact int64
|
||||
Anonpages int64
|
||||
Filepages int64
|
||||
Execpages int64
|
||||
Colorhit int64
|
||||
Colormiss int64
|
||||
Ncolors int64
|
||||
Bootpages int64
|
||||
Poolpages int64
|
||||
}
|
||||
|
||||
const SizeofClockinfo = 0x14
|
||||
|
||||
type Clockinfo struct {
|
||||
|
||||
@@ -496,6 +496,90 @@ type Utsname struct {
|
||||
Machine [256]byte
|
||||
}
|
||||
|
||||
const SizeofUvmexp = 0x278
|
||||
|
||||
type Uvmexp struct {
|
||||
Pagesize int64
|
||||
Pagemask int64
|
||||
Pageshift int64
|
||||
Npages int64
|
||||
Free int64
|
||||
Active int64
|
||||
Inactive int64
|
||||
Paging int64
|
||||
Wired int64
|
||||
Zeropages int64
|
||||
Reserve_pagedaemon int64
|
||||
Reserve_kernel int64
|
||||
Freemin int64
|
||||
Freetarg int64
|
||||
Inactarg int64
|
||||
Wiredmax int64
|
||||
Nswapdev int64
|
||||
Swpages int64
|
||||
Swpginuse int64
|
||||
Swpgonly int64
|
||||
Nswget int64
|
||||
Unused1 int64
|
||||
Cpuhit int64
|
||||
Cpumiss int64
|
||||
Faults int64
|
||||
Traps int64
|
||||
Intrs int64
|
||||
Swtch int64
|
||||
Softs int64
|
||||
Syscalls int64
|
||||
Pageins int64
|
||||
Swapins int64
|
||||
Swapouts int64
|
||||
Pgswapin int64
|
||||
Pgswapout int64
|
||||
Forks int64
|
||||
Forks_ppwait int64
|
||||
Forks_sharevm int64
|
||||
Pga_zerohit int64
|
||||
Pga_zeromiss int64
|
||||
Zeroaborts int64
|
||||
Fltnoram int64
|
||||
Fltnoanon int64
|
||||
Fltpgwait int64
|
||||
Fltpgrele int64
|
||||
Fltrelck int64
|
||||
Fltrelckok int64
|
||||
Fltanget int64
|
||||
Fltanretry int64
|
||||
Fltamcopy int64
|
||||
Fltnamap int64
|
||||
Fltnomap int64
|
||||
Fltlget int64
|
||||
Fltget int64
|
||||
Flt_anon int64
|
||||
Flt_acow int64
|
||||
Flt_obj int64
|
||||
Flt_prcopy int64
|
||||
Flt_przero int64
|
||||
Pdwoke int64
|
||||
Pdrevs int64
|
||||
Unused4 int64
|
||||
Pdfreed int64
|
||||
Pdscans int64
|
||||
Pdanscan int64
|
||||
Pdobscan int64
|
||||
Pdreact int64
|
||||
Pdbusy int64
|
||||
Pdpageouts int64
|
||||
Pdpending int64
|
||||
Pddeact int64
|
||||
Anonpages int64
|
||||
Filepages int64
|
||||
Execpages int64
|
||||
Colorhit int64
|
||||
Colormiss int64
|
||||
Ncolors int64
|
||||
Bootpages int64
|
||||
Poolpages int64
|
||||
}
|
||||
|
||||
const SizeofClockinfo = 0x14
|
||||
|
||||
type Clockinfo struct {
|
||||
|
||||
@@ -499,6 +499,90 @@ type Utsname struct {
|
||||
Machine [256]byte
|
||||
}
|
||||
|
||||
const SizeofUvmexp = 0x278
|
||||
|
||||
type Uvmexp struct {
|
||||
Pagesize int64
|
||||
Pagemask int64
|
||||
Pageshift int64
|
||||
Npages int64
|
||||
Free int64
|
||||
Active int64
|
||||
Inactive int64
|
||||
Paging int64
|
||||
Wired int64
|
||||
Zeropages int64
|
||||
Reserve_pagedaemon int64
|
||||
Reserve_kernel int64
|
||||
Freemin int64
|
||||
Freetarg int64
|
||||
Inactarg int64
|
||||
Wiredmax int64
|
||||
Nswapdev int64
|
||||
Swpages int64
|
||||
Swpginuse int64
|
||||
Swpgonly int64
|
||||
Nswget int64
|
||||
Unused1 int64
|
||||
Cpuhit int64
|
||||
Cpumiss int64
|
||||
Faults int64
|
||||
Traps int64
|
||||
Intrs int64
|
||||
Swtch int64
|
||||
Softs int64
|
||||
Syscalls int64
|
||||
Pageins int64
|
||||
Swapins int64
|
||||
Swapouts int64
|
||||
Pgswapin int64
|
||||
Pgswapout int64
|
||||
Forks int64
|
||||
Forks_ppwait int64
|
||||
Forks_sharevm int64
|
||||
Pga_zerohit int64
|
||||
Pga_zeromiss int64
|
||||
Zeroaborts int64
|
||||
Fltnoram int64
|
||||
Fltnoanon int64
|
||||
Fltpgwait int64
|
||||
Fltpgrele int64
|
||||
Fltrelck int64
|
||||
Fltrelckok int64
|
||||
Fltanget int64
|
||||
Fltanretry int64
|
||||
Fltamcopy int64
|
||||
Fltnamap int64
|
||||
Fltnomap int64
|
||||
Fltlget int64
|
||||
Fltget int64
|
||||
Flt_anon int64
|
||||
Flt_acow int64
|
||||
Flt_obj int64
|
||||
Flt_prcopy int64
|
||||
Flt_przero int64
|
||||
Pdwoke int64
|
||||
Pdrevs int64
|
||||
Unused4 int64
|
||||
Pdfreed int64
|
||||
Pdscans int64
|
||||
Pdanscan int64
|
||||
Pdobscan int64
|
||||
Pdreact int64
|
||||
Pdbusy int64
|
||||
Pdpageouts int64
|
||||
Pdpending int64
|
||||
Pddeact int64
|
||||
Anonpages int64
|
||||
Filepages int64
|
||||
Execpages int64
|
||||
Colorhit int64
|
||||
Colormiss int64
|
||||
Ncolors int64
|
||||
Bootpages int64
|
||||
Poolpages int64
|
||||
}
|
||||
|
||||
const SizeofClockinfo = 0x14
|
||||
|
||||
type Clockinfo struct {
|
||||
|
||||
Reference in New Issue
Block a user