xnu_system_call_wrappers.odin 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. package darwin
  2. import "core:c"
  3. import "core:intrinsics"
  4. /* flock */
  5. LOCK_SH :: 1 /* shared lock */
  6. LOCK_EX :: 2 /* exclusive lock */
  7. LOCK_NB :: 4 /* don't block when locking */
  8. LOCK_UN :: 8 /* unlock */
  9. /* sys/unistd.h for access */
  10. F_OK :: c.int(0) /* test for existence of file */
  11. X_OK :: c.int((1 << 0)) /* test for execute or search permission */
  12. W_OK :: c.int((1 << 1)) /* test for write permission */
  13. R_OK :: c.int((1 << 2)) /* test for read permission */
  14. /* copyfile flags */
  15. COPYFILE_ACL :: (1 << 0)
  16. COPYFILE_STAT :: (1 << 1)
  17. COPYFILE_XATTR :: (1 << 2)
  18. COPYFILE_DATA :: (1 << 3)
  19. COPYFILE_SECURITY :: (COPYFILE_STAT | COPYFILE_ACL)
  20. COPYFILE_METADATA :: (COPYFILE_SECURITY | COPYFILE_XATTR)
  21. COPYFILE_ALL :: (COPYFILE_METADATA | COPYFILE_DATA)
  22. /* syslimits.h */
  23. PATH_MAX :: 1024 /* max bytes in pathname */
  24. /* param.h */
  25. MAXPATHLEN :: PATH_MAX
  26. /* proc_info.h */
  27. DARWIN_PROC_PIDPATHINFO_SIZE :: MAXPATHLEN
  28. DARWIN_PROC_PIDPATHINFO :: 11
  29. DARWIN_PROC_ALL_PIDS :: c.int(1)
  30. DARWIN_PROC_PGRP_ONLY :: c.int(2)
  31. DARWIN_PROC_TTY_ONLY :: c.int(3)
  32. DARWIN_PROC_UID_ONLY :: c.int(4)
  33. DARWIN_PROC_RUID_ONLY :: c.int(5)
  34. DARWIN_PROC_PPID_ONLY :: c.int(6)
  35. DARWIN_PROC_KDBG_ONLY :: c.int(7)
  36. DARWIN_PROC_INFO_CALL_LISTPIDS :: c.int(0x1)
  37. DARWIN_PROC_INFO_CALL_PIDINFO :: c.int(0x2)
  38. DARWIN_PROC_INFO_CALL_PIDFDINFO :: c.int(0x3)
  39. DARWIN_PROC_INFO_CALL_KERNMSGBUF :: c.int(0x4)
  40. DARWIN_PROC_INFO_CALL_SETCONTROL :: c.int(0x5)
  41. DARWIN_PROC_INFO_CALL_PIDFILEPORTINFO :: c.int(0x6)
  42. DARWIN_PROC_INFO_CALL_TERMINATE :: c.int(0x7)
  43. DARWIN_PROC_INFO_CALL_DIRTYCONTROL :: c.int(0x8)
  44. DARWIN_PROC_INFO_CALL_PIDRUSAGE :: c.int(0x9)
  45. DARWIN_PROC_INFO_CALL_PIDORIGINATORINFO :: c.int(0xa)
  46. DARWIN_PROC_INFO_CALL_LISTCOALITIONS :: c.int(0xb)
  47. DARWIN_PROC_INFO_CALL_CANUSEFGHW :: c.int(0xc)
  48. DARWIN_PROC_INFO_CALL_PIDDYNKQUEUEINFO :: c.int(0xd)
  49. DARWIN_PROC_INFO_CALL_UDATA_INFO :: c.int(0xe)
  50. /* mmap flags */
  51. MAP_ANONYMOUS :: 0x1000 /* allocated from memory, swap space */
  52. MAP_FILE :: 0x0000 /* map from file (default) */
  53. MAP_FIXED :: 0x0010 /* [MF|SHM] interpret addr exactly */
  54. MAP_HASSEMAPHORE :: 0x0200 /* region may contain semaphores */
  55. MAP_PRIVATE :: 0x0002 /* [MF|SHM] changes are private */
  56. MAP_SHARED :: 0x0001 /* [MF|SHM] share changes */
  57. MAP_NOCACHE :: 0x0400 /* don't cache pages for this mapping */
  58. MAP_JIT :: 0x0800 /* Allocate a region that will be used for JIT purposes */
  59. MAP_32BIT :: 0x8000 /* Return virtual addresses <4G only */
  60. /* mmap prot flags */
  61. PROT_NONE :: 0x00 /* [MC2] no permissions */
  62. PROT_READ :: 0x01 /* [MC2] pages can be read */
  63. PROT_WRITE :: 0x02 /* [MC2] pages can be written */
  64. PROT_EXEC :: 0x04 /* [MC2] pages can be executed */
  65. /* For owner Mode/Permission Flags for Open etc. */
  66. PERMISSION_MASK_IRWXU :: 0o000700 /* RWX mask for owner */
  67. PERMISSION_MASK_IRUSR :: 0o000400 /* R for owner */
  68. PERMISSION_MASK_IWUSR :: 0o000200 /* W for owner */
  69. PERMISSION_MASK_IXUSR :: 0o000100 /* X for owner */
  70. /* For group Mode/Permission Flags for Open etc. */
  71. PERMISSION_MASK_IRWXG :: 0o000070 /* RWX mask for group */
  72. PERMISSION_MASK_IRGRP :: 0o000040 /* R for group */
  73. PERMISSION_MASK_IWGRP :: 0o000020 /* W for group */
  74. PERMISSION_MASK_IXGRP :: 0o000010 /* X for group */
  75. /* For other Mode/Permission Flags for Open etc. */
  76. PERMISSION_MASK_IRWXO :: 0o000007 /* RWX mask for other */
  77. PERMISSION_MASK_IROTH :: 0o000004 /* R for other */
  78. PERMISSION_MASK_IWOTH :: 0o000002 /* W for other */
  79. PERMISSION_MASK_IXOTH :: 0o000001 /* X for other */
  80. /* Special Mode/Permission Flags for Open etc. */
  81. PERMISSION_MASK_ISUID :: 0o004000 /* set user id on execution */
  82. PERMISSION_MASK_ISGID :: 0o002000 /* set group id on execution */
  83. PERMISSION_MASK_ISVTX :: 0o001000 /* save swapped text even after use */
  84. OPEN_FLAG_RDONLY :: 0x0000 /* open for reading only */
  85. OPEN_FLAG_WRONLY :: 0x0001 /* open for writing only */
  86. OPEN_FLAG_RDWR :: 0x0002 /* open for reading and writing */
  87. /* mask for above rd/wr/rdwr flags */
  88. MASK_ACCMODE :: 0x0003
  89. OPEN_FLAG_NONBLOCK :: 0x00000004 /* no delay */
  90. OPEN_FLAG_APPEND :: 0x00000008 /* set append mode */
  91. OPEN_FLAG_CREAT :: 0x00000200 /* create if nonexistant */
  92. OPEN_FLAG_TRUNC :: 0x00000400 /* truncate to zero length */
  93. OPEN_FLAG_EXCL :: 0x00000800 /* error if already exists */
  94. OPEN_FLAG_SHLOCK :: 0x00000010 /* open with shared file lock */
  95. OPEN_FLAG_EXLOCK :: 0x00000020 /* open with exclusive file lock */
  96. OPEN_FLAG_DIRECTORY :: 0x00100000 /* restrict open to only directories */
  97. OPEN_FLAG_NOFOLLOW :: 0x00000100 /* don't follow symlinks */
  98. OPEN_FLAG_SYMLINK :: 0x00200000 /* allow open of a symlink */
  99. OPEN_FLAG_EVTONLY :: 0x00008000 /* descriptor requested for event notifications only */
  100. OPEN_FLAG_CLOEXEC :: 0x01000000 /* causes the descriptor to be closed if you use any of the exec like functions */
  101. OPEN_FLAG_NOFOLLOW_ANY :: 0x20000000 /* no symlinks allowed in path */
  102. /* bsd/sys/param.h */
  103. DARWIN_MAXCOMLEN :: 16
  104. /*--==========================================================================--*/
  105. __darwin_ino64_t :: u64
  106. __darwin_time_t :: u32
  107. __darwin_dev_t :: i32
  108. __darwin_mode_t :: u16
  109. __darwin_off_t :: i64
  110. __darwin_blkcnt_t :: i64
  111. __darwin_blksize_t :: i32
  112. __darwin_pid_t :: i32
  113. __darwin_suseconds_t :: i32
  114. time_t :: __darwin_time_t
  115. dev_t :: __darwin_dev_t
  116. mode_t :: u16
  117. nlink_t :: u16
  118. uid_t :: u16
  119. gid_t :: u16
  120. off_t :: __darwin_off_t
  121. blkcnt_t :: __darwin_blkcnt_t
  122. blksize_t :: __darwin_blksize_t
  123. pid_t :: __darwin_pid_t
  124. stat :: __DARWIN_STRUCT_STAT64
  125. timeval :: _STRUCT_TIMEVAL
  126. /*--==========================================================================--*/
  127. /* sys/stat.h */
  128. __DARWIN_STRUCT_STAT64 :: struct {
  129. st_dev: dev_t, /* [XSI] ID of device containing file */
  130. st_mode: mode_t, /* [XSI] Mode of file (see below) */
  131. st_nlink: nlink_t, /* [XSI] Number of hard links */
  132. st_ino: __darwin_ino64_t, /* [XSI] File serial number */
  133. st_uid_t: uid_t, /* [XSI] User ID of the file */
  134. st_gid_t: gid_t, /* [XSI] Group ID of the file */
  135. st_rdev: dev_t, /* [XSI] Device ID */
  136. // __DARWIN_STRUCT_STAT64_TIMES
  137. st_atime: time_t, /* [XSI] Time of last access */
  138. st_atimensec: i32, /* nsec of last access */
  139. st_mtime: time_t, /* [XSI] Last data modification time */
  140. st_mtimensec: i32, /* last data modification nsec */
  141. st_ctime: time_t, /* [XSI] Time of last status change */
  142. st_ctimensec: u32, /* nsec of last status change */
  143. st_birthtime: time_t, /* File creation time(birth) */
  144. st_birthtimensec: i32, /* nsec of File creation time */
  145. // end __DARWIN_STRUCT_STAT64_TIMES
  146. st_size: off_t, /* [XSI] file size, in bytes */
  147. st_blocks: blkcnt_t, /* [XSI] blocks allocated for file */
  148. st_blksize: blksize_t, /* [XSI] optimal blocksize for I/O */
  149. st_flags: u32, /* user defined flags for file */
  150. st_gen: u32, /* file generation number */
  151. st_lspare: i32, /* RESERVED: DO NOT USE! */
  152. st_qspare: [2]i64, /* RESERVED: DO NOT USE! */
  153. }
  154. /* sys/_types/_timeval.h */
  155. _STRUCT_TIMEVAL :: struct {
  156. tv_sec: __darwin_time_t, /* seconds */
  157. tv_usec: __darwin_suseconds_t, /* microseconds */
  158. }
  159. /* pwd.h */
  160. _Password_Entry :: struct {
  161. pw_name: cstring, /* username */
  162. pw_passwd: cstring, /* user password */
  163. pw_uid: i32, /* user ID */
  164. pw_gid: i32, /* group ID */
  165. pw_change: u64, /* password change time */
  166. pw_class: cstring, /* user access class */
  167. pw_gecos: cstring, /* full user name */
  168. pw_dir: cstring, /* home directory */
  169. pw_shell: cstring, /* shell program */
  170. pw_expire: u64, /* account expiration */
  171. pw_fields: i32, /* filled fields */
  172. }
  173. /* processinfo.h */
  174. _Proc_Bsdinfo :: struct {
  175. pbi_flags: u32, /* if is 64bit; emulated etc */
  176. pbi_status: u32,
  177. pbi_xstatus: u32,
  178. pbi_pid: u32,
  179. pbi_ppid: u32,
  180. pbi_uid: u32,
  181. pbi_gid: u32,
  182. pbi_ruid: u32,
  183. pbi_rgid: u32,
  184. pbi_svuid: u32,
  185. pbi_svgid: u32,
  186. res: u32,
  187. pbi_comm: [DARWIN_MAXCOMLEN]u8,
  188. pbi_name: [2 * DARWIN_MAXCOMLEN]u8, /* empty if no name is registered */
  189. pbi_nfiles: u32,
  190. pbi_pgid: u32,
  191. pbi_pjobc: u32,
  192. e_tdev: u32, /* controlling tty dev */
  193. e_tpgid: u32, /* tty process group id */
  194. pbi_nice: i32,
  195. pbi_start_tvsec: u64,
  196. pbi_start_tvusec: u64,
  197. }
  198. /*--==========================================================================--*/
  199. syscall_fsync :: #force_inline proc(fildes: c.int) -> bool {
  200. return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.fsync), uintptr(fildes)))
  201. }
  202. syscall_write :: #force_inline proc (fildes: c.int, buf: ^byte, nbyte: u64) -> bool {
  203. return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.write), uintptr(fildes), uintptr(buf), uintptr(nbyte)))
  204. }
  205. syscall_read :: #force_inline proc(fildes: c.int, buf: ^byte, nbyte: u64) -> i64 {
  206. return cast(i64)intrinsics.syscall(unix_offset_syscall(.read), uintptr(fildes), uintptr(buf), uintptr(nbyte))
  207. }
  208. syscall_open :: #force_inline proc(path: cstring, oflag: u32, mode: u32) -> c.int {
  209. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.open), transmute(uintptr)path, uintptr(oflag), uintptr(mode))
  210. }
  211. syscall_close :: #force_inline proc(fd: c.int) -> bool {
  212. return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.close), uintptr(fd)))
  213. }
  214. syscall_fchmod :: #force_inline proc(fildes: c.int, mode: u32) -> c.int {
  215. return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.fchmod), uintptr(fildes), uintptr(mode)))
  216. }
  217. syscall_chmod :: #force_inline proc(path: cstring, mode: u32) -> c.int {
  218. return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.chmod), transmute(uintptr)path, uintptr(mode)))
  219. }
  220. syscall_mkdir :: #force_inline proc(path: cstring, mode: u32) -> c.int {
  221. return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.mkdir), transmute(uintptr)path, uintptr(mode)))
  222. }
  223. syscall_mkdir_at :: #force_inline proc(fd: c.int, path: cstring, mode: u32) -> c.int {
  224. return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.mkdir), uintptr(fd), transmute(uintptr)path, uintptr(mode)))
  225. }
  226. syscall_rmdir :: #force_inline proc(path: cstring, mode: u32) -> c.int {
  227. return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.rmdir), transmute(uintptr)path, uintptr(mode)))
  228. }
  229. syscall_rename :: #force_inline proc(path_old: cstring, path_new: cstring) -> c.int {
  230. return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.rename), transmute(uintptr)path_old, transmute(uintptr)path_new))
  231. }
  232. syscall_rename_at :: #force_inline proc(from_fd: c.int, from: cstring, to_fd: c.int, to: cstring) -> c.int {
  233. return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.renameat), uintptr(from_fd), transmute(uintptr)from, uintptr(to_fd), transmute(uintptr)to))
  234. }
  235. syscall_lseek :: #force_inline proc(fd: c.int, offset: i64, whence: c.int) -> i64 {
  236. return cast(i64)intrinsics.syscall(unix_offset_syscall(.lseek), uintptr(fd), uintptr(offset), uintptr(whence))
  237. }
  238. syscall_gettid :: #force_inline proc() -> u64 {
  239. return cast(u64)intrinsics.syscall(unix_offset_syscall(.gettid))
  240. }
  241. syscall_fstat :: #force_inline proc(fd: c.int, status: ^stat) -> c.int {
  242. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fstat), uintptr(fd), uintptr(status))
  243. }
  244. syscall_lstat :: #force_inline proc(path: cstring, status: ^stat) -> c.int {
  245. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.lstat), transmute(uintptr)path, uintptr(status))
  246. }
  247. syscall_stat :: #force_inline proc(path: cstring, status: ^stat) -> c.int {
  248. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.stat), transmute(uintptr)path, uintptr(status))
  249. }
  250. syscall_fstatat :: #force_inline proc(fd: c.int, path: cstring, status: ^stat) -> c.int {
  251. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fstatat), uintptr(fd), transmute(uintptr)path, uintptr(status))
  252. }
  253. syscall_link :: #force_inline proc(path: cstring, to_link: cstring) -> c.int {
  254. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.link), transmute(uintptr)path, transmute(uintptr)to_link)
  255. }
  256. syscall_linkat :: #force_inline proc(fd: c.int, path: cstring, fd2: c.int, to_link: cstring) -> c.int {
  257. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.linkat), uintptr(fd), transmute(uintptr)path, uintptr(fd2), transmute(uintptr)to_link)
  258. }
  259. syscall_readlink :: #force_inline proc(path: cstring, buf: ^u8, buf_size: u64) -> i64 {
  260. return cast(i64)intrinsics.syscall(unix_offset_syscall(.readlink), transmute(uintptr)path, uintptr(buf), uintptr(buf_size))
  261. }
  262. syscall_readlinkat :: #force_inline proc(fd: c.int, path: cstring, buf: ^u8, buf_size: u64) -> i64 {
  263. return cast(i64)intrinsics.syscall(unix_offset_syscall(.readlinkat), uintptr(fd), transmute(uintptr)path, uintptr(buf), uintptr(buf_size))
  264. }
  265. syscall_access :: #force_inline proc(path: cstring, mode: c.int) -> c.int {
  266. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.access), transmute(uintptr)path, uintptr(mode))
  267. }
  268. syscall_faccessat :: #force_inline proc(fd: c.int, path: cstring, mode: c.int, flag: c.int) -> c.int {
  269. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.faccessat), uintptr(fd), transmute(uintptr)path, uintptr(mode), uintptr(flag))
  270. }
  271. syscall_getdirentries :: #force_inline proc(fd: c.int, buf: ^u8, nbytes: c.int, base_pointer: ^u32) -> c.int {
  272. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getdirentries), uintptr(fd), uintptr(buf), uintptr(nbytes), uintptr(base_pointer))
  273. }
  274. syscall_truncate :: #force_inline proc (path: cstring, length: off_t) -> c.int {
  275. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.truncate), transmute(uintptr)path, uintptr(length))
  276. }
  277. syscall_ftruncate :: #force_inline proc (fd: c.int, length: off_t) -> c.int {
  278. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.ftruncate), uintptr(fd), uintptr(length))
  279. }
  280. syscall_sysctl :: #force_inline proc (name: ^c.int, namelen: c.uint, oldp: rawptr, oldlenp: ^i64, newp: ^i8, newlen: i64) -> c.int {
  281. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.sysctl), uintptr(name), uintptr(namelen), uintptr(oldp), uintptr(oldlenp), uintptr(newp), uintptr(newlen))
  282. }
  283. syscall_copyfile :: #force_inline proc(from: cstring, to: cstring, state: rawptr, flags: u32) -> c.int {
  284. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.copyfile), transmute(uintptr)from, transmute(uintptr)to, uintptr(state), uintptr(flags))
  285. }
  286. // think about this? last arg should be more than one
  287. syscall_fcntl :: #force_inline proc(fd: c.int, cmd: c.int, other: rawptr) -> c.int {
  288. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.fsctl), uintptr(fd), uintptr(cmd), uintptr(other))
  289. }
  290. syscall_exit :: #force_inline proc(code: c.int) {
  291. intrinsics.syscall(unix_offset_syscall(.exit), uintptr(code))
  292. }
  293. syscall_kill :: #force_inline proc(pid: pid_t, sig: c.int) -> c.int {
  294. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.kill), uintptr(pid), uintptr(sig))
  295. }
  296. syscall_dup :: #force_inline proc(fd: c.int) -> c.int {
  297. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.dup), uintptr(fd))
  298. }
  299. syscall_execve :: #force_inline proc(path: cstring, argv: [^]cstring, env: [^]cstring) -> c.int {
  300. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.execve), transmute(uintptr)path, transmute(uintptr)argv, transmute(uintptr)env)
  301. }
  302. syscall_munmap :: #force_inline proc(addr: rawptr, len: u64) -> c.int {
  303. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.mmap), uintptr(addr), uintptr(len))
  304. }
  305. syscall_mmap :: #force_inline proc(addr: ^u8, len: u64, port: c.int, flags: c.int, fd: int, offset: off_t) -> ^u8 {
  306. return cast(^u8)intrinsics.syscall(unix_offset_syscall(.mmap), uintptr(addr), uintptr(len), uintptr(port), uintptr(flags), uintptr(fd), uintptr(offset))
  307. }
  308. syscall_flock :: #force_inline proc(fd: c.int, operation: c.int) -> c.int {
  309. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.flock), uintptr(fd), uintptr(operation))
  310. }
  311. syscall_utimes :: #force_inline proc(path: cstring, times: ^timeval) -> c.int {
  312. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.utimes), transmute(uintptr)path, uintptr(times))
  313. }
  314. syscall_futimes :: #force_inline proc(fd: c.int, times: ^timeval) -> c.int {
  315. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.futimes), uintptr(fd), uintptr(times))
  316. }
  317. syscall_adjtime :: #force_inline proc(delta: ^timeval, old_delta: ^timeval) -> c.int {
  318. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.adjtime), uintptr(delta), uintptr(old_delta))
  319. }
  320. syscall_sysctlbyname :: #force_inline proc(name: cstring, oldp: rawptr, oldlenp: ^i64, newp: rawptr, newlen: i64) -> c.int {
  321. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.sysctlbyname), transmute(uintptr)name, uintptr(oldp), uintptr(oldlenp), uintptr(newp), uintptr(newlen))
  322. }
  323. syscall_proc_info :: #force_inline proc(num: c.int, pid: u32, flavor: c.int, arg: u64, buffer: rawptr, buffer_size: c.int) -> c.int {
  324. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.proc_info), uintptr(num), uintptr(pid), uintptr(flavor), uintptr(arg), uintptr(buffer), uintptr(buffer_size))
  325. }
  326. syscall_openat :: #force_inline proc(fd: int, path: cstring, oflag: u32, mode: u32) -> c.int {
  327. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.openat), uintptr(fd), transmute(uintptr)path, uintptr(oflag), uintptr(mode))
  328. }
  329. syscall_getentropy :: #force_inline proc(buf: [^]u8, buflen: u64) -> c.int {
  330. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(buf), uintptr(buflen))
  331. }
  332. syscall_pipe :: #force_inline proc(fds: [^]c.int) -> c.int {
  333. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(&fds[0]), uintptr(&fds[1]))
  334. }
  335. syscall_chdir :: #force_inline proc(path: cstring) -> c.int {
  336. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), transmute(uintptr)path)
  337. }
  338. syscall_fchdir :: #force_inline proc(fd: c.int, path: cstring) -> c.int {
  339. return cast(c.int)intrinsics.syscall(unix_offset_syscall(.getentropy), uintptr(fd), transmute(uintptr)path)
  340. }