aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/unix/ioctl_signed.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/unix/ioctl_signed.go')
-rw-r--r--vendor/golang.org/x/sys/unix/ioctl_signed.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/ioctl_signed.go b/vendor/golang.org/x/sys/unix/ioctl_signed.go
new file mode 100644
index 0000000..5b0759b
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/ioctl_signed.go
@@ -0,0 +1,69 @@
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.
4
5//go:build aix || solaris
6
7package unix
8
9import (
10 "unsafe"
11)
12
13// ioctl itself should not be exposed directly, but additional get/set
14// functions for specific types are permissible.
15
16// IoctlSetInt performs an ioctl operation which sets an integer value
17// on fd, using the specified request number.
18func IoctlSetInt(fd int, req int, value int) error {
19 return ioctl(fd, req, uintptr(value))
20}
21
22// IoctlSetPointerInt performs an ioctl operation which sets an
23// integer value on fd, using the specified request number. The ioctl
24// argument is called with a pointer to the integer value, rather than
25// passing the integer value directly.
26func IoctlSetPointerInt(fd int, req int, value int) error {
27 v := int32(value)
28 return ioctlPtr(fd, req, unsafe.Pointer(&v))
29}
30
31// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
32//
33// To change fd's window size, the req argument should be TIOCSWINSZ.
34func IoctlSetWinsize(fd int, req int, value *Winsize) error {
35 // TODO: if we get the chance, remove the req parameter and
36 // hardcode TIOCSWINSZ.
37 return ioctlPtr(fd, req, unsafe.Pointer(value))
38}
39
40// IoctlSetTermios performs an ioctl on fd with a *Termios.
41//
42// The req value will usually be TCSETA or TIOCSETA.
43func IoctlSetTermios(fd int, req int, value *Termios) error {
44 // TODO: if we get the chance, remove the req parameter.
45 return ioctlPtr(fd, req, unsafe.Pointer(value))
46}
47
48// IoctlGetInt performs an ioctl operation which gets an integer value
49// from fd, using the specified request number.
50//
51// A few ioctl requests use the return value as an output parameter;
52// for those, IoctlRetInt should be used instead of this function.
53func IoctlGetInt(fd int, req int) (int, error) {
54 var value int
55 err := ioctlPtr(fd, req, unsafe.Pointer(&value))
56 return value, err
57}
58
59func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
60 var value Winsize
61 err := ioctlPtr(fd, req, unsafe.Pointer(&value))
62 return &value, err
63}
64
65func IoctlGetTermios(fd int, req int) (*Termios, error) {
66 var value Termios
67 err := ioctlPtr(fd, req, unsafe.Pointer(&value))
68 return &value, err
69}