constants.odin 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. package linux
  2. /*
  3. Special file descriptor to pass to `*at` functions to specify
  4. that relative paths are relative to current directory.
  5. */
  6. AT_FDCWD :: Fd(-100)
  7. /*
  8. Special value to put into timespec for utimensat() to set timestamp to the current time.
  9. */
  10. UTIME_NOW :: uint((1 << 30) - 1)
  11. /*
  12. Special value to put into the timespec for utimensat() to leave the corresponding field of the timestamp unchanged.
  13. */
  14. UTIME_OMIT :: uint((1 << 30) - 2)
  15. /*
  16. For wait4: Pass this pid to wait for any process.
  17. */
  18. WAIT_ANY :: Pid(-1)
  19. /*
  20. For wait4: Pass this pid to wait for any process in current process group.
  21. */
  22. WAIT_MYPGRP :: Pid(0)
  23. /*
  24. Maximum priority (aka nice value) for the process.
  25. */
  26. PRIO_MAX :: 20
  27. /*
  28. Minimum priority (aka nice value) for the process.
  29. */
  30. PRIO_MIN :: -20
  31. SIGRTMIN :: Signal(32)
  32. SIGRTMAX :: Signal(64)
  33. S_IFMT :: Mode{.IFREG, .IFDIR, .IFCHR, .IFFIFO}
  34. S_IFSOCK :: Mode{.IFREG, .IFDIR}
  35. S_IFLNK :: Mode{.IFREG, .IFCHR}
  36. S_IFBLK :: Mode{.IFDIR, .IFCHR}
  37. S_IFFIFO :: Mode{.IFFIFO}
  38. S_IFCHR :: Mode{.IFCHR}
  39. S_IFDIR :: Mode{.IFDIR}
  40. S_IFREG :: Mode{.IFREG}
  41. /*
  42. Checks the Mode bits to see if the file is a named pipe (FIFO).
  43. */
  44. S_ISFIFO :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFFIFO == (m & S_IFMT))}
  45. /*
  46. Check the Mode bits to see if the file is a character device.
  47. */
  48. S_ISCHR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFCHR == (m & S_IFMT))}
  49. /*
  50. Check the Mode bits to see if the file is a directory.
  51. */
  52. S_ISDIR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFDIR == (m & S_IFMT))}
  53. /*
  54. Check the Mode bits to see if the file is a register.
  55. */
  56. S_ISREG :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFREG == (m & S_IFMT))}
  57. /*
  58. Check the Mode bits to see if the file is a socket.
  59. */
  60. S_ISSOCK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFSOCK == (m & S_IFMT))}
  61. /*
  62. Check the Mode bits to see if the file is a symlink.
  63. */
  64. S_ISLNK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFLNK == (m & S_IFMT))}
  65. /*
  66. Check the Mode bits to see if the file is a block device.
  67. */
  68. S_ISBLK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFBLK == (m & S_IFMT))}
  69. /*
  70. For access.2 syscall family: instruct to check if the file exists.
  71. */
  72. F_OK :: Mode{}
  73. /*
  74. For access.2 syscall family: instruct to check if the file is executable.
  75. */
  76. X_OK :: Mode{.IXOTH}
  77. /*
  78. For access.2 syscall family: instruct to check if the file is writeable.
  79. */
  80. W_OK :: Mode{.IWOTH}
  81. /*
  82. For access.2 syscall family: instruct to check if the file is readable.
  83. */
  84. R_OK :: Mode{.IROTH}
  85. /*
  86. The stats you get by calling `stat`.
  87. */
  88. STATX_BASIC_STATS :: Statx_Mask {
  89. .TYPE,
  90. .MODE,
  91. .NLINK,
  92. .UID,
  93. .GID,
  94. .ATIME,
  95. .MTIME,
  96. .CTIME,
  97. .INO,
  98. .SIZE,
  99. .BLOCKS,
  100. }
  101. /*
  102. Tell `shmget` to create a new key
  103. */
  104. IPC_PRIVATE :: Key(0)
  105. FCntl_Command_DUPFD :: distinct FCntl_Command
  106. FCntl_Command_GETFD :: distinct FCntl_Command
  107. FCntl_Command_SETFD :: distinct FCntl_Command
  108. FCntl_Command_GETFL :: distinct FCntl_Command
  109. FCntl_Command_SETFL :: distinct FCntl_Command
  110. FCntl_Command_GETLK :: distinct FCntl_Command
  111. FCntl_Command_SETLK :: distinct FCntl_Command
  112. FCntl_Command_SETLKW :: distinct FCntl_Command
  113. FCntl_Command_DUPFD_CLOEXEC :: distinct FCntl_Command
  114. FCntl_Command_SETOWN :: distinct FCntl_Command
  115. FCntl_Command_GETOWN :: distinct FCntl_Command
  116. FCntl_Command_SETSIG :: distinct FCntl_Command
  117. FCntl_Command_GETSIG :: distinct FCntl_Command
  118. FCntl_Command_SETOWN_EX :: distinct FCntl_Command
  119. FCntl_Command_GETOWN_EX :: distinct FCntl_Command
  120. FCntl_Command_SETLEASE :: distinct FCntl_Command
  121. FCntl_Command_GETLEASE :: distinct FCntl_Command
  122. FCntl_Command_NOTIFY :: distinct FCntl_Command
  123. FCntl_Command_SETPIPE_SZ :: distinct FCntl_Command
  124. FCntl_Command_GETPIPE_SZ :: distinct FCntl_Command
  125. FCntl_Command_ADD_SEALS :: distinct FCntl_Command
  126. FCntl_Command_GET_SEALS :: distinct FCntl_Command
  127. FCntl_Command_GET_RW_HINT :: distinct FCntl_Command
  128. FCntl_Command_SET_RW_HINT :: distinct FCntl_Command
  129. FCntl_Command_GET_FILE_RW_HINT :: distinct FCntl_Command
  130. FCntl_Command_SET_FILE_RW_HINT :: distinct FCntl_Command
  131. F_DUPFD :: FCntl_Command_DUPFD(.DUPFD)
  132. F_GETFD :: FCntl_Command_GETFD(.GETFD)
  133. F_SETFD :: FCntl_Command_SETFD(.SETFD)
  134. F_GETFL :: FCntl_Command_GETFL(.GETFL)
  135. F_SETFL :: FCntl_Command_SETFL(.SETFL)
  136. // F_GETLK64 :: FCntl_Command_GETLK64(.GETLK64)
  137. // F_SETLK64 :: FCntl_Command_SETLK64(.SETLK64)
  138. // F_SETLKW64 :: FCntl_Command_SETLKW64(.SETLKW64)
  139. F_GETLK :: FCntl_Command_GETLK(.GETLK)
  140. F_SETLK :: FCntl_Command_SETLK(.SETLK)
  141. F_SETLKW :: FCntl_Command_SETLKW(.SETLKW)
  142. F_DUPFD_CLOEXEC :: FCntl_Command_DUPFD_CLOEXEC(.DUPFD_CLOEXEC)
  143. F_SETOWN :: FCntl_Command_SETOWN(.SETOWN)
  144. F_GETOWN :: FCntl_Command_GETOWN(.GETOWN)
  145. F_SETSIG :: FCntl_Command_SETSIG(.SETSIG)
  146. F_GETSIG :: FCntl_Command_GETSIG(.GETSIG)
  147. F_SETOWN_EX :: FCntl_Command_SETOWN_EX(.SETOWN_EX)
  148. F_GETOWN_EX :: FCntl_Command_GETOWN_EX(.GETOWN_EX)
  149. F_SETLEASE :: FCntl_Command_SETLEASE(.SETLEASE)
  150. F_GETLEASE :: FCntl_Command_GETLEASE(.GETLEASE)
  151. F_NOTIFY :: FCntl_Command_NOTIFY(.NOTIFY)
  152. F_SETPIPE_SZ :: FCntl_Command_SETPIPE_SZ(.SETPIPE_SZ)
  153. F_GETPIPE_SZ :: FCntl_Command_GETPIPE_SZ(.GETPIPE_SZ)
  154. F_ADD_SEALS :: FCntl_Command_ADD_SEALS(.ADD_SEALS)
  155. F_GET_SEALS :: FCntl_Command_GET_SEALS(.GET_SEALS)
  156. F_GET_RW_HINT :: FCntl_Command_GET_RW_HINT(.GET_RW_HINT)
  157. F_SET_RW_HINT :: FCntl_Command_SET_RW_HINT(.SET_RW_HINT)
  158. F_GET_FILE_RW_HINT :: FCntl_Command_GET_FILE_RW_HINT(.GET_FILE_RW_HINT)
  159. F_SET_FILE_RW_HINT :: FCntl_Command_SET_FILE_RW_HINT(.SET_FILE_RW_HINT)
  160. Socket_API_Level_Sock :: distinct Socket_API_Level
  161. Socket_API_Level_TCP :: distinct Socket_API_Level
  162. Socket_API_Level_UDP :: distinct Socket_API_Level
  163. Socket_API_Level_Raw :: distinct Socket_API_Level
  164. SOL_SOCKET :: Socket_API_Level_Sock(.SOCKET)
  165. SOL_TCP :: Socket_API_Level_TCP(.TCP)
  166. SOL_UDP :: Socket_API_Level_UDP(.UDP)
  167. SOL_RAW :: Socket_API_Level_Raw(.RAW)
  168. Futex_Wait_Type :: distinct Futex_Op
  169. Futex_Wake_Type :: distinct Futex_Op
  170. Futex_Fd_Type :: distinct Futex_Op
  171. Futex_Requeue_Type :: distinct Futex_Op
  172. Futex_Cmp_Requeue_Type :: distinct Futex_Op
  173. Futex_Wake_Op_Type :: distinct Futex_Op
  174. Futex_Lock_Pi_Type :: distinct Futex_Op
  175. Futex_Unlock_Pi_Type :: distinct Futex_Op
  176. Futex_Trylock_Pi_Type :: distinct Futex_Op
  177. Futex_Wait_Bitset_Type :: distinct Futex_Op
  178. Futex_Wake_Bitset_Type :: distinct Futex_Op
  179. Futex_Wait_requeue_Pi_Type :: distinct Futex_Op
  180. Futex_Cmp_requeue_Pi_Type :: distinct Futex_Op
  181. Futex_Lock_Pi2_Type :: distinct Futex_Op
  182. /*
  183. Wait on futex wakeup signal.
  184. */
  185. FUTEX_WAIT :: Futex_Wait_Type(.WAIT)
  186. /*
  187. Wake up other processes waiting on the futex.
  188. */
  189. FUTEX_WAKE :: Futex_Wake_Type(.WAKE)
  190. /*
  191. Not implemented. Basically, since.
  192. */
  193. FUTEX_FD :: Futex_Fd_Type(.FD)
  194. /*
  195. Requeue waiters from one futex to another.
  196. */
  197. FUTEX_REQUEUE :: Futex_Requeue_Type(.REQUEUE)
  198. /*
  199. Requeue waiters from one futex to another if the value at mutex matches.
  200. */
  201. FUTEX_CMP_REQUEUE :: Futex_Cmp_Requeue_Type(.CMP_REQUEUE)
  202. /*
  203. See man pages, I'm not describing it here.
  204. */
  205. FUTEX_WAKE_OP :: Futex_Wake_Op_Type(.WAKE_OP)
  206. /*
  207. Wait on a futex, but the value is a bitset.
  208. */
  209. FUTEX_WAIT_BITSET :: Futex_Wait_Bitset_Type(.WAIT_BITSET)
  210. /*
  211. Wait on a futex, but the value is a bitset.
  212. */
  213. FUTEX_WAKE_BITSET :: Futex_Wake_Bitset_Type(.WAKE_BITSET)
  214. // TODO(flysand): Priority inversion futexes
  215. FUTEX_LOCK_PI :: Futex_Lock_Pi_Type(.LOCK_PI)
  216. FUTEX_UNLOCK_PI :: Futex_Unlock_Pi_Type(.UNLOCK_PI)
  217. FUTEX_TRYLOCK_PI :: Futex_Trylock_Pi_Type(.TRYLOCK_PI)
  218. FUTEX_WAIT_REQUEUE_PI :: Futex_Wait_requeue_Pi_Type(.WAIT_REQUEUE_PI)
  219. FUTEX_CMP_REQUEUE_PI :: Futex_Cmp_requeue_Pi_Type(.CMP_REQUEUE_PI)
  220. FUTEX_LOCK_PI2 :: Futex_Lock_Pi2_Type(.LOCK_PI2)
  221. PTrace_Traceme_Type :: distinct PTrace_Request
  222. PTrace_Peek_Type :: distinct PTrace_Request
  223. PTrace_Poke_Type :: distinct PTrace_Request
  224. PTrace_Cont_Type :: distinct PTrace_Request
  225. PTrace_Kill_Type :: distinct PTrace_Request
  226. PTrace_Singlestep_Type :: distinct PTrace_Request
  227. PTrace_Getregs_Type :: distinct PTrace_Request
  228. PTrace_Setregs_Type :: distinct PTrace_Request
  229. PTrace_Getfpregs_Type :: distinct PTrace_Request
  230. PTrace_Setfpregs_Type :: distinct PTrace_Request
  231. PTrace_Attach_Type :: distinct PTrace_Request
  232. PTrace_Detach_Type :: distinct PTrace_Request
  233. PTrace_Getfpxregs_Type :: distinct PTrace_Request
  234. PTrace_Setfpxregs_Type :: distinct PTrace_Request
  235. PTrace_Syscall_Type :: distinct PTrace_Request
  236. PTrace_Get_Thread_Area_Type :: distinct PTrace_Request
  237. PTrace_Set_Thread_Area_Type :: distinct PTrace_Request
  238. PTrace_Arch_Prctl_Type :: distinct PTrace_Request
  239. PTrace_Sysemu_Type :: distinct PTrace_Request
  240. PTrace_Sysemu_Singlestep_Type :: distinct PTrace_Request
  241. PTrace_Singleblock_Type :: distinct PTrace_Request
  242. PTrace_Setoptions_Type :: distinct PTrace_Request
  243. PTrace_Geteventmsg_Type :: distinct PTrace_Request
  244. PTrace_Getsiginfo_Type :: distinct PTrace_Request
  245. PTrace_Setsiginfo_Type :: distinct PTrace_Request
  246. PTrace_Getregset_Type :: distinct PTrace_Request
  247. PTrace_Setregset_Type :: distinct PTrace_Request
  248. PTrace_Seize_Type :: distinct PTrace_Request
  249. PTrace_Interrupt_Type :: distinct PTrace_Request
  250. PTrace_Listen_Type :: distinct PTrace_Request
  251. PTrace_Peeksiginfo_Type :: distinct PTrace_Request
  252. PTrace_Getsigmask_Type :: distinct PTrace_Request
  253. PTrace_Setsigmask_Type :: distinct PTrace_Request
  254. PTrace_Seccomp_Get_Filter_Type :: distinct PTrace_Request
  255. PTrace_Seccomp_Get_Metadata_Type :: distinct PTrace_Request
  256. PTrace_Get_Syscall_Info_Type :: distinct PTrace_Request
  257. PTrace_Get_RSeq_Configuration_Type :: distinct PTrace_Request
  258. PTRACE_TRACEME :: PTrace_Traceme_Type(.TRACEME)
  259. PTRACE_PEEKTEXT :: PTrace_Peek_Type(.PEEKTEXT)
  260. PTRACE_PEEKDATA :: PTrace_Peek_Type(.PEEKDATA)
  261. PTRACE_PEEKUSER :: PTrace_Peek_Type(.PEEKUSER)
  262. PTRACE_POKETEXT :: PTrace_Poke_Type(.POKETEXT)
  263. PTRACE_POKEDATA :: PTrace_Poke_Type(.POKEDATA)
  264. PTRACE_POKEUSER :: PTrace_Poke_Type(.POKEUSER)
  265. PTRACE_CONT :: PTrace_Cont_Type(.CONT)
  266. PTRACE_KILL :: PTrace_Kill_Type(.KILL)
  267. PTRACE_SINGLESTEP :: PTrace_Singlestep_Type(.SINGLESTEP)
  268. PTRACE_GETREGS :: PTrace_Getregs_Type(.GETREGS)
  269. PTRACE_SETREGS :: PTrace_Setregs_Type(.SETREGS)
  270. PTRACE_GETFPREGS :: PTrace_Getfpregs_Type(.GETFPREGS)
  271. PTRACE_SETFPREGS :: PTrace_Setfpregs_Type(.SETFPREGS)
  272. PTRACE_ATTACH :: PTrace_Attach_Type(.ATTACH)
  273. PTRACE_DETACH :: PTrace_Detach_Type(.DETACH)
  274. PTRACE_GETFPXREGS :: PTrace_Getfpxregs_Type(.GETFPXREGS)
  275. PTRACE_SETFPXREGS :: PTrace_Setfpxregs_Type(.SETFPXREGS)
  276. PTRACE_SYSCALL :: PTrace_Syscall_Type(.SYSCALL)
  277. PTRACE_GET_THREAD_AREA :: PTrace_Get_Thread_Area_Type(.GET_THREAD_AREA)
  278. PTRACE_SET_THREAD_AREA :: PTrace_Set_Thread_Area_Type(.SET_THREAD_AREA)
  279. PTRACE_ARCH_PRCTL :: PTrace_Arch_Prctl_Type(.ARCH_PRCTL)
  280. PTRACE_SYSEMU :: PTrace_Sysemu_Type(.SYSEMU)
  281. PTRACE_SYSEMU_SINGLESTEP :: PTrace_Sysemu_Singlestep_Type(.SYSEMU_SINGLESTEP)
  282. PTRACE_SINGLEBLOCK :: PTrace_Singleblock_Type(.SINGLEBLOCK)
  283. PTRACE_SETOPTIONS :: PTrace_Setoptions_Type(.SETOPTIONS)
  284. PTRACE_GETEVENTMSG :: PTrace_Geteventmsg_Type(.GETEVENTMSG)
  285. PTRACE_GETSIGINFO :: PTrace_Getsiginfo_Type(.GETSIGINFO)
  286. PTRACE_SETSIGINFO :: PTrace_Setsiginfo_Type(.SETSIGINFO)
  287. PTRACE_GETREGSET :: PTrace_Getregset_Type(.GETREGSET)
  288. PTRACE_SETREGSET :: PTrace_Setregset_Type(.SETREGSET)
  289. PTRACE_SEIZE :: PTrace_Seize_Type(.SEIZE)
  290. PTRACE_INTERRUPT :: PTrace_Interrupt_Type(.INTERRUPT)
  291. PTRACE_LISTEN :: PTrace_Listen_Type(.LISTEN)
  292. PTRACE_PEEKSIGINFO :: PTrace_Peeksiginfo_Type(.PEEKSIGINFO)
  293. PTRACE_GETSIGMASK :: PTrace_Getsigmask_Type(.GETSIGMASK)
  294. PTRACE_SETSIGMASK :: PTrace_Setsigmask_Type(.SETSIGMASK)
  295. PTRACE_SECCOMP_GET_FILTER :: PTrace_Seccomp_Get_Filter_Type(.SECCOMP_GET_FILTER)
  296. PTRACE_SECCOMP_GET_METADATA :: PTrace_Seccomp_Get_Metadata_Type(.SECCOMP_GET_METADATA)
  297. PTRACE_GET_SYSCALL_INFO :: PTrace_Get_Syscall_Info_Type(.GET_SYSCALL_INFO)
  298. PTRACE_GET_RSEQ_CONFIGURATION :: PTrace_Get_RSeq_Configuration_Type(.GET_RSEQ_CONFIGURATION)