constants.odin 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. package linux
  2. /// Special file descriptor to pass to `*at` functions to specify
  3. /// that relative paths are relative to current directory
  4. AT_FDCWD :: Fd(-100)
  5. /// Special value to put into timespec for utimensat() to set timestamp to the current time
  6. UTIME_NOW :: uint((1 << 30) - 1)
  7. /// Special value to put into the timespec for utimensat() to leave the corresponding field of the timestamp unchanged
  8. UTIME_OMIT :: uint((1 << 30) - 2)
  9. /// For wait4: Pass this pid to wait for any process
  10. WAIT_ANY :: Pid(-1)
  11. /// For wait4: Pass this pid to wait for any process in current process group
  12. WAIT_MYPGRP :: Pid(0)
  13. /// Maximum priority (aka nice value) for the process
  14. PRIO_MAX :: 20
  15. /// Minimum priority (aka nice value) for the process
  16. PRIO_MIN :: -20
  17. SIGRTMIN :: Signal(32)
  18. SIGRTMAX :: Signal(64)
  19. S_IFMT :: Mode{.IFREG, .IFDIR, .IFCHR, .IFFIFO}
  20. S_IFSOCK :: Mode{.IFREG, .IFDIR}
  21. S_IFLNK :: Mode{.IFREG, .IFCHR}
  22. S_IFBLK :: Mode{.IFDIR, .IFCHR}
  23. S_IFFIFO :: Mode{.IFFIFO}
  24. S_IFCHR :: Mode{.IFCHR}
  25. S_IFDIR :: Mode{.IFDIR}
  26. S_IFREG :: Mode{.IFREG}
  27. /// Checks the Mode bits to see if the file is a named pipe (FIFO)
  28. S_ISFIFO :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFFIFO == (m & S_IFMT))}
  29. /// Check the Mode bits to see if the file is a character device
  30. S_ISCHR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFCHR == (m & S_IFMT))}
  31. /// Check the Mode bits to see if the file is a directory
  32. S_ISDIR :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFDIR == (m & S_IFMT))}
  33. /// Check the Mode bits to see if the file is a register
  34. S_ISREG :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFREG == (m & S_IFMT))}
  35. /// Check the Mode bits to see if the file is a socket
  36. S_ISSOCK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFSOCK == (m & S_IFMT))}
  37. /// Check the Mode bits to see if the file is a symlink
  38. S_ISLNK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFLNK == (m & S_IFMT))}
  39. /// Check the Mode bits to see if the file is a block device
  40. S_ISBLK :: #force_inline proc "contextless" (m: Mode) -> bool {return (S_IFBLK == (m & S_IFMT))}
  41. /// For access.2 syscall family: instruct to check if the file exists
  42. F_OK :: Mode{}
  43. /// For access.2 syscall family: instruct to check if the file is executable
  44. X_OK :: Mode{.IXOTH}
  45. /// For access.2 syscall family: instruct to check if the file is writeable
  46. W_OK :: Mode{.IWOTH}
  47. /// For access.2 syscall family: instruct to check if the file is readable
  48. R_OK :: Mode{.IROTH}
  49. /// The stats you get by calling `stat`
  50. STATX_BASIC_STATS :: Statx_Mask {
  51. .TYPE,
  52. .MODE,
  53. .NLINK,
  54. .UID,
  55. .GID,
  56. .ATIME,
  57. .MTIME,
  58. .CTIME,
  59. .INO,
  60. .SIZE,
  61. .BLOCKS,
  62. }
  63. FCntl_Command_DUPFD :: distinct FCntl_Command
  64. FCntl_Command_GETFD :: distinct FCntl_Command
  65. FCntl_Command_SETFD :: distinct FCntl_Command
  66. FCntl_Command_GETFL :: distinct FCntl_Command
  67. FCntl_Command_SETFL :: distinct FCntl_Command
  68. FCntl_Command_GETLK :: distinct FCntl_Command
  69. FCntl_Command_SETLK :: distinct FCntl_Command
  70. FCntl_Command_SETLKW :: distinct FCntl_Command
  71. FCntl_Command_DUPFD_CLOEXEC :: distinct FCntl_Command
  72. FCntl_Command_SETOWN :: distinct FCntl_Command
  73. FCntl_Command_GETOWN :: distinct FCntl_Command
  74. FCntl_Command_SETSIG :: distinct FCntl_Command
  75. FCntl_Command_GETSIG :: distinct FCntl_Command
  76. FCntl_Command_SETOWN_EX :: distinct FCntl_Command
  77. FCntl_Command_GETOWN_EX :: distinct FCntl_Command
  78. FCntl_Command_SETLEASE :: distinct FCntl_Command
  79. FCntl_Command_GETLEASE :: distinct FCntl_Command
  80. FCntl_Command_NOTIFY :: distinct FCntl_Command
  81. FCntl_Command_SETPIPE_SZ :: distinct FCntl_Command
  82. FCntl_Command_GETPIPE_SZ :: distinct FCntl_Command
  83. FCntl_Command_ADD_SEALS :: distinct FCntl_Command
  84. FCntl_Command_GET_SEALS :: distinct FCntl_Command
  85. FCntl_Command_GET_RW_HINT :: distinct FCntl_Command
  86. FCntl_Command_SET_RW_HINT :: distinct FCntl_Command
  87. FCntl_Command_GET_FILE_RW_HINT :: distinct FCntl_Command
  88. FCntl_Command_SET_FILE_RW_HINT :: distinct FCntl_Command
  89. F_DUPFD :: FCntl_Command_DUPFD(.DUPFD)
  90. F_GETFD :: FCntl_Command_GETFD(.GETFD)
  91. F_SETFD :: FCntl_Command_SETFD(.SETFD)
  92. F_GETFL :: FCntl_Command_GETFL(.GETFL)
  93. F_SETFL :: FCntl_Command_SETFL(.SETFL)
  94. // F_GETLK64 :: FCntl_Command_GETLK64(.GETLK64)
  95. // F_SETLK64 :: FCntl_Command_SETLK64(.SETLK64)
  96. // F_SETLKW64 :: FCntl_Command_SETLKW64(.SETLKW64)
  97. F_GETLK :: FCntl_Command_GETLK(.GETLK)
  98. F_SETLK :: FCntl_Command_SETLK(.SETLK)
  99. F_SETLKW :: FCntl_Command_SETLKW(.SETLKW)
  100. F_DUPFD_CLOEXEC :: FCntl_Command_DUPFD_CLOEXEC(.DUPFD_CLOEXEC)
  101. F_SETOWN :: FCntl_Command_SETOWN(.SETOWN)
  102. F_GETOWN :: FCntl_Command_GETOWN(.GETOWN)
  103. F_SETSIG :: FCntl_Command_SETSIG(.SETSIG)
  104. F_GETSIG :: FCntl_Command_GETSIG(.GETSIG)
  105. F_SETOWN_EX :: FCntl_Command_SETOWN_EX(.SETOWN_EX)
  106. F_GETOWN_EX :: FCntl_Command_GETOWN_EX(.GETOWN_EX)
  107. F_SETLEASE :: FCntl_Command_SETLEASE(.SETLEASE)
  108. F_GETLEASE :: FCntl_Command_GETLEASE(.GETLEASE)
  109. F_NOTIFY :: FCntl_Command_NOTIFY(.NOTIFY)
  110. F_SETPIPE_SZ :: FCntl_Command_SETPIPE_SZ(.SETPIPE_SZ)
  111. F_GETPIPE_SZ :: FCntl_Command_GETPIPE_SZ(.GETPIPE_SZ)
  112. F_ADD_SEALS :: FCntl_Command_ADD_SEALS(.ADD_SEALS)
  113. F_GET_SEALS :: FCntl_Command_GET_SEALS(.GET_SEALS)
  114. F_GET_RW_HINT :: FCntl_Command_GET_RW_HINT(.GET_RW_HINT)
  115. F_SET_RW_HINT :: FCntl_Command_SET_RW_HINT(.SET_RW_HINT)
  116. F_GET_FILE_RW_HINT :: FCntl_Command_GET_FILE_RW_HINT(.GET_FILE_RW_HINT)
  117. F_SET_FILE_RW_HINT :: FCntl_Command_SET_FILE_RW_HINT(.SET_FILE_RW_HINT)
  118. Socket_API_Level_Sock :: distinct Socket_API_Level
  119. Socket_API_Level_TCP :: distinct Socket_API_Level
  120. Socket_API_Level_UDP :: distinct Socket_API_Level
  121. Socket_API_Level_Raw :: distinct Socket_API_Level
  122. SOL_SOCKET :: Socket_API_Level_Sock(.SOCKET)
  123. SOL_TCP :: Socket_API_Level_TCP(.TCP)
  124. SOL_UDP :: Socket_API_Level_UDP(.UDP)
  125. SOL_RAW :: Socket_API_Level_Raw(.RAW)
  126. Futex_Wait_Type :: distinct Futex_Op
  127. Futex_Wake_Type :: distinct Futex_Op
  128. Futex_Fd_Type :: distinct Futex_Op
  129. Futex_Requeue_Type :: distinct Futex_Op
  130. Futex_Cmp_Requeue_Type :: distinct Futex_Op
  131. Futex_Wake_Op_Type :: distinct Futex_Op
  132. Futex_Lock_Pi_Type :: distinct Futex_Op
  133. Futex_Unlock_Pi_Type :: distinct Futex_Op
  134. Futex_Trylock_Pi_Type :: distinct Futex_Op
  135. Futex_Wait_Bitset_Type :: distinct Futex_Op
  136. Futex_Wake_Bitset_Type :: distinct Futex_Op
  137. Futex_Wait_requeue_Pi_Type :: distinct Futex_Op
  138. Futex_Cmp_requeue_Pi_Type :: distinct Futex_Op
  139. Futex_Lock_Pi2_Type :: distinct Futex_Op
  140. /// Wait on futex wakeup signal
  141. FUTEX_WAIT :: Futex_Wait_Type(.WAIT)
  142. /// Wake up other processes waiting on the futex
  143. FUTEX_WAKE :: Futex_Wake_Type(.WAKE)
  144. /// Not implemented. Basically, since
  145. FUTEX_FD :: Futex_Fd_Type(.FD)
  146. /// Requeue waiters from one futex to another
  147. FUTEX_REQUEUE :: Futex_Requeue_Type(.REQUEUE)
  148. /// Requeue waiters from one futex to another if the value at mutex matches
  149. FUTEX_CMP_REQUEUE :: Futex_Cmp_Requeue_Type(.CMP_REQUEUE)
  150. /// See man pages, I'm not describing it here
  151. FUTEX_WAKE_OP :: Futex_Wake_Op_Type(.WAKE_OP)
  152. /// Wait on a futex, but the value is a bitset
  153. FUTEX_WAIT_BITSET :: Futex_Wait_Bitset_Type(.WAIT_BITSET)
  154. /// Wait on a futex, but the value is a bitset
  155. FUTEX_WAKE_BITSET :: Futex_Wake_Bitset_Type(.WAKE_BITSET)
  156. // TODO(flysand): Priority inversion futexes
  157. FUTEX_LOCK_PI :: Futex_Lock_Pi_Type(.LOCK_PI)
  158. FUTEX_UNLOCK_PI :: Futex_Unlock_Pi_Type(.UNLOCK_PI)
  159. FUTEX_TRYLOCK_PI :: Futex_Trylock_Pi_Type(.TRYLOCK_PI)
  160. FUTEX_WAIT_REQUEUE_PI :: Futex_Wait_requeue_Pi_Type(.WAIT_REQUEUE_PI)
  161. FUTEX_CMP_REQUEUE_PI :: Futex_Cmp_requeue_Pi_Type(.CMP_REQUEUE_PI)
  162. FUTEX_LOCK_PI2 :: Futex_Lock_Pi2_Type(.LOCK_PI2)