Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Namespace

ioctl

Public Namespace

Namespaces

Structs

Values

Functions

fn io_impl(dir: Direction, io_type: u8, nr: u8, comptime T: type) u32
pub fn IO(io_type: u8, nr: u8) u32
pub fn IOR(io_type: u8, nr: u8, comptime T: type) u32
pub fn IOW(io_type: u8, nr: u8, comptime T: type) u32
pub fn IOWR(io_type: u8, nr: u8, comptime T: type) u32

File

os/linux/ioctl.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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);
}