authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 01:45:21 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 01:45:21 -07:00
logf79146abebfb35f1740cfaf119944b4d4aeb51fa
treec2592d2a2d50b01a32f8bc0a50d40a16e22d7a14
parentc5c1b35492224b0ed8d2570c8e71702947b1e400
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

fill out more things


1 files changed, 194 insertions(+), 0 deletions(-)

sys_darwin.zig+194
......@@ -269,6 +269,16 @@ pub const libc = struct {
269269 pub extern fn close(fildes: c_int) c_int;
270270 pub extern fn read(fd: c_int, buf: [*]u8, count: usize) isize;
271271 pub extern fn clock_gettime(clock_id: clockid_t, tp: *struct_timespec) c_int;
272 pub extern fn fcntl(fd: c_int, cmd: c_int, ...) c_int;
273 pub extern fn mkdirat(fd: c_int, path: [*:0]const u8, mode: mode_t) c_int;
274 pub extern fn fstatat(fd: c_int, noalias path: [*:0]const u8, noalias buf: *struct_stat, flag: c_int) c_int;
275 pub extern fn getdirentries(fd: c_int, buf: [*]u8, nbytes: c_int, basep: *c_long) c_int;
276 pub extern fn unlinkat(fd: c_int, name: [*:0]const u8, flag: c_int) c_int;
277 pub extern fn write(fd: c_int, buf: *const anyopaque, n: usize) isize;
278 pub extern fn writev(fd: c_int, iovec: [*]const struct_iovec, count: c_int) isize;
279 pub extern fn isatty(fd: c_int) c_int;
280 pub extern fn lseek(fd: c_int, offset: off_t, whence: c_int) off_t;
281 pub extern fn getcwd(buf: [*]u8, size: usize) ?[*:0]u8;
272282};
273283
274284pub const natural_t = c_uint;
......@@ -297,6 +307,10 @@ pub const time_t = c_ulong;
297307pub const struct_timespec = extern struct { sec: time_t, nsec: c_long };
298308pub const struct_stat = extern struct { dev: dev_t, mode: mode_t, nlink: nlink_t, ino: ino_t, uid: uid_t, gid: gid_t, rdev: dev_t, atimespec: struct_timespec, mtimespec: struct_timespec, ctimespec: struct_timespec, birthtimespec: struct_timespec, size: off_t, blocks: blkcnt_t, blksize: blksize_t, flags: u32, gen: u32, lspare: i32, qspare: [2]i64 };
299309pub const struct_iovec = extern struct { base: [*]u8, len: usize };
310pub const struct_dirent = extern struct { ino: u64, seekoff: u64, reclen: u16, namlen: u16, type: DT, name: [PATH_MAX]u8 };
311
312pub const PATH_MAX = 1024;
313pub const NAME_MAX = 255;
300314
301315pub const O = struct {
302316 pub const RDONLY = 0x0000;
......@@ -338,12 +352,147 @@ pub const CLOCK = struct {
338352 pub const THREAD_CPUTIME_ID = 16;
339353};
340354
355pub const AT = struct {
356 pub const FDCWD = -2;
357 pub const EACCESS = 0x0010;
358 pub const SYMLINK_NOFOLLOW = 0x0020;
359 pub const SYMLINK_FOLLOW = 0x0040;
360 pub const REMOVEDIR = 0x0080;
361 pub const REALDEV = 0x0200;
362 pub const FDONLY = 0x0400;
363 pub const SYMLINK_NOFOLLOW_ANY = 0x0800;
364 pub const RESOLVE_BENEATH = 0x2000;
365 pub const NODELETEBUSY = 0x4000;
366 pub const UNIQUE = 0x8000;
367};
368
369pub const F = struct {
370 pub const DUPFD = 0;
371 pub const GETFD = 1;
372 pub const SETFD = 2;
373 pub const GETFL = 3;
374 pub const SETFL = 4;
375 pub const GETOWN = 5;
376 pub const SETOWN = 6;
377 pub const GETLK = 7;
378 pub const SETLK = 8;
379 pub const SETLKW = 9;
380 pub const SETLKWTIMEOUT = 10;
381 pub const FLUSH_DATA = 40;
382 pub const CHKCLEAN = 41;
383 pub const PREALLOCATE = 42;
384 pub const SETSIZE = 43;
385 pub const RDADVISE = 44;
386 pub const RDAHEAD = 45;
387 pub const NOCACHE = 48;
388 pub const LOG2PHYS = 49;
389 pub const GETPATH = 50;
390 pub const FULLFSYNC = 51;
391 pub const PATHPKG_CHECK = 52;
392 pub const FREEZE_FS = 53;
393 pub const THAW_FS = 54;
394 pub const GLOBAL_NOCACHE = 55;
395 pub const ADDSIGS = 59;
396 pub const ADDFILESIGS = 61;
397 pub const NODIRECT = 62;
398 pub const GETPROTECTIONCLASS = 63;
399 pub const SETPROTECTIONCLASS = 64;
400 pub const LOG2PHYS_EXT = 65;
401 pub const GETLKPID = 66;
402 pub const SETBACKINGSTORE = 70;
403 pub const GETPATH_MTMINFO = 71;
404 pub const GETCODEDIR = 72;
405 pub const SETNOSIGPIPE = 73;
406 pub const GETNOSIGPIPE = 74;
407 pub const TRANSCODEKEY = 75;
408 pub const SINGLE_WRITER = 76;
409 pub const GETPROTECTIONLEVEL = 77;
410 pub const FINDSIGS = 78;
411 pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
412 pub const BARRIERFSYNC = 85;
413 pub const OFD_SETLK = 90;
414 pub const OFD_SETLKW = 91;
415 pub const OFD_GETLK = 92;
416 pub const OFD_SETLKWTIMEOUT = 93;
417 pub const ADDFILESIGS_RETURN = 97;
418 pub const CHECK_LV = 98;
419 pub const PUNCHHOLE = 99;
420 pub const TRIM_ACTIVE_FILE = 100;
421 pub const SPECULATIVE_READ = 101;
422 pub const GETPATH_NOFIRMLINK = 102;
423 pub const ADDFILESIGS_INFO = 103;
424 pub const ADDFILESUPPL = 104;
425 pub const GETSIGSINFO = 105;
426 pub const SETLEASE = 106;
427 pub const GETLEASE = 107;
428 pub const TRANSFEREXTENTS = 110;
429 pub const ATTRIBUTION_TAG = 111;
430 pub const NOCACHE_EXT = 112;
431 pub const ADDSIGS_MAIN_BINARY = 113;
432};
433
434pub const DT = enum(u8) {
435 UNKNOWN = 0,
436 FIFO = 1,
437 CHR = 2,
438 DIR = 4,
439 BLK = 6,
440 REG = 8,
441 LNK = 10,
442 SOCK = 12,
443 WHT = 14,
444};
445
446pub const S = struct {
447 pub const IFMT = 0o170000;
448 pub const IFIFO = 0o010000;
449 pub const IFCHR = 0o020000;
450 pub const IFDIR = 0o040000;
451 pub const IFBLK = 0o060000;
452 pub const IFREG = 0o100000;
453 pub const IFLNK = 0o120000;
454 pub const IFSOCK = 0o140000;
455 pub const IFWHT = 0o160000;
456 pub const IRWXU = 0o000700;
457 pub const IRUSR = 0o000400;
458 pub const IWUSR = 0o000200;
459 pub const IXUSR = 0o000100;
460 pub const IRWXG = 0o000070;
461 pub const IRGRP = 0o000040;
462 pub const IWGRP = 0o000020;
463 pub const IXGRP = 0o000010;
464 pub const IRWXO = 0o000007;
465 pub const IROTH = 0o000004;
466 pub const IWOTH = 0o000002;
467 pub const IXOTH = 0o000001;
468 pub const ISUID = 0o004000;
469 pub const ISGID = 0o002000;
470 pub const ISVTX = 0o001000;
471 pub const ISTXT = ISVTX;
472 pub const IREAD = IRUSR;
473 pub const IWRITE = IWUSR;
474 pub const IEXEC = IXUSR;
475};
476
477pub const SEEK = struct {
478 pub const SET = 0;
479 pub const CUR = 1;
480 pub const END = 2;
481 pub const HOLE = 3;
482 pub const DATA = 4;
483};
484
341485pub fn openat(fd: c_int, file: [*:0]const u8, oflag: c_int) errno.Error!c_int {
342486 const rc = libc.openat(fd, file, oflag);
343487 if (rc == -1) return errno.fromInt(errno.fromLibC());
344488 std.debug.assert(rc >= 0);
345489 return rc;
346490}
491pub fn openat4(fd: c_int, file: [*:0]const u8, oflag: c_int, mode: mode_t) errno.Error!c_int {
492 const rc = libc.openat(fd, file, oflag, mode);
493 if (rc == -1) return errno.fromInt(errno.fromLibC());
494 return rc;
495}
347496pub fn fstat(fd: c_int) errno.Error!struct_stat {
348497 var buf: struct_stat = undefined;
349498 const rc = libc.fstat(fd, &buf);
......@@ -369,3 +518,48 @@ pub fn clock_gettime(clock_id: clockid_t) !struct_timespec {
369518 std.debug.assert(rc == 0);
370519 return tp;
371520}
521pub fn mkdirat(fd: c_int, path: [*:0]const u8, mode: mode_t) errno.Error!void {
522 const rc = libc.mkdirat(fd, path, mode);
523 if (rc == -1) return errno.fromInt(errno.fromLibC());
524 std.debug.assert(rc == 0);
525}
526pub fn fstatat(fd: c_int, path: [*:0]const u8, flag: c_int) errno.Error!struct_stat {
527 var buf: struct_stat = undefined;
528 const rc = libc.fstatat(fd, path, &buf, flag);
529 if (rc == -1) return errno.fromInt(errno.fromLibC());
530 std.debug.assert(rc == 0);
531 return buf;
532}
533pub fn getdirentries(fd: c_int, buf: []u8, basep: *c_long) errno.Error!c_uint {
534 const rc = libc.getdirentries(fd, buf.ptr, @intCast(buf.len), basep);
535 if (rc == -1) return errno.fromInt(errno.fromLibC());
536 std.debug.assert(rc >= 0);
537 return @intCast(rc);
538}
539pub fn unlinkat(fd: c_int, name: [*:0]const u8, flag: c_int) !void {
540 const rc = libc.unlinkat(fd, name, flag);
541 if (rc == -1) return errno.fromInt(errno.fromLibC());
542 std.debug.assert(rc == 0);
543}
544pub fn write(fd: c_int, buf: []const u8) !usize {
545 const rc = libc.write(fd, buf.ptr, buf.len);
546 if (rc == -1) return errno.fromInt(errno.fromLibC());
547 std.debug.assert(rc >= 0);
548 return @intCast(rc);
549}
550pub fn writev(fd: c_int, iovec: []const struct_iovec) !usize {
551 const rc = libc.writev(fd, iovec.ptr, @intCast(iovec.len));
552 if (rc == -1) return errno.fromInt(errno.fromLibC());
553 std.debug.assert(rc >= 0);
554 return @intCast(rc);
555}
556pub fn lseek(fd: c_int, offset: off_t, whence: c_int) !void {
557 const rc = libc.lseek(fd, offset, whence);
558 if (rc == -1) return errno.fromInt(errno.fromLibC());
559 std.debug.assert(rc >= 0);
560}
561pub fn getcwd(buf: []u8) ![*:0]u8 {
562 const rc = libc.getcwd(buf.ptr, buf.len);
563 if (rc == null) return errno.fromInt(errno.fromLibC());
564 return rc.?;
565}