aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux/x86.zig
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2025-10-16 23:39:11 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2025-10-17 01:20:33 +0200
commitcfdc0f0e34b00a7e1a4dc23f1d6672f213bbf9ca (patch)
treece0d1478c80373c0167bf8708cc82ac8c546d2f2 /lib/std/os/linux/x86.zig
parentfc7a5f2ae49aa0a0c5e1f1dd1c5678ee3e49b1b6 (diff)
downloadzig-cfdc0f0e34b00a7e1a4dc23f1d6672f213bbf9ca.tar.gz
zig-cfdc0f0e34b00a7e1a4dc23f1d6672f213bbf9ca.zip
std.os.linux: replace usize/isize in arch bits with fixed types for clarity
Diffstat (limited to 'lib/std/os/linux/x86.zig')
-rw-r--r--lib/std/os/linux/x86.zig50
1 files changed, 25 insertions, 25 deletions
diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig
index aa94ad6a63..4f72c3cc63 100644
--- a/lib/std/os/linux/x86.zig
+++ b/lib/std/os/linux/x86.zig
@@ -14,33 +14,33 @@ const sigset_t = linux.sigset_t;
const sockaddr = linux.sockaddr;
const timespec = linux.timespec;
-pub fn syscall0(number: SYS) usize {
+pub fn syscall0(number: SYS) u32 {
return asm volatile ("int $0x80"
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(number)),
: .{ .memory = true });
}
-pub fn syscall1(number: SYS, arg1: usize) usize {
+pub fn syscall1(number: SYS, arg1: u32) u32 {
return asm volatile ("int $0x80"
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1),
: .{ .memory = true });
}
-pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
+pub fn syscall2(number: SYS, arg1: u32, arg2: u32) u32 {
return asm volatile ("int $0x80"
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
: .{ .memory = true });
}
-pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
+pub fn syscall3(number: SYS, arg1: u32, arg2: u32, arg3: u32) u32 {
return asm volatile ("int $0x80"
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
@@ -48,9 +48,9 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
: .{ .memory = true });
}
-pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
+pub fn syscall4(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32) u32 {
return asm volatile ("int $0x80"
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
@@ -59,9 +59,9 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
: .{ .memory = true });
}
-pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
+pub fn syscall5(number: SYS, arg1: u32, arg2: u32, arg3: u32, arg4: u32, arg5: u32) u32 {
return asm volatile ("int $0x80"
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
@@ -73,20 +73,20 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
pub fn syscall6(
number: SYS,
- arg1: usize,
- arg2: usize,
- arg3: usize,
- arg4: usize,
- arg5: usize,
- arg6: usize,
-) usize {
+ arg1: u32,
+ arg2: u32,
+ arg3: u32,
+ arg4: u32,
+ arg5: u32,
+ arg6: u32,
+) u32 {
// arg6 can't be passed to asm in a register because ebp might be reserved as the frame pointer
// and there are no more GPRs available; so we'll need a memory operand for it. Adding that
// memory operand means that on PIC we might need a reference to the GOT, which in turn needs
// *its* own GPR, so we need to pass another arg in memory too! This is surprisingly hard to get
// right, because we can't touch esp or ebp until we're done with the memory input (as that
// input could be relative to esp or ebp).
- const args56: [2]usize = .{ arg5, arg6 };
+ const args56: [2]u32 = .{ arg5, arg6 };
return asm volatile (
\\ push %[args56]
\\ push %%ebp
@@ -99,7 +99,7 @@ pub fn syscall6(
\\ int $0x80
\\ pop %%ebp
\\ pop %%edi
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(number)),
[arg1] "{ebx}" (arg1),
[arg2] "{ecx}" (arg2),
@@ -109,16 +109,16 @@ pub fn syscall6(
: .{ .memory = true });
}
-pub fn socketcall(call: usize, args: [*]const usize) usize {
+pub fn socketcall(call: u32, args: [*]const u32) u32 {
return asm volatile ("int $0x80"
- : [ret] "={eax}" (-> usize),
+ : [ret] "={eax}" (-> u32),
: [number] "{eax}" (@intFromEnum(SYS.socketcall)),
[arg1] "{ebx}" (call),
[arg2] "{ecx}" (@intFromPtr(args)),
: .{ .memory = true });
}
-pub fn clone() callconv(.naked) usize {
+pub fn clone() callconv(.naked) u32 {
// __clone(func, stack, flags, arg, ptid, tls, ctid)
// +8, +12, +16, +20, +24, +28, +32
//
@@ -239,7 +239,7 @@ pub const Flock = extern struct {
pub const blksize_t = i32;
pub const nlink_t = u32;
-pub const time_t = isize;
+pub const time_t = i32;
pub const mode_t = u32;
pub const off_t = i64;
pub const ino_t = u64;