mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
std.c: adding freebsd's ioctl base operands.
This commit is contained in:
parent
ebc3773542
commit
cd7e2bf57a
@ -2607,3 +2607,31 @@ pub const domainset = extern struct {
|
|||||||
|
|
||||||
pub extern "c" fn cpuset_getdomain(level: cpulevel_t, which: cpuwhich_t, id: id_t, len: usize, domain: *domainset_t, r: *c_int) c_int;
|
pub extern "c" fn cpuset_getdomain(level: cpulevel_t, which: cpuwhich_t, id: id_t, len: usize, domain: *domainset_t, r: *c_int) c_int;
|
||||||
pub extern "c" fn cpuset_setdomain(level: cpulevel_t, which: cpuwhich_t, id: id_t, len: usize, domain: *const domainset_t, r: c_int) c_int;
|
pub extern "c" fn cpuset_setdomain(level: cpulevel_t, which: cpuwhich_t, id: id_t, len: usize, domain: *const domainset_t, r: c_int) c_int;
|
||||||
|
|
||||||
|
const ioctl_cmd = enum(u32) {
|
||||||
|
VOID = 0x20000000,
|
||||||
|
OUT = 0x40000000,
|
||||||
|
IN = 0x80000000,
|
||||||
|
INOUT = ioctl_cmd.IN | ioctl_cmd.OUT,
|
||||||
|
DIRMASK = ioctl_cmd.VOID | ioctl_cmd.IN | ioctl_cmd.OUT,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn ioImpl(cmd: ioctl_cmd, op: u8, nr: u8, comptime IT: type) u32 {
|
||||||
|
return @bitCast(u32, @enumToInt(cmd) | @intCast(u32, @truncate(u8, @sizeOf(IT))) << 16 | @intCast(u32, op) << 8 | nr);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn IO(op: u8, nr: u8) u32 {
|
||||||
|
return ioImpl(ioctl_cmd.VOID, op, nr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn IOR(op: u8, nr: u8, comptime IT: type) u32 {
|
||||||
|
return ioImpl(ioctl_cmd.OUT, op, nr, @sizeOf(IT));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn IOW(op: u8, nr: u8, comptime IT: type) u32 {
|
||||||
|
return ioImpl(ioctl_cmd.IN, op, nr, @sizeOf(IT));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn IOWR(op: u8, nr: u8, comptime IT: type) u32 {
|
||||||
|
return ioImpl(ioctl_cmd.INOUT, op, nr, @sizeOf(IT));
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user