Browse Source

Adds several system calls and the beginning of odin wrappers for them

This also adds all systemcall numbers from the xnu kernel / and additional helpers for some of the calls to make it easier to call them from odin
Platin21 3 years ago
parent
commit
540c5400a0

+ 180 - 0
core/sys/darwin/xnu_system_call_helpers.odin

@@ -0,0 +1,180 @@
+package sys
+
+import "core:strings"
+import "core:c"
+import "core:os"
+import "core:fmt"
+
+// this package uses the sys prefix for the proc names to indicate that these aren't native syscalls but directly call such
+sys_write_string ::  proc (fd: c.int, message: string) -> bool {
+	return syscall_write(fd, strings.ptr_from_string(message), cast(u64)len(message))
+}
+
+Offset_From :: enum c.int {
+	SEEK_SET  = 0,  // the offset is set to offset bytes.
+	SEEK_CUR  = 1,  // the offset is set to its current location plus offset bytes.
+   	SEEK_END  = 2,  // the offset is set to the size of the file plus offset bytes.
+   	SEEK_HOLE = 3,  //  the offset is set to the start of the next hole greater than or equal to the supplied offset.
+ 	SEEK_DATA = 4,  //  the offset is set to the start of the next non-hole file region greater than or equal to the supplied offset.
+}
+
+Open_Flags_Enum :: enum u8 {
+	RDONLY, /* open for reading only */
+	WRONLY, /* open for writing only */
+	RDWR, /* open for reading and writing */
+
+	NONBLOCK, /* no delay */
+	APPEND, /* set append mode */
+	CREAT, /* create if nonexistant */
+	TRUNC, /* truncate to zero length */
+	EXCL, /* error if already exists */
+	SHLOCK, /* open with shared file lock */
+	EXLOCK, /* open with exclusive file lock */
+	DIRECTORY, /* restrict open to only directories */
+	NOFOLLOW, /* don't follow symlinks */
+	SYMLINK, /* allow open of a symlink */
+	EVTONLY, /* descriptor requested for event notifications only */
+	CLOEXEC, /* causes the descriptor to be closed if you use any of the exec like functions */
+	NOFOLLOW_ANY, /* no symlinks allowed in path */
+}
+Open_Flags :: bit_set[Open_Flags_Enum; u16]
+
+Permission_Enum :: enum u8 {
+	/* For owner */
+	PERMISSION_OWNER_READ, /* R for owner */
+	PERMISSION_OWNER_WRITE, /* W for owner */
+	PERMISSION_OWNER_EXECUTE, /* X for owner */
+	//IRWXU, /* RWX mask for owner */
+	
+	/* For group */
+	PERMISSION_GROUP_READ, /* R for group */
+	PERMISSION_GROUP_WRITE, /* W for group */
+	PERMISSION_GROUP_EXECUTE, /* X for group */
+	//IRWXG, /* RWX mask for group */
+	
+	/* For other */
+	PERMISSION_OTHER_READ, /* R for other */
+	PERMISSION_OTHER_WRITE, /* W for other */
+	PERMISSION_OTHER_EXECUTE, /* X for other */
+	//IRWXO, /* RWX mask for other */
+	
+	/* Special */
+	PERMISSION_SET_USER_ON_EXECUTION, /* set user id on execution */
+	PERMISSION_SET_GROUP_ON_EXECUTION, /* set group id on execution */
+
+	/* ?? */
+	PERMISSION_ISVTX, /* save swapped text even after use */
+}
+Permission :: bit_set[Permission_Enum; u16]
+
+PERMISSION_NONE_NONE :: Permission{}
+PERMISSION_OWNER_ALL :: Permission{.PERMISSION_OWNER_READ, .PERMISSION_OWNER_WRITE, .PERMISSION_OWNER_EXECUTE}
+PERMISSION_GROUP_ALL :: Permission{.PERMISSION_GROUP_READ, .PERMISSION_GROUP_WRITE, .PERMISSION_GROUP_EXECUTE}
+PERMISSION_OTHER_ALL :: Permission{.PERMISSION_OTHER_READ, .PERMISSION_OTHER_WRITE, .PERMISSION_OTHER_EXECUTE}
+PERMISSION_ALL_ALL   :: PERMISSION_OWNER_ALL | PERMISSION_GROUP_ALL | PERMISSION_OTHER_ALL
+
+_sys_permission_mode :: #force_inline proc (mode: Permission) -> u32 {
+	cflags: u32 = 0;
+
+	cflags |= PERMISSION_MASK_IRUSR * u32(Permission.PERMISSION_OWNER_READ in mode)
+	cflags |= PERMISSION_MASK_IWUSR * u32(Permission.PERMISSION_OWNER_WRITE in mode)
+	cflags |= PERMISSION_MASK_IXUSR * u32(Permission.PERMISSION_OWNER_WRITE in mode)
+	cflags |= PERMISSION_MASK_IRGRP * u32(Permission.PERMISSION_GROUP_READ in mode)
+	cflags |= PERMISSION_MASK_IWGRP * u32(Permission.PERMISSION_GROUP_WRITE in mode)
+	cflags |= PERMISSION_MASK_IXGRP * u32(Permission.PERMISSION_GROUP_WRITE in mode)
+	cflags |= PERMISSION_MASK_IROTH * u32(Permission.PERMISSION_OTHER_READ in mode)
+	cflags |= PERMISSION_MASK_IWOTH * u32(Permission.PERMISSION_OTHER_WRITE in mode)
+	cflags |= PERMISSION_MASK_IXOTH * u32(Permission.PERMISSION_OTHER_WRITE in mode)
+
+	return cflags
+}
+
+sys_open :: proc(path: string, oflag: Open_Flags, mode: Permission) -> (c.int, bool) {
+	
+	cmode: u32 = 0;
+	cflags: u32 = 0;
+	cpath: cstring = strings.clone_to_cstring(path);
+	defer delete(cpath)
+
+	cflags = _sys_permission_mode(mode)
+
+	cmode |= OPEN_FLAG_RDONLY       * u32(Open_Flags.RDONLY in oflag)
+	cmode |= OPEN_FLAG_WRONLY       * u32(Open_Flags.WRONLY in oflag)
+	cmode |= OPEN_FLAG_RDWR         * u32(Open_Flags.RDWR in oflag)
+	cmode |= OPEN_FLAG_NONBLOCK     * u32(Open_Flags.NONBLOCK in oflag)
+	cmode |= OPEN_FLAG_CREAT        * u32(Open_Flags.CREAT in oflag)
+	cmode |= OPEN_FLAG_APPEND       * u32(Open_Flags.APPEND in oflag)
+	cmode |= OPEN_FLAG_TRUNC        * u32(Open_Flags.TRUNC in oflag)
+	cmode |= OPEN_FLAG_EXCL         * u32(Open_Flags.EXCL in oflag)
+	cmode |= OPEN_FLAG_SHLOCK       * u32(Open_Flags.SHLOCK in oflag)
+	cmode |= OPEN_FLAG_EXLOCK       * u32(Open_Flags.EXLOCK in oflag)
+	cmode |= OPEN_FLAG_DIRECTORY    * u32(Open_Flags.DIRECTORY in oflag)
+	cmode |= OPEN_FLAG_NOFOLLOW     * u32(Open_Flags.NOFOLLOW in oflag)
+	cmode |= OPEN_FLAG_SYMLINK      * u32(Open_Flags.SYMLINK in oflag)
+	cmode |= OPEN_FLAG_EVTONLY      * u32(Open_Flags.EVTONLY in oflag)
+	cmode |= OPEN_FLAG_CLOEXEC      * u32(Open_Flags.CLOEXEC in oflag)
+	cmode |= OPEN_FLAG_NOFOLLOW_ANY * u32(Open_Flags.NOFOLLOW_ANY in oflag)
+	
+	result := syscall_open(cpath, cmode, cflags)
+	state  := result != -1
+
+	if state && cflags != 0 {
+		state = (syscall_fchmod(result, cflags) != -1)
+	}
+
+	return result * cast(c.int)state, state
+}
+
+sys_mkdir :: proc(path: string, mode: Permission) -> bool {
+	cpath: cstring = strings.clone_to_cstring(path)
+	defer delete(cpath)
+	cflags := _sys_permission_mode(mode)
+	return syscall_mkdir(cpath, cflags) != -1
+}
+
+sys_mkdir_at :: proc(fd: c.int, path: string, mode: Permission) -> bool {
+	cpath: cstring = strings.clone_to_cstring(path)
+	defer delete(cpath)
+	cflags := _sys_permission_mode(mode)
+	return syscall_mkdir_at(fd, cpath, cflags) != -1
+}
+
+sys_rmdir :: proc(path: string, mode: Permission) -> bool {
+	cpath: cstring = strings.clone_to_cstring(path)
+	defer delete(cpath)
+	cflags := _sys_permission_mode(mode)
+	return syscall_rmdir(cpath, cflags) != -1
+}
+
+sys_rename :: proc(path: string, new_path: string) -> bool {
+	cpath: cstring = strings.clone_to_cstring(path)
+	defer delete(cpath)
+	cnpath: cstring = strings.clone_to_cstring(new_path)
+	defer delete(cnpath)
+	return syscall_rename(cpath, cnpath) != -1
+}
+
+sys_rename_at :: proc(fd: c.int, path: string, to_fd: c.int, new_path: string) -> bool {
+	cpath: cstring = strings.clone_to_cstring(path)
+	defer delete(cpath)
+	cnpath: cstring = strings.clone_to_cstring(new_path)
+	defer delete(cnpath)
+	return syscall_rename_at(fd, cpath, to_fd, cnpath) != -1
+}
+
+sys_lseek :: proc(fd: c.int, offset: i64, whence: Offset_From) -> i64 {
+	return syscall_lseek(fd, offset, cast(c.int)whence)
+}
+
+sys_chmod :: proc(path: string, mode: Permission) -> bool {
+	cpath: cstring = strings.clone_to_cstring(path)
+	defer delete(cpath)
+	cmode := _sys_permission_mode(mode);
+	return syscall_chmod(cpath, cmode) != -1
+}
+
+sys_lstat :: proc(path: string, status: ^stat) -> bool {
+	cpath: cstring = strings.clone_to_cstring(path)
+	defer delete(cpath)
+	return syscall_lstat(cpath, status) != -1
+}

