std.os.linux.ioctl.bits
常量
std.os.linux.ioctl.Direction
常量
std.os.linux.ioctl.IO
函数
pub fn IO(io_type: u8, nr: u8) u32
参数
io_type: u8
nr: u8
std.os.linux.ioctl.io_impl
函数
fn io_impl(dir: Direction, io_type: u8, nr: u8, comptime T: type) u32
参数
std.os.linux.ioctl.IOR
函数
pub fn IOR(io_type: u8, nr: u8, comptime T: type) u32
参数
io_type: u8
nr: u8
T: type
std.os.linux.ioctl.IOW
函数
pub fn IOW(io_type: u8, nr: u8, comptime T: type) u32
参数
io_type: u8
nr: u8
T: type
std.os.linux.ioctl.IOWR
函数
pub fn IOWR(io_type: u8, nr: u8, comptime T: type) u32
参数
io_type: u8
nr: u8
T: type
std.os.linux.ioctl.Request
容器
字段
std.os.linux.ioctl.std
别名
别名目标 std
源码
std/os/linux/ioctl.zig
const std = @import("../../std.zig");
const bits = switch (@import("builtin").cpu.arch) {
.mips,
.mipsel,
.mips64,
.mips64el,
.powerpc,
.powerpcle,
.powerpc64,
.powerpc64le,
.sparc,
.sparc64,
.alpha,
=> .{ .size = 13, .dir = 3, .none = 1, .read = 2, .write = 4 },
else => .{ .size = 14, .dir = 2, .none = 0, .read = 2, .write = 1 },
};
const Direction = @Int(.unsigned, bits.dir);
pub const Request = packed struct {
nr: u8,
io_type: u8,
size: @Int(.unsigned, bits.size),
dir: Direction,
};
fn io_impl(dir: Direction, io_type: u8, nr: u8, comptime T: type) u32 {
const request = Request{
.dir = dir,
.size = @sizeOf(T),
.io_type = io_type,
.nr = nr,
};
return @as(u32, @bitCast(request));
}
pub fn IO(io_type: u8, nr: u8) u32 {
return io_impl(bits.none, io_type, nr, void);
}
pub fn IOR(io_type: u8, nr: u8, comptime T: type) u32 {
return io_impl(bits.read, io_type, nr, T);
}
pub fn IOW(io_type: u8, nr: u8, comptime T: type) u32 {
return io_impl(bits.write, io_type, nr, T);
}
pub fn IOWR(io_type: u8, nr: u8, comptime T: type) u32 {
return io_impl(bits.read | bits.write, io_type, nr, T);
}
comptime {
std.debug.assert(@bitSizeOf(Request) == 32);
}