From 2bddbd2f0c6ce06cbf082534b583160e3ef82a6a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 24 Aug 2020 11:42:11 +0200 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Matt Layher --- unix/ioctl.go | 9 +++++++++ unix/syscall_linux.go | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/unix/ioctl.go b/unix/ioctl.go index 3559e5dc..56416786 100644 --- a/unix/ioctl.go +++ b/unix/ioctl.go @@ -20,6 +20,15 @@ func IoctlSetInt(fd int, req uint, value int) error { 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 3e20fcf5..5b3af2e6 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -82,15 +82,6 @@ func IoctlRetInt(fd int, req uint) (int, error) { 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)