constants.odin 13 KB

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