aboutsummaryrefslogtreecommitdiff
path: root/test/incremental/assert_function.18.zig
blob: 31cf1207f3dc07541a4210641ee136eb0ba385b0 (plain)
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
const builtin = @import("builtin");

extern "c" fn write(usize, usize, usize) usize;

pub fn main() void {
    for ("hello") |_| print();
}

fn print() void {
    switch (builtin.os.tag) {
        .linux => {
            asm volatile ("syscall"
                :
                : [number] "{rax}" (1),
                  [arg1] "{rdi}" (1),
                  [arg2] "{rsi}" (@ptrToInt("hello\n")),
                  [arg3] "{rdx}" (6),
                : "rcx", "r11", "memory"
            );
        },
        .macos => {
            _ = write(1, @ptrToInt("hello\n"), 6);
        },
        else => unreachable,
    }
}

// run
//
// hello
// hello
// hello
// hello
// hello
//