|
1 | 1 | // riscv64-specific declarations that are intended to be imported into the POSIX namespace.
|
| 2 | +const std = @import("../../../std.zig"); |
| 3 | +const uid_t = std.os.linux.uid_t; |
| 4 | +const gid_t = std.os.linux.gid_t; |
2 | 5 |
|
3 | 6 | pub const SYS_io_setup = 0;
|
4 | 7 | pub const SYS_io_destroy = 1;
|
@@ -294,3 +297,92 @@ pub const SYS_fsmount = 432;
|
294 | 297 | pub const SYS_fspick = 433;
|
295 | 298 | pub const SYS_pidfd_open = 434;
|
296 | 299 | pub const SYS_clone3 = 435;
|
| 300 | + |
| 301 | +pub const O_CREAT = 0100; |
| 302 | +pub const O_EXCL = 0200; |
| 303 | +pub const O_NOCTTY = 0400; |
| 304 | +pub const O_TRUNC = 01000; |
| 305 | +pub const O_APPEND = 02000; |
| 306 | +pub const O_NONBLOCK = 04000; |
| 307 | +pub const O_DSYNC = 010000; |
| 308 | +pub const O_SYNC = 04010000; |
| 309 | +pub const O_RSYNC = 04010000; |
| 310 | +pub const O_DIRECTORY = 0200000; |
| 311 | +pub const O_NOFOLLOW = 0400000; |
| 312 | +pub const O_CLOEXEC = 02000000; |
| 313 | + |
| 314 | +pub const O_ASYNC = 020000; |
| 315 | +pub const O_DIRECT = 040000; |
| 316 | +pub const O_LARGEFILE = 0100000; |
| 317 | +pub const O_NOATIME = 01000000; |
| 318 | +pub const O_PATH = 010000000; |
| 319 | +pub const O_TMPFILE = 020200000; |
| 320 | +pub const O_NDELAY = O_NONBLOCK; |
| 321 | + |
| 322 | +pub const F_DUPFD = 0; |
| 323 | +pub const F_GETFD = 1; |
| 324 | +pub const F_SETFD = 2; |
| 325 | +pub const F_GETFL = 3; |
| 326 | +pub const F_SETFL = 4; |
| 327 | +pub const F_GETLK = 5; |
| 328 | +pub const F_SETLK = 6; |
| 329 | +pub const F_SETLKW = 7; |
| 330 | +pub const F_SETOWN = 8; |
| 331 | +pub const F_GETOWN = 9; |
| 332 | +pub const F_SETSIG = 10; |
| 333 | +pub const F_GETSIG = 11; |
| 334 | + |
| 335 | +pub const F_SETOWN_EX = 15; |
| 336 | +pub const F_GETOWN_EX = 16; |
| 337 | + |
| 338 | +pub const F_GETOWNER_UIDS = 17; |
| 339 | + |
| 340 | +pub const blksize_t = i32; |
| 341 | +pub const nlink_t = u32; |
| 342 | +pub const time_t = isize; |
| 343 | +pub const mode_t = u32; |
| 344 | +pub const off_t = isize; |
| 345 | +pub const ino_t = usize; |
| 346 | +pub const dev_t = usize; |
| 347 | +pub const blkcnt_t = isize; |
| 348 | +pub 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. |
| 359 | +pub 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 | +}; |
0 commit comments