zig/test/cases/asm.zig

26 lines
630 B
Zig
Raw Normal View History

const config = @import("builtin");
const assert = @import("std").debug.assert;
comptime {
2017-12-18 22:59:57 +08:00
@export("derp", derp);
2017-08-27 12:11:09 +08:00
if (config.arch == config.Arch.x86_64 and config.os == config.Os.linux) {
asm volatile (
2017-12-18 22:59:57 +08:00
\\.globl my_aoeu_symbol_asdf;
\\.type my_aoeu_symbol_asdf, @function;
\\.set my_aoeu_symbol_asdf, derp;
);
}
}
test "module level assembly" {
2017-08-27 12:11:09 +08:00
if (config.arch == config.Arch.x86_64 and config.os == config.Os.linux) {
2017-12-18 22:59:57 +08:00
assert(my_aoeu_symbol_asdf() == 1234);
}
}
2017-12-18 22:59:57 +08:00
extern fn my_aoeu_symbol_asdf() -> i32;
2017-12-18 22:59:57 +08:00
extern fn derp() -> i32 {
return 1234;
}