+ 558 - 0
core/sys/darwin/xnu_system_call_numbers.odin

@@ -0,0 +1,558 @@
+package sys
+
+unix_offset_syscall :: proc(number: System_Call_Number) -> uintptr {
+    return uintptr(number) + uintptr(0x2000000)
+}
+
+System_Call_Number :: enum uintptr {
+    /* 0 syscall */
+    exit = 1,
+    fork = 2,
+    read = 3,
+    write = 4,
+    open = 5,
+    close = 6,
+    wait4 = 7,
+    /* 8  old creat */
+    link = 9,
+    unlink = 10,
+    /* 11  old execv */
+    chdir = 12,
+    fchdir = 13,
+    mknod = 14,
+    chmod = 15,
+    chown = 16,
+    /* 17  old break */
+    getfsstat = 18,
+    /* 19  old lseek */
+    getpid = 20,
+    /* 21  old mount */
+    /* 22  old umount */
+    setuid = 23,
+    getuid = 24,
+    geteuid = 25,
+    ptrace = 26,
+    recvmsg = 27,
+    sendmsg = 28,
+    recvfrom = 29,
+    accept = 30,
+    getpeername = 31,
+    getsockname = 32,
+    access = 33,
+    chflags = 34,
+    fchflags = 35,
+    sync = 36,
+    kill = 37,
+    /* 38  old stat */
+    getppid = 39,
+    /* 40  old lstat */
+    dup = 41,
+    pipe = 42,
+    getegid = 43,
+    /* 44  old profil */
+    /* 45  old ktrace */
+    sigaction = 46,
+    getgid = 47,
+    sigprocmask = 48,
+    getlogin = 49,
+    setlogin = 50,
+    acct = 51,
+    sigpending = 52,
+    sigaltstack = 53,
+    ioctl = 54,
+    reboot = 55,
+    revoke = 56,
+    symlink = 57,
+    readlink = 58,
+    execve = 59,
+    umask = 60,
+    chroot = 61,
+    /* 62  old fstat */
+    /* 63  used internally and reserved */
+    /* getpagesize = 64, invalid */
+    msync = 65,
+    vfork = 66,
+    /* 67  old vread */
+    /* 68  old vwrite */
+    /* 69  old sbrk */
+    /* 70  old sstk */
+    /* 71  old mmap */
+    /* 72  old vadvise */
+    munmap = 73,
+    mprotect = 74,
+    madvise = 75,
+    /* 76  old vhangup */
+    /* 77  old vlimit */
+    mincore = 78,
+    getgroups = 79,
+    setgroups = 80,
+    getpgrp = 81,
+    setpgid = 82,
+    setitimer = 83,
+    /* 84  old wait */
+    swapon = 85,
+    getitimer = 86,
+    /* 87  old gethostname */
+    /* 88  old sethostname */
+    getdtablesize = 89,
+    dup2 = 90,
+    /* 91  old getdopt */
+    fcntl = 92,
+    select = 93,
+    /* 94  old setdopt */
+    fsync = 95,
+    setpriority = 96,
+    socket = 97,
+    connect = 98,
+    /* 99  old accept */
+    getpriority = 100,
+    /* 101  old send */
+    /* 102  old recv */
+    /* 103  old sigreturn */
+    bind = 104,
+    setsockopt = 105,
+    listen = 106,
+    /* 107  old vtimes */
+    /* 108  old sigvec */
+    /* 109  old sigblock */
+    /* 110  old sigsetmask */
+    sigsuspend = 111,
+    /* 112  old sigstack */
+    /* 113  old recvmsg */
+    /* 114  old sendmsg */
+    /* 115  old vtrace */
+    gettimeofday = 116,
+    getrusage = 117,
+    getsockopt = 118,
+    /* 119  old resuba */
+    readv = 120,
+    writev = 121,
+    settimeofday = 122,
+    fchown = 123,
+    fchmod = 124,
+    /* 125  old recvfrom */
+    setreuid = 126,
+    setregid = 127,
+    rename = 128,
+    /* 129  old truncate */
+    /* 130  old ftruncate */
+    flock = 131,
+    mkfifo = 132,
+    sendto = 133,
+    shutdown = 134,
+    socketpair = 135,
+    mkdir = 136,
+    rmdir = 137,
+    utimes = 138,
+    futimes = 139,
+    adjtime = 140,
+    /* 141  old getpeername */
+    gethostuuid = 142,
+    /* 143  old sethostid */
+    /* 144  old getrlimit */
+    /* 145  old setrlimit */
+    /* 146  old killpg */
+    setsid = 147,
+    /* 148  old setquota */
+    /* 149  old qquota */
+    /* 150  old getsockname */
+    getpgid = 151,
+    setprivexec = 152,
+    pread = 153,
+    pwrite = 154,
+    nfssvc = 155,
+    /* 156  old getdirentries */
+    statfs = 157,
+    fstatfs = 158,
+    unmount = 159,
+    /* 160  old async_daemon */
+    getfh = 161,
+    /* 162  old getdomainname */
+    /* 163  old setdomainname */
+    /* 164  */
+    quotactl = 165,
+    /* 166  old exportfs */
+    mount = 167,
+    /* 168  old ustat */
+    csops = 169,
+    csops_audittoken = 170,
+    /* 171  old wait3 */
+    /* 172  old rpause */
+    waitid = 173,
+    /* 174  old getdents */
+    /* 175  old gc_control */
+    /* 176  old add_profil */
+    kdebug_typefilter = 177,
+    kdebug_trace_string = 178,
+    kdebug_trace64 = 179,
+    kdebug_trace = 180,
+    setgid = 181,
+    setegid = 182,
+    seteuid = 183,
+    sigreturn = 184,
+    /* 185  old chud */
+    thread_selfcounts = 186,
+    fdatasync = 187,
+    stat = 188,
+    fstat = 189,
+    lstat = 190,
+    pathconf = 191,
+    fpathconf = 192,
+    /* 193  old getfsstat */
+    getrlimit = 194,
+    setrlimit = 195,
+    getdirentries = 196,
+    mmap = 197,
+    /* 198  old __syscall */
+    lseek = 199,
+    truncate = 200,
+    ftruncate = 201,
+    sysctl = 202,
+    mlock = 203,
+    munlock = 204,
+    undelete = 205,
+    /* 206  old ATsocket */
+    /* 207  old ATgetmsg */
+    /* 208  old ATputmsg */
+    /* 209  old ATsndreq */
+    /* 210  old ATsndrsp */
+    /* 211  old ATgetreq */
+    /* 212  old ATgetrsp */
+    /* 213  Reserved for AppleTalk */
+    /* 214  */
+    /* 215  */
+    open_dprotected_np = 216,
+    fsgetpath_ext = 217,
+    /* 218  old lstatv */
+    /* 219  old fstatv */
+    getattrlist = 220,
+    setattrlist = 221,
+    getdirentriesattr = 222,
+    exchangedata = 223,
+    /* 224  old checkuseraccess or fsgetpath */
+    searchfs = 225,
+    delete = 226,
+    copyfile = 227,
+    fgetattrlist = 228,
+    fsetattrlist = 229,
+    poll = 230,
+    /* 231  old watchevent */
+    /* 232  old waitevent */
+    /* 233  old modwatch */
+    getxattr = 234,
+    fgetxattr = 235,
+    setxattr = 236,
+    fsetxattr = 237,
+    removexattr = 238,
+    fremovexattr = 239,
+    listxattr = 240,
+    flistxattr = 241,
+    fsctl = 242,
+    initgroups = 243,
+    posix_spawn = 244,
+    ffsctl = 245,
+    /* 246  */
+    nfsclnt = 247,
+    fhopen = 248,
+    /* 249  */
+    minherit = 250,
+    semsys = 251,
+    msgsys = 252,
+    shmsys = 253,
+    semctl = 254,
+    semget = 255,
+    semop = 256,
+    /* 257  old semconfig */
+    msgctl = 258,
+    msgget = 259,
+    msgsnd = 260,
+    msgrcv = 261,
+    shmat = 262,
+    shmctl = 263,
+    shmdt = 264,
+    shmget = 265,
+    shm_open = 266,
+    shm_unlink = 267,
+    sem_open = 268,
+    sem_close = 269,
+    sem_unlink = 270,
+    sem_wait = 271,
+    sem_trywait = 272,
+    sem_post = 273,
+    sysctlbyname = 274,
+    /* 275  old sem_init */
+    /* 276  old sem_destroy */
+    open_extended = 277,
+    umask_extended = 278,
+    stat_extended = 279,
+    lstat_extended = 280,
+    fstat_extended = 281,
+    chmod_extended = 282,
+    fchmod_extended = 283,
+    access_extended = 284,
+    settid = 285,
+    gettid = 286,
+    setsgroups = 287,
+    getsgroups = 288,
+    setwgroups = 289,
+    getwgroups = 290,
+    mkfifo_extended = 291,
+    mkdir_extended = 292,
+    identitysvc = 293,
+    shared_region_check_np = 294,
+    /* 295  old shared_region_map_np */
+    vm_pressure_monitor = 296,
+    psynch_rw_longrdlock = 297,
+    psynch_rw_yieldwrlock = 298,
+    psynch_rw_downgrade = 299,
+    psynch_rw_upgrade = 300,
+    psynch_mutexwait = 301,
+    psynch_mutexdrop = 302,
+    psynch_cvbroad = 303,
+    psynch_cvsignal = 304,
+    psynch_cvwait = 305,
+    psynch_rw_rdlock = 306,
+    psynch_rw_wrlock = 307,
+    psynch_rw_unlock = 308,
+    psynch_rw_unlock2 = 309,
+    getsid = 310,
+    settid_with_pid = 311,
+    psynch_cvclrprepost = 312,
+    aio_fsync = 313,
+    aio_return = 314,
+    aio_suspend = 315,
+    aio_cancel = 316,
+    aio_error = 317,
+    aio_read = 318,
+    aio_write = 319,
+    lio_listio = 320,
+    /* 321  old __pthread_cond_wait */
+    iopolicysys = 322,
+    process_policy = 323,
+    mlockall = 324,
+    munlockall = 325,
+    /* 326  */
+    issetugid = 327,
+    __pthread_kill = 328,
+    __pthread_sigmask = 329,
+    __sigwait = 330,
+    __disable_threadsignal = 331,
+    __pthread_markcancel = 332,
+    __pthread_canceled = 333,
+    __semwait_signal = 334,
+    /* 335  old utrace */
+    proc_info = 336,
+    sendfile = 337,
+    stat64 = 338,
+    fstat64 = 339,
+    lstat64 = 340,
+    stat64_extended = 341,
+    lstat64_extended = 342,
+    fstat64_extended = 343,
+    getdirentries64 = 344,
+    statfs64 = 345,
+    fstatfs64 = 346,
+    getfsstat64 = 347,
+    __pthread_chdir = 348,
+    __pthread_fchdir = 349,
+    audit = 350,
+    auditon = 351,
+    /* 352  */
+    getauid = 353,
+    setauid = 354,
+    /* 355  old getaudit */
+    /* 356  old setaudit */
+    getaudit_addr = 357,
+    setaudit_addr = 358,
+    auditctl = 359,
+    bsdthread_create = 360,
+    bsdthread_terminate = 361,
+    kqueue = 362,
+    kevent = 363,
+    lchown = 364,
+    /* 365  old stack_snapshot */
+    bsdthread_register = 366,
+    workq_open = 367,
+    workq_kernreturn = 368,
+    kevent64 = 369,
+    __old_semwait_signal = 370,
+    __old_semwait_signal_nocancel = 371,
+    thread_selfid = 372,
+    ledger = 373,
+    kevent_qos = 374,
+    kevent_id = 375,
+    /* 376  */
+    /* 377  */
+    /* 378  */
+    /* 379  */
+    __mac_execve = 380,
+    __mac_syscall = 381,
+    __mac_get_file = 382,
+    __mac_set_file = 383,
+    __mac_get_link = 384,
+    __mac_set_link = 385,
+    __mac_get_proc = 386,
+    __mac_set_proc = 387,
+    __mac_get_fd = 388,
+    __mac_set_fd = 389,
+    __mac_get_pid = 390,
+    /* 391  */
+    /* 392  */
+    /* 393  */
+    pselect = 394,
+    pselect_nocancel = 395,
+    read_nocancel = 396,
+    write_nocancel = 397,
+    open_nocancel = 398,
+    close_nocancel = 399,
+    wait4_nocancel = 400,
+    recvmsg_nocancel = 401,
+    sendmsg_nocancel = 402,
+    recvfrom_nocancel = 403,
+    accept_nocancel = 404,
+    msync_nocancel = 405,
+    fcntl_nocancel = 406,
+    select_nocancel = 407,
+    fsync_nocancel = 408,
+    connect_nocancel = 409,
+    sigsuspend_nocancel = 410,
+    readv_nocancel = 411,
+    writev_nocancel = 412,
+    sendto_nocancel = 413,
+    pread_nocancel = 414,
+    pwrite_nocancel = 415,
+    waitid_nocancel = 416,
+    poll_nocancel = 417,
+    msgsnd_nocancel = 418,
+    msgrcv_nocancel = 419,
+    sem_wait_nocancel = 420,
+    aio_suspend_nocancel = 421,
+    __sigwait_nocancel = 422,
+    __semwait_signal_nocancel = 423,
+    __mac_mount = 424,
+    __mac_get_mount = 425,
+    __mac_getfsstat = 426,
+    fsgetpath = 427,
+    audit_session_self = 428,
+    audit_session_join = 429,
+    fileport_makeport = 430,
+    fileport_makefd = 431,
+    audit_session_port = 432,
+    pid_suspend = 433,
+    pid_resume = 434,
+    pid_hibernate = 435,
+    pid_shutdown_sockets = 436,
+    /* 437  old shared_region_slide_np */
+    shared_region_map_and_slide_np = 438,
+    kas_info = 439,
+    memorystatus_control = 440,
+    guarded_open_np = 441,
+    guarded_close_np = 442,
+    guarded_kqueue_np = 443,
+    change_fdguard_np = 444,
+    usrctl = 445,
+    proc_rlimit_control = 446,
+    connectx = 447,
+    disconnectx = 448,
+    peeloff = 449,
+    socket_delegate = 450,
+    telemetry = 451,
+    proc_uuid_policy = 452,
+    memorystatus_get_level = 453,
+    system_override = 454,
+    vfs_purge = 455,
+    sfi_ctl = 456,
+    sfi_pidctl = 457,
+    coalition = 458,
+    coalition_info = 459,
+    necp_match_policy = 460,
+    getattrlistbulk = 461,
+    clonefileat = 462,
+    openat = 463,
+    openat_nocancel = 464,
+    renameat = 465,
+    faccessat = 466,
+    fchmodat = 467,
+    fchownat = 468,
+    fstatat = 469,
+    fstatat64 = 470,
+    linkat = 471,
+    unlinkat = 472,
+    readlinkat = 473,
+    symlinkat = 474,
+    mkdirat = 475,
+    getattrlistat = 476,
+    proc_trace_log = 477,
+    bsdthread_ctl = 478,
+    openbyid_np = 479,
+    recvmsg_x = 480,
+    sendmsg_x = 481,
+    thread_selfusage = 482,
+    csrctl = 483,
+    guarded_open_dprotected_np = 484,
+    guarded_write_np = 485,
+    guarded_pwrite_np = 486,
+    guarded_writev_np = 487,
+    renameatx_np = 488,
+    mremap_encrypted = 489,
+    netagent_trigger = 490,
+    stack_snapshot_with_config = 491,
+    microstackshot = 492,
+    grab_pgo_data = 493,
+    persona = 494,
+    /* 495  */
+    mach_eventlink_signal = 496,
+    mach_eventlink_wait_until = 497,
+    mach_eventlink_signal_wait_until = 498,
+    work_interval_ctl = 499,
+    getentropy = 500,
+    necp_open = 501,
+    necp_client_action = 502,
+    nexus_open = 503,       // for those who are intressted http://newosxbook.com/bonus/vol1ch16.html
+    nexus_register = 504,  
+    nexus_deregister = 505,
+    nexus_create = 506,
+    nexus_destroy = 507,
+    nexus_get_opt = 508,
+    nexus_set_opt = 509,
+    channel_open = 510,
+    channel_get_info = 511,
+    channel_sync = 512,
+    channel_get_opt = 513,
+    channel_set_opt = 514,
+    ulock_wait = 515,
+    ulock_wake = 516,
+    fclonefileat = 517,
+    fs_snapshot = 518,
+    register_uexc_handler = 519,
+    terminate_with_payload = 520,
+    abort_with_payload = 521,
+    necp_session_open = 522,
+    necp_session_action = 523,
+    setattrlistat = 524,
+    net_qos_guideline = 525,
+    fmount = 526,
+    ntp_adjtime = 527,
+    ntp_gettime = 528,
+    os_fault_with_payload = 529,
+    kqueue_workloop_ctl = 530,
+    mach_bridge_remote_time = 531, 
+    coalition_ledger = 532,
+    log_data = 533,
+    memorystatus_available_memory = 534,
+    objc_bp_assist_cfg_np = 535,
+    shared_region_map_and_slide_2_np = 536,
+    pivot_root = 537,
+    task_inspect_for_pid = 538,
+    task_read_for_pid = 539,
+    preadv = 540,
+    pwritev = 541,
+    preadv_nocancel = 542,
+    pwritev_nocancel = 543,
+    ulock_wait2 = 544,
+    proc_info_extended_id = 545,
+    tracker_action = 546,
+    debug_syscall_reject = 547,
+    MAXSYSCALL = 548,
+    /* invalid = 63, */
+}

