ioctl_bsd.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // +build darwin dragonfly freebsd netbsd openbsd
  2. package pty
  3. // from <sys/ioccom.h>
  4. const (
  5. _IOC_VOID uintptr = 0x20000000
  6. _IOC_OUT uintptr = 0x40000000
  7. _IOC_IN uintptr = 0x80000000
  8. _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN
  9. _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN
  10. _IOC_PARAM_SHIFT = 13
  11. _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1
  12. )
  13. func _IOC_PARM_LEN(ioctl uintptr) uintptr {
  14. return (ioctl >> 16) & _IOC_PARAM_MASK
  15. }
  16. func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr {
  17. return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num
  18. }
  19. func _IO(group byte, ioctl_num uintptr) uintptr {
  20. return _IOC(_IOC_VOID, group, ioctl_num, 0)
  21. }
  22. func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr {
  23. return _IOC(_IOC_OUT, group, ioctl_num, param_len)
  24. }
  25. func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr {
  26. return _IOC(_IOC_IN, group, ioctl_num, param_len)
  27. }
  28. func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr {
  29. return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len)
  30. }