authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-20 15:24:50-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-20 15:24:50-04:00
logf663bcd6b2ff8186e13b6826318fa3c8e72a9ff9
tree730df9620e4ad5d7a4142da2bb7a4cd0e94ed47f
parentea776c287b21286af393a7678240478caa8fa4f5
signaturelock-open Commit is signed but in an unrecognized format.

add more RISCV64 linux bits to std lib


3 files changed, 94 insertions(+), 1 deletions(-)

std/os/bits/linux.zig+1
...@@ -15,6 +15,7 @@ pub usingnamespace switch (builtin.arch) {...@@ -15,6 +15,7 @@ pub usingnamespace switch (builtin.arch) {
15pub const pid_t = i32;15pub const pid_t = i32;
16pub const fd_t = i32;16pub const fd_t = i32;
17pub const uid_t = i32;17pub const uid_t = i32;
18pub const gid_t = u32;
18pub const clock_t = isize;19pub const clock_t = isize;
1920
20pub const PATH_MAX = 4096;21pub const PATH_MAX = 4096;
std/os/bits/linux/riscv64.zig+92
...@@ -1,4 +1,7 @@...@@ -1,4 +1,7 @@
1// riscv64-specific declarations that are intended to be imported into the POSIX namespace.1// riscv64-specific declarations that are intended to be imported into the POSIX namespace.
2const std = @import("../../../std.zig");
3const uid_t = std.os.linux.uid_t;
4const gid_t = std.os.linux.gid_t;
25
3pub const SYS_io_setup = 0;6pub const SYS_io_setup = 0;
4pub const SYS_io_destroy = 1;7pub const SYS_io_destroy = 1;
...@@ -294,3 +297,92 @@ pub const SYS_fsmount = 432;...@@ -294,3 +297,92 @@ pub const SYS_fsmount = 432;
294pub const SYS_fspick = 433;297pub const SYS_fspick = 433;
295pub const SYS_pidfd_open = 434;298pub const SYS_pidfd_open = 434;
296pub const SYS_clone3 = 435;299pub const SYS_clone3 = 435;
300
301pub const O_CREAT = 0100;
302pub const O_EXCL = 0200;
303pub const O_NOCTTY = 0400;
304pub const O_TRUNC = 01000;
305pub const O_APPEND = 02000;
306pub const O_NONBLOCK = 04000;
307pub const O_DSYNC = 010000;
308pub const O_SYNC = 04010000;
309pub const O_RSYNC = 04010000;
310pub const O_DIRECTORY = 0200000;
311pub const O_NOFOLLOW = 0400000;
312pub const O_CLOEXEC = 02000000;
313
314pub const O_ASYNC = 020000;
315pub const O_DIRECT = 040000;
316pub const O_LARGEFILE = 0100000;
317pub const O_NOATIME = 01000000;
318pub const O_PATH = 010000000;
319pub const O_TMPFILE = 020200000;
320pub const O_NDELAY = O_NONBLOCK;
321
322pub const F_DUPFD = 0;
323pub const F_GETFD = 1;
324pub const F_SETFD = 2;
325pub const F_GETFL = 3;
326pub const F_SETFL = 4;
327pub const F_GETLK = 5;
328pub const F_SETLK = 6;
329pub const F_SETLKW = 7;
330pub const F_SETOWN = 8;
331pub const F_GETOWN = 9;
332pub const F_SETSIG = 10;
333pub const F_GETSIG = 11;
334
335pub const F_SETOWN_EX = 15;
336pub const F_GETOWN_EX = 16;
337
338pub const F_GETOWNER_UIDS = 17;
339
340pub const blksize_t = i32;
341pub const nlink_t = u32;
342pub const time_t = isize;
343pub const mode_t = u32;
344pub const off_t = isize;
345pub const ino_t = usize;
346pub const dev_t = usize;
347pub const blkcnt_t = isize;
348pub const timespec = extern struct {
349 tv_sec: time_t,
350 tv_nsec: isize,
351};
352
353/// Renamed to Stat to not conflict with the stat function.
354/// atime, mtime, and ctime have functions to return `timespec`,
355/// because although this is a POSIX API, the layout and names of
356/// the structs are inconsistent across operating systems, and
357/// in C, macros are used to hide the differences. Here we use
358/// methods to accomplish this.
359pub const Stat = extern struct {
360 dev: dev_t,
361 ino: ino_t,
362 mode: mode_t,
363 nlink: nlink_t,
364 uid: uid_t,
365 gid: gid_t,
366 rdev: dev_t,
367 __pad: usize,
368 size: off_t,
369 blksize: blksize_t,
370 __pad2: i32,
371 blocks: blkcnt_t,
372 atim: timespec,
373 mtim: timespec,
374 ctim: timespec,
375 __unused: [2]u32,
376
377 pub fn atime(self: Stat) timespec {
378 return self.atim;
379 }
380
381 pub fn mtime(self: Stat) timespec {
382 return self.mtim;
383 }
384
385 pub fn ctime(self: Stat) timespec {
386 return self.ctim;
387 }
388};
std/special/start.zig+1-1
...@@ -76,7 +76,7 @@ nakedcc fn _start() noreturn {...@@ -76,7 +76,7 @@ nakedcc fn _start() noreturn {
76 );76 );
77 },77 },
78 .riscv64 => {78 .riscv64 => {
79 argc_ptr = asm ("mv %[argc], sp"79 starting_stack_ptr = asm ("mv %[argc], sp"
80 : [argc] "=r" (-> [*]usize)80 : [argc] "=r" (-> [*]usize)
81 );81 );
82 },82 },