+ 419 - 0
core/sys/darwin/xnu_system_call_wrappers.odin

@@ -0,0 +1,419 @@
+package sys
+
+import "core:c"
+import "core:intrinsics"
+
+/* flock */
+LOCK_SH :: 1 /* shared lock */
+LOCK_EX :: 2 /* exclusive lock */
+LOCK_NB :: 4 /* don't block when locking */
+LOCK_UN :: 8 /* unlock */
+
+/* sys/unistd.h for access */
+F_OK  :: c.int(0);         /* test for existence of file */
+X_OK  :: c.int((1 << 0));  /* test for execute or search permission */
+W_OK  :: c.int((1 << 1));  /* test for write permission */
+R_OK  :: c.int((1 << 2));  /* test for read permission */
+
+/* copyfile flags */
+COPYFILE_ACL   :: (1 << 0)
+COPYFILE_STAT  :: (1 << 1)
+COPYFILE_XATTR :: (1 << 2)
+COPYFILE_DATA  :: (1 << 3)
+
+COPYFILE_SECURITY :: (COPYFILE_STAT | COPYFILE_ACL)
+COPYFILE_METADATA :: (COPYFILE_SECURITY | COPYFILE_XATTR)
+COPYFILE_ALL	  :: (COPYFILE_METADATA | COPYFILE_DATA)
+
+/* syslimits.h */
+PATH_MAX	:: 1024;	/* max bytes in pathname */
+
+/* param.h */
+MAXPATHLEN :: PATH_MAX;
+
+/* proc_info.h */
+DARWIN_PROC_PIDPATHINFO_SIZE :: MAXPATHLEN;
+DARWIN_PROC_PIDPATHINFO :: 11;
+
+DARWIN_PROC_ALL_PIDS  :: c.int(1);
+DARWIN_PROC_PGRP_ONLY :: c.int(2);
+DARWIN_PROC_TTY_ONLY  :: c.int(3);
+DARWIN_PROC_UID_ONLY  :: c.int(4);
+DARWIN_PROC_RUID_ONLY :: c.int(5);
+DARWIN_PROC_PPID_ONLY :: c.int(6);
+DARWIN_PROC_KDBG_ONLY :: c.int(7);
+
+DARWIN_PROC_INFO_CALL_LISTPIDS          :: c.int(0x1);
+DARWIN_PROC_INFO_CALL_PIDINFO           :: c.int(0x2);
+DARWIN_PROC_INFO_CALL_PIDFDINFO         :: c.int(0x3);
+DARWIN_PROC_INFO_CALL_KERNMSGBUF        :: c.int(0x4);
+DARWIN_PROC_INFO_CALL_SETCONTROL        :: c.int(0x5);
+DARWIN_PROC_INFO_CALL_PIDFILEPORTINFO   :: c.int(0x6);
+DARWIN_PROC_INFO_CALL_TERMINATE         :: c.int(0x7);
+DARWIN_PROC_INFO_CALL_DIRTYCONTROL      :: c.int(0x8);
+DARWIN_PROC_INFO_CALL_PIDRUSAGE         :: c.int(0x9);
+DARWIN_PROC_INFO_CALL_PIDORIGINATORINFO :: c.int(0xa);
+DARWIN_PROC_INFO_CALL_LISTCOALITIONS    :: c.int(0xb);
+DARWIN_PROC_INFO_CALL_CANUSEFGHW        :: c.int(0xc);
+DARWIN_PROC_INFO_CALL_PIDDYNKQUEUEINFO  :: c.int(0xd);
+DARWIN_PROC_INFO_CALL_UDATA_INFO        :: c.int(0xe);
+
+/* mmap flags */
+MAP_ANONYMOUS    :: 0x1000 /* allocated from memory, swap space */
+MAP_FILE         :: 0x0000 /* map from file (default) */
+MAP_FIXED        :: 0x0010 /* [MF|SHM] interpret addr exactly */
+MAP_HASSEMAPHORE :: 0x0200 /* region may contain semaphores */
+MAP_PRIVATE      :: 0x0002 /* [MF|SHM] changes are private */
+MAP_SHARED       :: 0x0001 /* [MF|SHM] share changes */
+MAP_NOCACHE      :: 0x0400 /* don't cache pages for this mapping */
+MAP_JIT          :: 0x0800 /* Allocate a region that will be used for JIT purposes */
+MAP_32BIT        :: 0x8000 /* Return virtual addresses <4G only */
+
+/* mmap prot flags */
+PROT_NONE  :: 0x00 /* [MC2] no permissions */
+PROT_READ  :: 0x01 /* [MC2] pages can be read */
+PROT_WRITE :: 0x02 /* [MC2] pages can be written */
+PROT_EXEC  :: 0x04 /* [MC2] pages can be executed */
+
+/* For owner Mode/Permission Flags for Open etc. */
+PERMISSION_MASK_IRWXU :: 0o000700 /* RWX mask for owner */
+PERMISSION_MASK_IRUSR :: 0o000400 /* R for owner */
+PERMISSION_MASK_IWUSR :: 0o000200 /* W for owner */
+PERMISSION_MASK_IXUSR :: 0o000100 /* X for owner */
+
+/* For group Mode/Permission Flags for Open etc. */
+PERMISSION_MASK_IRWXG :: 0o000070 /* RWX mask for group */
+PERMISSION_MASK_IRGRP :: 0o000040 /* R for group */
+PERMISSION_MASK_IWGRP :: 0o000020 /* W for group */
+PERMISSION_MASK_IXGRP :: 0o000010 /* X for group */
+
+/* For other Mode/Permission Flags for Open etc. */
+PERMISSION_MASK_IRWXO :: 0o000007 /* RWX mask for other */
+PERMISSION_MASK_IROTH :: 0o000004 /* R for other */
+PERMISSION_MASK_IWOTH :: 0o000002 /* W for other */
+PERMISSION_MASK_IXOTH :: 0o000001 /* X for other */
+
+/* Special Mode/Permission Flags for Open etc. */
+PERMISSION_MASK_ISUID :: 0o004000 /* set user id on execution */
+PERMISSION_MASK_ISGID :: 0o002000 /* set group id on execution */
+PERMISSION_MASK_ISVTX :: 0o001000 /* save swapped text even after use */
+
+OPEN_FLAG_RDONLY :: 0x0000 /* open for reading only */
+OPEN_FLAG_WRONLY :: 0x0001 /* open for writing only */
+OPEN_FLAG_RDWR   :: 0x0002 /* open for reading and writing */
+
+/* mask for above rd/wr/rdwr flags */
+MASK_ACCMODE      :: 0x0003 
+
+OPEN_FLAG_NONBLOCK     :: 0x00000004 /* no delay */
+OPEN_FLAG_APPEND       :: 0x00000008 /* set append mode */
+OPEN_FLAG_CREAT        :: 0x00000200 /* create if nonexistant */
+OPEN_FLAG_TRUNC        :: 0x00000400 /* truncate to zero length */
+OPEN_FLAG_EXCL         :: 0x00000800 /* error if already exists */
+OPEN_FLAG_SHLOCK       :: 0x00000010 /* open with shared file lock */
+OPEN_FLAG_EXLOCK       :: 0x00000020 /* open with exclusive file lock */
+OPEN_FLAG_DIRECTORY    :: 0x00100000 /* restrict open to only directories */
+OPEN_FLAG_NOFOLLOW     :: 0x00000100 /* don't follow symlinks */
+OPEN_FLAG_SYMLINK      :: 0x00200000 /* allow open of a symlink */
+OPEN_FLAG_EVTONLY      :: 0x00008000 /* descriptor requested for event notifications only */
+OPEN_FLAG_CLOEXEC      :: 0x01000000 /* causes the descriptor to be closed if you use any of the exec like functions */
+OPEN_FLAG_NOFOLLOW_ANY :: 0x20000000 /* no symlinks allowed in path */
+
+/* bsd/sys/param.h */
+DARWIN_MAXCOMLEN :: 16;
+
+/*--==========================================================================--*/
+
+__darwin_ino64_t :: u64
+__darwin_time_t :: u32
+__darwin_dev_t :: i32
+__darwin_mode_t :: u16
+__darwin_off_t :: i64
+__darwin_blkcnt_t :: i64
+__darwin_blksize_t :: i32
+__darwin_pid_t :: i32
+__darwin_suseconds_t :: i32
+
+time_t :: __darwin_time_t
+dev_t :: __darwin_dev_t
+mode_t :: u16
+nlink_t :: u16  
+uid_t :: u16
+gid_t :: u16
+off_t :: __darwin_off_t
+blkcnt_t :: __darwin_blkcnt_t
+blksize_t :: __darwin_blksize_t
+pid_t :: __darwin_pid_t
+
+stat :: __DARWIN_STRUCT_STAT64 
+timeval :: _STRUCT_TIMEVAL
+
+/*--==========================================================================--*/
+
+/* sys/stat.h */
+__DARWIN_STRUCT_STAT64 :: struct {
+	st_dev: dev_t,            /* [XSI] ID of device containing file */
+	st_mode: mode_t,          /* [XSI] Mode of file (see below) */
+	st_nlink: nlink_t,        /* [XSI] Number of hard links */
+	st_ino: __darwin_ino64_t, /* [XSI] File serial number */
+	st_uid_t: uid_t,          /* [XSI] User ID of the file */
+	st_gid_t: gid_t,          /* [XSI] Group ID of the file */
+	st_rdev: dev_t,           /* [XSI] Device ID */
+
+	// __DARWIN_STRUCT_STAT64_TIMES 
+	st_atime: time_t,      /* [XSI] Time of last access */ 
+	st_atimensec: i32,     /* nsec of last access */ 
+	st_mtime: time_t,      /* [XSI] Last data modification time */
+	st_mtimensec: i32,     /* last data modification nsec */ 
+	st_ctime: time_t,      /* [XSI] Time of last status change */ 
+	st_ctimensec: u32,     /* nsec of last status change */ 
+	st_birthtime: time_t,  /*  File creation time(birth)  */
+	st_birthtimensec: i32, /* nsec of File creation time */
+	// end __DARWIN_STRUCT_STAT64_TIMES
+
+	st_size: off_t,        /* [XSI] file size, in bytes */
+	st_blocks: blkcnt_t,   /* [XSI] blocks allocated for file */
+	st_blksize: blksize_t, /* [XSI] optimal blocksize for I/O */
+	st_flags: u32,         /* user defined flags for file */
+	st_gen: u32,           /* file generation number */
+	st_lspare: i32,        /* RESERVED: DO NOT USE! */
+	st_qspare: [2]i64,     /* RESERVED: DO NOT USE! */
+}
+
+/* sys/_types/_timeval.h */
+_STRUCT_TIMEVAL :: struct {
+	tv_sec: __darwin_time_t, /* seconds */
+	tv_usec: __darwin_suseconds_t, /* microseconds */
+};
+
+/* pwd.h */
+_Password_Entry :: struct {
+    pw_name: cstring, /* username */
+    pw_passwd: cstring, /* user password */
+    pw_uid: i32,   /* user ID */
+    pw_gid: i32,   /* group ID */
+	pw_change: u64,     /* password change time */
+	pw_class: cstring, /* user access class */
+    pw_gecos: cstring, /* full user name */
+    pw_dir: cstring, /* home directory */
+    pw_shell: cstring, /* shell program */
+	pw_expire: u64,     /* account expiration */
+	pw_fields: i32,     /* filled fields */
+};
+
+/* processinfo.h */
+_Proc_Bsdinfo :: struct {
+  pbi_flags: u32, /* if is 64bit; emulated etc */
+  pbi_status: u32,
+  pbi_xstatus: u32,
+  pbi_pid: u32,
+  pbi_ppid: u32,
+  pbi_uid: u32,
+  pbi_gid: u32,
+  pbi_ruid: u32,
+  pbi_rgid: u32,
+  pbi_svuid: u32,
+  pbi_svgid: u32,
+  res: u32,
+  pbi_comm: [DARWIN_MAXCOMLEN]u8,
+  pbi_name: [2 * DARWIN_MAXCOMLEN]u8,	/* empty if no name is registered */
+  pbi_nfiles: u32,
+  pbi_pgid: u32,
+  pbi_pjobc: u32,
+  e_tdev: u32, /* controlling tty dev */
+  e_tpgid: u32,	/* tty process group id */
+  pbi_nice: i32,
+  pbi_start_tvsec: u64,
+  pbi_start_tvusec: u64,
+};
+
+/*--==========================================================================--*/
+
+syscall_fsync :: #force_inline proc(fildes: c.int) -> bool {
+	return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.fsync), uintptr(fildes)))
+}
+
+syscall_write :: #force_inline proc (fildes: c.int, buf: ^byte, nbyte: u64) -> bool {
+	return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.write),  uintptr(fildes), uintptr(buf), uintptr(nbyte)))
+}
+ 
+syscall_read :: #force_inline proc(fildes: c.int, buf: ^byte, nbyte: u64) -> i64 {
+	return cast(i64)intrinsics.syscall(unix_offset_syscall(.read), uintptr(fildes), uintptr(buf), uintptr(nbyte))
+}
+
+syscall_open :: #force_inline proc(path: cstring, oflag: u32, mode: u32) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.open), transmute(uintptr)path, uintptr(oflag), uintptr(mode))
+}
+
+syscall_close :: #force_inline proc(fd: c.int) -> bool {
+	return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.close), uintptr(fd)))
+}
+
+syscall_fchmod :: #force_inline proc(fildes: c.int, mode: u32) -> c.int {
+	return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.fchmod), uintptr(fildes), uintptr(mode)))
+}
+
+syscall_chmod :: #force_inline proc(path: cstring, mode: u32) -> c.int {
+	return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.chmod), transmute(uintptr)path, uintptr(mode)))
+}
+
+syscall_mkdir :: #force_inline proc(path: cstring, mode: u32) -> c.int {
+	return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.mkdir), transmute(uintptr)path, uintptr(mode)))
+}
+
+syscall_mkdir_at :: #force_inline proc(fd: c.int, path: cstring, mode: u32) -> c.int {
+	return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.mkdir), uintptr(fd), transmute(uintptr)path, uintptr(mode)))
+}
+
+syscall_rmdir :: #force_inline proc(path: cstring, mode: u32) -> c.int {
+	return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.rmdir), transmute(uintptr)path, uintptr(mode)))
+}
+
+syscall_rename :: #force_inline proc(path_old: cstring, path_new: cstring) -> c.int {
+	return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.rename), transmute(uintptr)path_old, transmute(uintptr)path_new))
+}
+
+syscall_rename_at :: #force_inline proc(from_fd: c.int, from: cstring, to_fd: c.int, to: cstring) -> c.int {
+	return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.renameat), uintptr(from_fd), transmute(uintptr)from, uintptr(to_fd), transmute(uintptr)to))
+}
+
+syscall_lseek :: #force_inline proc(fd: c.int, offset: i64, whence: c.int) -> i64 {
+	return cast(i64)intrinsics.syscall(unix_offset_syscall(.lseek), uintptr(fd), uintptr(offset), uintptr(whence))
+}
+
+syscall_gettid :: #force_inline proc() -> u64 {
+	return cast(u64)intrinsics.syscall(unix_offset_syscall(.gettid))
+}
+
+syscall_fstat :: #force_inline proc(fd: c.int, status: ^stat) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fstat), uintptr(fd), uintptr(status))
+}
+
+syscall_lstat :: #force_inline proc(path: cstring, status: ^stat) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.lstat), transmute(uintptr)path, uintptr(status))
+}
+
+syscall_stat :: #force_inline proc(path: cstring, status: ^stat) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.stat), transmute(uintptr)path, uintptr(status))
+}
+
+syscall_fstatat :: #force_inline proc(fd: c.int, path: cstring, status: ^stat) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fstatat), uintptr(fd), transmute(uintptr)path, uintptr(status))
+}
+
+syscall_link :: #force_inline proc(path: cstring, to_link: cstring) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.link), transmute(uintptr)path, transmute(uintptr)to_link)
+}
+
+syscall_linkat :: #force_inline proc(fd: c.int, path: cstring, fd2: c.int, to_link: cstring) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.linkat), uintptr(fd), transmute(uintptr)path, uintptr(fd2), transmute(uintptr)to_link)
+}
+
+syscall_readlink :: #force_inline proc(path: cstring, buf: ^u8, buf_size: u64) -> i64 {
+	return cast(i64)intrinsics.syscall(unix_offset_syscall(.readlink), transmute(uintptr)path, uintptr(buf), uintptr(buf_size))
+}
+
+syscall_readlinkat :: #force_inline proc(fd: c.int, path: cstring, buf: ^u8, buf_size: u64) -> i64 {
+	return cast(i64)intrinsics.syscall(unix_offset_syscall(.readlinkat), uintptr(fd), transmute(uintptr)path, uintptr(buf), uintptr(buf_size))
+}
+
+syscall_access :: #force_inline proc(path: cstring, mode: c.int) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.access), transmute(uintptr)path, uintptr(mode))
+}
+
+syscall_faccessat :: #force_inline proc(fd: c.int, path: cstring, mode: c.int, flag: c.int) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.faccessat), uintptr(fd), transmute(uintptr)path, uintptr(mode), uintptr(flag))
+}
+
+syscall_getdirentries :: #force_inline proc(fd: c.int, buf: ^u8, nbytes: c.int, base_pointer: ^u32) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getdirentries), uintptr(fd), uintptr(buf), uintptr(nbytes), uintptr(base_pointer))
+}
+
+syscall_truncate :: #force_inline proc (path: cstring, length: off_t) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.truncate), transmute(uintptr)path, uintptr(length))
+}
+
+syscall_ftruncate :: #force_inline proc (fd: c.int, length: off_t) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.ftruncate), uintptr(fd), uintptr(length))
+}
+
+syscall_sysctl :: #force_inline proc (name: ^c.int, namelen: c.uint, oldp: rawptr, oldlenp: ^i64, newp: ^i8, newlen: i64) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.sysctl), uintptr(name), uintptr(namelen), uintptr(oldp), uintptr(oldlenp), uintptr(newp), uintptr(newlen))
+}
+
+syscall_copyfile ::  #force_inline proc(from: cstring, to: cstring, state: rawptr, flags: u32) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.copyfile), transmute(uintptr)from, transmute(uintptr)to, uintptr(state), uintptr(flags))
+} 
+
+// think about this? last arg should be more than one
+syscall_fcntl :: #force_inline proc(fd: c.int, cmd: c.int, other: rawptr) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fsctl), uintptr(fd), uintptr(cmd), uintptr(other))
+}
+
+syscall_exit :: #force_inline proc(code: c.int) {
+	intrinsics.syscall(unix_offset_syscall(.exit), uintptr(code))
+}
+
+syscall_kill :: #force_inline proc(pid: pid_t, sig: c.int) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.kill), uintptr(pid), uintptr(sig))
+}
+
+syscall_dup :: #force_inline proc(fd: c.int) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.dup), uintptr(fd))
+}
+
+syscall_execve :: #force_inline proc(path: cstring, argv: [^]cstring, env: [^]cstring) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.execve), transmute(uintptr)path, transmute(uintptr)argv, transmute(uintptr)env)
+}
+
+syscall_munmap :: #force_inline proc(addr: rawptr, len: u64) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.mmap), uintptr(addr), uintptr(len))
+}
+
+syscall_mmap :: #force_inline proc(addr: ^u8, len: u64, port: c.int, flags: c.int, fd: int, offset: off_t) -> ^u8 {
+	return cast(^u8)intrinsics.syscall(unix_offset_syscall(.mmap), uintptr(addr), uintptr(len), uintptr(port), uintptr(flags), uintptr(fd), uintptr(offset))
+}
+
+syscall_flock :: #force_inline proc(fd: c.int, operation: c.int) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.flock), uintptr(fd), uintptr(operation)) 
+}
+
+syscall_utimes :: #force_inline proc(path: cstring, times: ^timeval) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.utimes), transmute(uintptr)path, uintptr(times))
+}
+
+syscall_futimes :: #force_inline proc(fd: c.int, times: ^timeval) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.futimes), uintptr(fd), uintptr(times))
+}
+
+syscall_adjtime :: #force_inline proc(delta: ^timeval, old_delta: ^timeval) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.adjtime), uintptr(delta), uintptr(old_delta))
+}
+
+syscall_sysctlbyname :: #force_inline proc(name: cstring, oldp: rawptr, oldlenp: ^i64, newp: rawptr, newlen: i64) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.sysctlbyname), transmute(uintptr)name, uintptr(oldp), uintptr(oldlenp), uintptr(newp), uintptr(newlen))
+}
+
+syscall_proc_info :: #force_inline proc(num: c.int, pid: u32, flavor: c.int, arg: u64, buffer: rawptr, buffer_size: c.int) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.proc_info), uintptr(num), uintptr(pid), uintptr(flavor), uintptr(arg), uintptr(buffer), uintptr(buffer_size))
+}
+
+syscall_openat :: #force_inline proc(fd: int, path: cstring, oflag: u32, mode: u32) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.openat), uintptr(fd), transmute(uintptr)path, uintptr(oflag), uintptr(mode))
+} 
+
+syscall_getentropy :: #force_inline proc(buf: ^u8, buflen: u64) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(buf), uintptr(buflen))
+}
+
+syscall_pipe :: #force_inline proc(fds: [^]c.int) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(&fds[0]), uintptr(&fds[1]))
+}
+
+syscall_chdir :: #force_inline proc(path: cstring) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), transmute(uintptr)path)
+}
+
+syscall_fchdir :: #force_inline proc(fd: c.int, path: cstring) -> c.int {
+	return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(fd), transmute(uintptr)path)
+}