Skip to content

Commit 1cab57f

Browse files
committed
std.os.linux: Add some missing arch bits for loongarch64.
1 parent 9423712 commit 1cab57f

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

lib/std/os/linux/loongarch64.zig

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ const builtin = @import("builtin");
22
const std = @import("../../std.zig");
33
const linux = std.os.linux;
44
const SYS = linux.SYS;
5-
const iovec = std.os.iovec;
5+
const iovec = std.posix.iovec;
6+
const iovec_const = std.posix.iovec_const;
67
const uid_t = linux.uid_t;
78
const gid_t = linux.gid_t;
89
const stack_t = linux.stack_t;
910
const sigset_t = linux.sigset_t;
11+
const sockaddr = linux.sockaddr;
12+
const socklen_t = linux.socklen_t;
13+
const timespec = linux.timespec;
1014

1115
pub fn syscall0(number: SYS) usize {
1216
return asm volatile (
@@ -150,6 +154,30 @@ pub fn restore_rt() callconv(.naked) noreturn {
150154
);
151155
}
152156

157+
pub const msghdr = extern struct {
158+
name: ?*sockaddr,
159+
namelen: socklen_t,
160+
iov: [*]iovec,
161+
iovlen: i32,
162+
__pad1: i32 = 0,
163+
control: ?*anyopaque,
164+
controllen: socklen_t,
165+
__pad2: socklen_t = 0,
166+
flags: i32,
167+
};
168+
169+
pub const msghdr_const = extern struct {
170+
name: ?*const sockaddr,
171+
namelen: socklen_t,
172+
iov: [*]const iovec_const,
173+
iovlen: i32,
174+
__pad1: i32 = 0,
175+
control: ?*const anyopaque,
176+
controllen: socklen_t,
177+
__pad2: socklen_t = 0,
178+
flags: i32,
179+
};
180+
153181
pub const blksize_t = i32;
154182
pub const nlink_t = u32;
155183
pub const time_t = i64;
@@ -159,6 +187,38 @@ pub const ino_t = u64;
159187
pub const dev_t = u32;
160188
pub const blkcnt_t = i64;
161189

190+
// The `stat` definition used by the Linux kernel.
191+
pub const Stat = extern struct {
192+
dev: dev_t,
193+
ino: ino_t,
194+
mode: mode_t,
195+
nlink: nlink_t,
196+
uid: uid_t,
197+
gid: gid_t,
198+
rdev: dev_t,
199+
_pad1: u64,
200+
size: off_t,
201+
blksize: blksize_t,
202+
_pad2: i32,
203+
blocks: blkcnt_t,
204+
atim: timespec,
205+
mtim: timespec,
206+
ctim: timespec,
207+
_pad3: [2]u32,
208+
209+
pub fn atime(self: @This()) timespec {
210+
return self.atim;
211+
}
212+
213+
pub fn mtime(self: @This()) timespec {
214+
return self.mtim;
215+
}
216+
217+
pub fn ctime(self: @This()) timespec {
218+
return self.ctim;
219+
}
220+
};
221+
162222
pub const timeval = extern struct {
163223
tv_sec: time_t,
164224
tv_usec: i64,

0 commit comments

Comments
 (0)