3 Star 1 Fork 0

Gitee 极速下载/gatt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/paypal/gatt
克隆/下载
ioctl.go 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
Tzu-Jung Lee 提交于 10年前 . import gioctl
package gioctl
import "syscall"
const (
typeBits = 8
numberBits = 8
sizeBits = 14
directionBits = 2
typeMask = (1 << typeBits) - 1
numberMask = (1 << numberBits) - 1
sizeMask = (1 << sizeBits) - 1
directionMask = (1 << directionBits) - 1
directionNone = 0
directionWrite = 1
directionRead = 2
numberShift = 0
typeShift = numberShift + numberBits
sizeShift = typeShift + typeBits
directionShift = sizeShift + sizeBits
)
func ioc(dir, t, nr, size uintptr) uintptr {
return (dir << directionShift) | (t << typeShift) | (nr << numberShift) | (size << sizeShift)
}
// Io used for a simple ioctl that sends nothing but the type and number, and receives back nothing but an (integer) retval.
func Io(t, nr uintptr) uintptr {
return ioc(directionNone, t, nr, 0)
}
// IoR used for an ioctl that reads data from the device driver. The driver will be allowed to return sizeof(data_type) bytes to the user.
func IoR(t, nr, size uintptr) uintptr {
return ioc(directionRead, t, nr, size)
}
// IoW used for an ioctl that writes data to the device driver.
func IoW(t, nr, size uintptr) uintptr {
return ioc(directionWrite, t, nr, size)
}
// IoRW a combination of IoR and IoW. That is, data is both written to the driver and then read back from the driver by the client.
func IoRW(t, nr, size uintptr) uintptr {
return ioc(directionRead|directionWrite, t, nr, size)
}
// Ioctl simplified ioct call
func Ioctl(fd, op, arg uintptr) error {
_, _, ep := syscall.Syscall(syscall.SYS_IOCTL, fd, op, arg)
if ep != 0 {
return syscall.Errno(ep)
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/gatt.git
git@gitee.com:mirrors/gatt.git
mirrors
gatt
gatt
4ae819d591cf

搜索帮助