mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
unix: add SysctlClockinfo on NetBSD
NetBSD uses sysctl with struct clockinfo to get clock rate information from the kernel. Add type Clockinfo and the SysctlClockinfo function to query this information. This will be used in github.com/tklauser/go-sysconf to get _SC_CLK_TCK on NetBSD. Change-Id: I9e67d766f491ec3b460f26cb243b3595f0ba4d69 Reviewed-on: https://go-review.googlesource.com/138035 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
c2ed4eda69
commit
8ccfc68037
@@ -4,6 +4,12 @@
|
||||
|
||||
package unix_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// stringsFromByteSlice converts a sequence of attributes to a []string.
|
||||
// On NetBSD, each entry consists of a single byte containing the length
|
||||
// of the attribute name, followed by the attribute name.
|
||||
@@ -18,3 +24,12 @@ func stringsFromByteSlice(buf []byte) []string {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func TestSysctlClockinfo(t *testing.T) {
|
||||
ci, err := unix.SysctlClockinfo("kern.clockrate")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("tick = %v, tickadj = %v, hz = %v, profhz = %v, stathz = %v",
|
||||
ci.Tick, ci.Tickadj, ci.Hz, ci.Profhz, ci.Stathz)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user