From 21e18009e2390e5120d4a6c80717f38875f624d6 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 26 Jan 2021 12:31:59 +0000 Subject: [PATCH] unix: add Sysconf on solaris This wraps sysconf(3) on solaris. Change-Id: Ie5dd32bfa98bf900cadce6f20cefd553fdf80e29 Reviewed-on: https://go-review.googlesource.com/c/sys/+/286593 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- unix/syscall_solaris.go | 1 + unix/syscall_solaris_test.go | 8 ++++++++ unix/zsyscall_solaris_amd64.go | 14 ++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/unix/syscall_solaris.go b/unix/syscall_solaris.go index 9fdcaac5..169497f0 100644 --- a/unix/syscall_solaris.go +++ b/unix/syscall_solaris.go @@ -682,6 +682,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Statvfs(path string, vfsstat *Statvfs_t) (err error) //sys Symlink(path string, link string) (err error) //sys Sync() (err error) +//sys Sysconf(which int) (n int64, err error) //sysnb Times(tms *Tms) (ticks uintptr, err error) //sys Truncate(path string, length int64) (err error) //sys Fsync(fd int) (err error) diff --git a/unix/syscall_solaris_test.go b/unix/syscall_solaris_test.go index ae2c40c5..f4d73a85 100644 --- a/unix/syscall_solaris_test.go +++ b/unix/syscall_solaris_test.go @@ -74,3 +74,11 @@ func TestStatvfs(t *testing.T) { } } } + +func TestSysconf(t *testing.T) { + n, err := unix.Sysconf(3 /* SC_CLK_TCK */) + if err != nil { + t.Fatalf("Sysconf: %v", err) + } + t.Logf("Sysconf(SC_CLK_TCK) = %d", n) +} diff --git a/unix/zsyscall_solaris_amd64.go b/unix/zsyscall_solaris_amd64.go index 6dbb8371..9898ce1f 100644 --- a/unix/zsyscall_solaris_amd64.go +++ b/unix/zsyscall_solaris_amd64.go @@ -115,6 +115,7 @@ import ( //go:cgo_import_dynamic libc_statvfs statvfs "libc.so" //go:cgo_import_dynamic libc_symlink symlink "libc.so" //go:cgo_import_dynamic libc_sync sync "libc.so" +//go:cgo_import_dynamic libc_sysconf sysconf "libc.so" //go:cgo_import_dynamic libc_times times "libc.so" //go:cgo_import_dynamic libc_truncate truncate "libc.so" //go:cgo_import_dynamic libc_fsync fsync "libc.so" @@ -245,6 +246,7 @@ import ( //go:linkname procStatvfs libc_statvfs //go:linkname procSymlink libc_symlink //go:linkname procSync libc_sync +//go:linkname procSysconf libc_sysconf //go:linkname procTimes libc_times //go:linkname procTruncate libc_truncate //go:linkname procFsync libc_fsync @@ -376,6 +378,7 @@ var ( procStatvfs, procSymlink, procSync, + procSysconf, procTimes, procTruncate, procFsync, @@ -1687,6 +1690,17 @@ func Sync() (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Sysconf(which int) (n int64, err error) { + r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procSysconf)), 1, uintptr(which), 0, 0, 0, 0, 0) + n = int64(r0) + if e1 != 0 { + err = e1 + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Times(tms *Tms) (ticks uintptr, err error) { r0, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procTimes)), 1, uintptr(unsafe.Pointer(tms)), 0, 0, 0, 0, 0) ticks = uintptr(r0)