core/sys/darwin

darwin

Types

53

Offset_From

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. }Source

Open_Flags_Enum

Open_Flags_Enum :: enum u8 { RDONLY = 0, // open for reading only WRONLY = 1, // open for writing only RDWR = 2, // open for reading and writing NONBLOCK = 3, // no delay APPEND = 4, // set append mode CREAT = 5, // create if nonexistant TRUNC = 6, // truncate to zero length EXCL = 7, // error if already exists SHLOCK = 8, // open with shared file lock EXLOCK = 9, // open with exclusive file lock DIRECTORY = 10, // restrict open to only directories NOFOLLOW = 11, // don't follow symlinks SYMLINK = 12, // allow open of a symlink EVTONLY = 13, // descriptor requested for event notifications only CLOEXEC = 14, // causes the descriptor to be closed if you use any of the exec like functions NOFOLLOW_ANY = 15, // no symlinks allowed in path }Source

PBI_Flag_Bits

PBI_Flag_Bits :: enum u32 { SYSTEM = intrinsics.constant_log2(0x0001), TRACED = intrinsics.constant_log2(0x0002), INEXIT = intrinsics.constant_log2(0x0004), PWAIT = intrinsics.constant_log2(0x0008), LP64 = intrinsics.constant_log2(0x0010), SLEADER = intrinsics.constant_log2(0x0020), CTTY = intrinsics.constant_log2(0x0040), CONTROLT = intrinsics.constant_log2(0x0080), THCWD = intrinsics.constant_log2(0x0100), PC_THROTTLE = intrinsics.constant_log2(0x0200), PC_SUSP = intrinsics.constant_log2(0x0400), PC_KILL = intrinsics.constant_log2(0x0600), PA_THROTTLE = intrinsics.constant_log2(0x0800), PA_SUSP = intrinsics.constant_log2(0x1000), PA_PSUGID = intrinsics.constant_log2(0x2000), EXEC = intrinsics.constant_log2(0x4000), }Source

PID_Info_Flavor

PID_Info_Flavor :: enum i32 { LISTFDS = 1, TASKALLINFO = 2, BSDINFO = 3, TASKINFO = 4, THREADINFO = 5, LISTTHREADS = 6, REGIONINFO = 7, REGIONPATHINFO = 8, VNODEPATHINFO = 9, THREADPATHINFO = 10, PATHINFO = 11, WORKQUEUEINFO = 12, SHORTBSDINFO = 13, LISTFILEPORTS = 14, THREADID64INFO = 15, RUSAGE = 16, }Source

Permission_Enum

Permission_Enum :: enum u8 { // For owner PERMISSION_OWNER_READ = 0, // R for owner PERMISSION_OWNER_WRITE = 1, // W for owner PERMISSION_OWNER_EXECUTE = 2, // X for owner // IRWXU, /* RWX mask for owner */ // For group PERMISSION_GROUP_READ = 3, // R for group PERMISSION_GROUP_WRITE = 4, // W for group PERMISSION_GROUP_EXECUTE = 5, // X for group // IRWXG, /* RWX mask for group */ // For other PERMISSION_OTHER_READ = 6, // R for other PERMISSION_OTHER_WRITE = 7, // W for other PERMISSION_OTHER_EXECUTE = 8, // X for other // IRWXO, /* RWX mask for other */ // Special PERMISSION_SET_USER_ON_EXECUTION = 9, // set user id on execution PERMISSION_SET_GROUP_ON_EXECUTION = 10, // set group id on execution // ?? PERMISSION_ISVTX = 11, // save swapped text even after use }Source

System_Call_Number

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 =Source

__DARWIN_STRUCT_STAT64

__DARWIN_STRUCT_STAT64 :: struct { st_dev: dev_t, st_mode: mode_t, st_nlink: nlink_t, st_ino: __darwin_ino64_t, st_uid_t: uid_t, st_gid_t: gid_t, st_rdev: dev_t, // __DARWIN_STRUCT_STAT64_TIMES st_atime: time_t, st_atimensec: i32, st_mtime: time_t, st_mtimensec: i32, st_ctime: time_t, st_ctimensec: u32, st_birthtime: time_t, st_birthtimensec: i32, // end __DARWIN_STRUCT_STAT64_TIMES st_size: off_t, st_blocks: blkcnt_t, st_blksize: blksize_t, st_flags: u32, st_gen: u32, st_lspare: i32, st_qspare: [2]i64, }Source

--==========================================================================-- sys/stat.h

copyfile_state_flag

copyfile_state_flag :: enum u32 { SRC_FD = 1, SRC_FILENAME = 2, DST_FD = 3, DST_FILENAME = 4, QUARANTINE = 5, STATUS_CB = 6, STATUS_CTX = 7, COPIED = 8, XATTRNAME = 9, WAS_CLONED = 10, SRC_BSIZE = 11, DST_BSIZE = 12, BSIZE = 13, FORBID_CROSS_MOUNT = 14, NOCPROTECT = 15, PRESERVE_SUID = 16, RECURSIVE_SRC_FTSENT = 17, FORBID_DST_EXISTING_SYMLINKS = 18, }Source

os_sync_wait_on_address_flag

os_sync_wait_on_address_flag :: enum u32 { // This flag should be used when synchronizing among multiple processes by // placing the @addr passed to os_sync_wait_on_address and its variants // in a shared memory region. // // When using this flag, it is important to pass OS_SYNC_WAKE_BY_ADDRESS_SHARED // flag along with the exact same @addr to os_sync_wake_by_address_any and // its variants to correctly find and wake up blocked waiters on the @addr. // // This flag should not be used when synchronizing among multiple threads of // a single process. It allows the kernel to perform performance optimizations // as the @addr is local to the calling process. SHARED = 0, }Source

os_sync_wake_by_address_flag

os_sync_wake_by_address_flag :: enum u32 { // This flag should be used when synchronizing among multiple processes by // placing the @addr passed to os_sync_wake_by_address_any and its variants // in a shared memory region. // // When using this flag, it is important to pass OS_SYNC_WAIT_ON_ADDRESS_SHARED // flag along with the exact same @addr to os_sync_wait_on_address and // its variants to correctly find and wake up blocked waiters on the @addr. // // This flag should not be used when synchronizing among multiple threads of // a single process. It allows the kernel to perform performance optimizations // as the @addr is local the calling process. SHARED = 0, }Source

proc_bsdinfo

proc_bsdinfo :: struct { pbi_flags: PBI_Flags, pbi_status: u32, pbi_xstatus: u32, pbi_pid: u32, pbi_ppid: u32, pbi_uid: posix.uid_t, pbi_gid: posix.gid_t, pbi_ruid: posix.uid_t, pbi_rgid: posix.gid_t, pbi_svuid: posix.uid_t, pbi_svgid: posix.gid_t, rfu_1: u32, pbi_comm: [16]u8, pbi_name: [32]u8, pbi_nfiles: u32, pbi_pgid: u32, pbi_pjobc: u32, e_tdev: u32, e_tpgid: u32, pbi_nice: i32, pbi_start_tvsec: u64, pbi_start_tvusec: u64, }Source

proc_taskinfo

proc_taskinfo :: struct { pti_virtual_size: u64, pti_resident_size: u64, pti_total_user: u64, pti_total_system: u64, pti_threads_user: u64, pti_threads_system: u64, pti_policy: i32, pti_faults: i32, pti_pageins: i32, pti_cow_faults: i32, pti_messages_sent: i32, pti_messages_received: i32, pti_syscalls_mach: i32, pti_syscalls_unix: i32, pti_csw: i32, pti_threadnum: i32, pti_numrunning: i32, pti_priority: i32, }Source

vinfo_stat

vinfo_stat :: struct { vst_dev: u32, vst_mode: u16, vst_nlink: u16, vst_ino: u64, vst_uid: posix.uid_t, vst_gid: posix.gid_t, vst_atime: i64, vst_atimensec: i64, vst_mtime: i64, vst_mtimensec: i64, vst_ctime: i64, vst_ctimensec: i64, vst_birthtime: i64, vst_birthtimensec: i64, vst_size: posix.off_t, vst_blocks: i64, vst_blksize: i32, vst_flags: u32, vst_gen: u32, vst_rdev: u32, vst_qspare: [2]i64, }Source

Constants

93

LOCK_SH

LOCK_SH :: 1Source

IMPORTANT NOTE: direct syscall usage is not allowed by Apple's review process of apps and should be entirely avoided in the builtin Odin collections, these are here for users if they don't care about the Apple review process. flock

TIOCGWINSZ

TIOCGWINSZ :: 0x40087468Source

--==========================================================================-- Get window size

Procedures

65

sys_write_string

sys_write_string :: proc(fd: c.int, message: string) -> (bool)Source

IMPORTANT NOTE: direct syscall usage is not allowed by Apple's review process of apps and should be entirely avoided in the builtin Odin collections, these are here for users if they don't care about the Apple review process. this package uses the sys prefix for the proc names to indicate that these aren't native syscalls but directly call such

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.