1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
14 // ioctl itself should not be exposed directly, but additional get/set
15 // functions for specific types are permissible.
17 // IoctlSetInt performs an ioctl operation which sets an integer value
18 // on fd, using the specified request number.
19 func IoctlSetInt(fd int, req uint, value int) error {
20 return ioctl(fd, req, uintptr(value))
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 {
29 return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
32 // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
34 // To change fd's window size, the req argument should be TIOCSWINSZ.
35 func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
36 // TODO: if we get the chance, remove the req parameter and
37 // hardcode TIOCSWINSZ.
38 err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
39 runtime.KeepAlive(value)
43 // IoctlSetTermios performs an ioctl on fd with a *Termios.
45 // The req value will usually be TCSETA or TIOCSETA.
46 func IoctlSetTermios(fd int, req uint, value *Termios) error {
47 // TODO: if we get the chance, remove the req parameter.
48 err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
49 runtime.KeepAlive(value)
53 // IoctlGetInt performs an ioctl operation which gets an integer value
54 // from fd, using the specified request number.
56 // A few ioctl requests use the return value as an output parameter;
57 // for those, IoctlRetInt should be used instead of this function.
58 func IoctlGetInt(fd int, req uint) (int, error) {
60 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
64 func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
66 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
70 func IoctlGetTermios(fd int, req uint) (*Termios, error) {
72 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))