github.com/dolfly/pty@v1.2.1/ioctl_bsd.go (about)

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