ioctl_solaris.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //go:build solaris
  2. // +build solaris
  3. package pty
  4. import (
  5. "syscall"
  6. "unsafe"
  7. )
  8. //go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
  9. //go:linkname procioctl libc_ioctl
  10. var procioctl uintptr
  11. const (
  12. // see /usr/include/sys/stropts.h
  13. I_PUSH = uintptr((int32('S')<<8 | 002))
  14. I_STR = uintptr((int32('S')<<8 | 010))
  15. I_FIND = uintptr((int32('S')<<8 | 013))
  16. // see /usr/include/sys/ptms.h
  17. ISPTM = (int32('P') << 8) | 1
  18. UNLKPT = (int32('P') << 8) | 2
  19. PTSSTTY = (int32('P') << 8) | 3
  20. ZONEPT = (int32('P') << 8) | 4
  21. OWNERPT = (int32('P') << 8) | 5
  22. // see /usr/include/sys/termios.h
  23. TIOCSWINSZ = (uint32('T') << 8) | 103
  24. TIOCGWINSZ = (uint32('T') << 8) | 104
  25. )
  26. type strioctl struct {
  27. icCmd int32
  28. icTimeout int32
  29. icLen int32
  30. icDP unsafe.Pointer
  31. }
  32. // Defined in asm_solaris_amd64.s.
  33. func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
  34. func ioctl(fd, cmd, ptr uintptr) error {
  35. if _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, fd, cmd, ptr, 0, 0, 0); errno != 0 {
  36. return errno
  37. }
  38. return nil
  39. }