commit fe314e60bbb2861484241a81d3d6185dbb60d1e8 (tree)
parent 09992f8acc2432080409c3c3b32cab52bc8a3d91
Author: Jacob G-W <jacoblevgw@gmail.com>
Date: Sun, 17 Oct 2021 01:14:27 -0400
fix outputs in inline assembly
Diffstat:
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/std/os/plan9.zig b/lib/std/os/plan9.zig
@@ -60,8 +60,8 @@ pub const SYS = enum(usize) {
_NSEC = 53,
};
-pub fn pwrite(fd: usize, buf: [*]const u8, count: usize, offset: usize) void {
- syscall_bits.syscall4(.PWRITE, fd, @ptrToInt(buf), count, offset);
+pub fn pwrite(fd: usize, buf: [*]const u8, count: usize, offset: usize) usize {
+ return syscall_bits.syscall4(.PWRITE, fd, @ptrToInt(buf), count, offset);
}
pub fn exits(status: ?[*:0]const u8) void {
diff --git a/lib/std/os/plan9/x86_64.zig b/lib/std/os/plan9/x86_64.zig
@@ -2,8 +2,8 @@ const plan9 = @import("../plan9.zig");
// TODO get ret from inline asm
// TODO better inline asm
-pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usize) void {
- asm volatile (
+pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usize) usize {
+ return asm volatile (
\\push %%r11
\\push %%r10
\\push %%r9
@@ -15,7 +15,8 @@ pub fn syscall4(sys: plan9.SYS, arg0: usize, arg1: usize, arg2: usize, arg3: usi
\\pop %%r11
\\pop %%r11
\\pop %%r11
- :
+ : [ret] "={rax}" (-> usize),
+ // :
: [arg0] "{r8}" (arg0),
[arg1] "{r9}" (arg1),
[arg2] "{r10}" (arg2),