Skip to content

Commit 2bddbd2

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Matt Layher <[email protected]>
1 parent fda5168 commit 2bddbd2

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

unix/ioctl.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ func IoctlSetInt(fd int, req uint, value int) error {
2020
return ioctl(fd, req, uintptr(value))
2121
}
2222

23+
// IoctlSetPointerInt performs an ioctl operation which sets an
24+
// integer value on fd, using the specified request number. The ioctl
25+
// argument is called with a pointer to the integer value, rather than
26+
// passing the integer value directly.
27+
func IoctlSetPointerInt(fd int, req uint, value int) error {
28+
v := int32(value)
29+
return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
30+
}
31+
2332
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
2433
//
2534
// To change fd's window size, the req argument should be TIOCSWINSZ.

unix/syscall_linux.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ func IoctlRetInt(fd int, req uint) (int, error) {
8282
return int(ret), nil
8383
}
8484

85-
// IoctlSetPointerInt performs an ioctl operation which sets an
86-
// integer value on fd, using the specified request number. The ioctl
87-
// argument is called with a pointer to the integer value, rather than
88-
// passing the integer value directly.
89-
func IoctlSetPointerInt(fd int, req uint, value int) error {
90-
v := int32(value)
91-
return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
92-
}
93-
9485
func IoctlSetRTCTime(fd int, value *RTCTime) error {
9586
err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value)))
9687
runtime.KeepAlive(value)

0 commit comments

Comments
 (0)