unix: make IoctlSetPointerInt available on all platforms
This may be used with unix.TIOCSPGRP which is available on platforms
other than linux.
Fixes golang/go#40986
Change-Id: Ic96b119e68395e5b6c5f33504ad40f3dfd4804f7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/250001
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
diff --git a/unix/ioctl.go b/unix/ioctl.go
index 3559e5d..5641678 100644
--- a/unix/ioctl.go
+++ b/unix/ioctl.go
@@ -20,6 +20,15 @@
return ioctl(fd, req, uintptr(value))
}
+// IoctlSetPointerInt performs an ioctl operation which sets an
+// integer value on fd, using the specified request number. The ioctl
+// argument is called with a pointer to the integer value, rather than
+// passing the integer value directly.
+func IoctlSetPointerInt(fd int, req uint, value int) error {
+ v := int32(value)
+ return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
+}
+
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
//
// To change fd's window size, the req argument should be TIOCSWINSZ.
diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go
index 3e20fcf..5b3af2e 100644
--- a/unix/syscall_linux.go
+++ b/unix/syscall_linux.go
@@ -82,15 +82,6 @@
return int(ret), nil
}
-// IoctlSetPointerInt performs an ioctl operation which sets an
-// integer value on fd, using the specified request number. The ioctl
-// argument is called with a pointer to the integer value, rather than
-// passing the integer value directly.
-func IoctlSetPointerInt(fd int, req uint, value int) error {
- v := int32(value)
- return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
-}
-
func IoctlSetRTCTime(fd int, value *RTCTime) error {
err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value)