UnixTypes.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. #pragma once
  2. extern "C" {
  3. namespace Unix {
  4. #define SEEK_SET 0
  5. #define SEEK_CUR 1
  6. #define SEEK_END 2
  7. #define MAP_SHARED 0x01
  8. #define MAP_PRIVATE 0x02
  9. #define MAP_FIXED 0x10
  10. #define MAP_ANONYMOUS 0x20
  11. #define MAP_ANON MAP_ANONYMOUS
  12. #define PROT_READ 0x1
  13. #define PROT_WRITE 0x2
  14. #define PROT_EXEC 0x4
  15. #define PROT_NONE 0x0
  16. #define F_DUPFD 0
  17. #define F_GETFD 1
  18. #define F_SETFD 2
  19. #define F_GETFL 3
  20. #define F_SETFL 4
  21. /* c_cc characters */
  22. #define VINTR 0
  23. #define VQUIT 1
  24. #define VERASE 2
  25. #define VKILL 3
  26. #define VEOF 4
  27. #define VTIME 5
  28. #define VMIN 6
  29. #define VSWTC 7
  30. #define VSTART 8
  31. #define VSTOP 9
  32. #define VSUSP 10
  33. #define VEOL 11
  34. #define VREPRINT 12
  35. #define VDISCARD 13
  36. #define VWERASE 14
  37. #define VLNEXT 15
  38. #define VEOL2 16
  39. /* c_iflag bits */
  40. #define IGNBRK 0000001
  41. #define BRKINT 0000002
  42. #define IGNPAR 0000004
  43. #define PARMRK 0000010
  44. #define INPCK 0000020
  45. #define ISTRIP 0000040
  46. #define INLCR 0000100
  47. #define IGNCR 0000200
  48. #define ICRNL 0000400
  49. #define IUCLC 0001000
  50. #define IXON 0002000
  51. #define IXANY 0004000
  52. #define IXOFF 0010000
  53. #define IMAXBEL 0020000
  54. #define IUTF8 0040000
  55. /* c_oflag bits */
  56. #define OPOST 0000001
  57. #define OLCUC 0000002
  58. #define ONLCR 0000004
  59. #define OCRNL 0000010
  60. #define ONOCR 0000020
  61. #define ONLRET 0000040
  62. #define OFILL 0000100
  63. #define OFDEL 0000200
  64. #if defined __USE_MISC || defined __USE_XOPEN
  65. # define NLDLY 0000400
  66. # define NL0 0000000
  67. # define NL1 0000400
  68. # define CRDLY 0003000
  69. # define CR0 0000000
  70. # define CR1 0001000
  71. # define CR2 0002000
  72. # define CR3 0003000
  73. # define TABDLY 0014000
  74. # define TAB0 0000000
  75. # define TAB1 0004000
  76. # define TAB2 0010000
  77. # define TAB3 0014000
  78. # define BSDLY 0020000
  79. # define BS0 0000000
  80. # define BS1 0020000
  81. # define FFDLY 0100000
  82. # define FF0 0000000
  83. # define FF1 0100000
  84. #endif
  85. #define VTDLY 0040000
  86. #define VT0 0000000
  87. #define VT1 0040000
  88. #ifdef __USE_MISC
  89. # define XTABS 0014000
  90. #endif
  91. /* c_cflag bit meaning */
  92. #ifdef __USE_MISC
  93. # define CBAUD 0010017
  94. #endif
  95. #define B0 0000000 /* hang up */
  96. #define B50 0000001
  97. #define B75 0000002
  98. #define B110 0000003
  99. #define B134 0000004
  100. #define B150 0000005
  101. #define B200 0000006
  102. #define B300 0000007
  103. #define B600 0000010
  104. #define B1200 0000011
  105. #define B1800 0000012
  106. #define B2400 0000013
  107. #define B4800 0000014
  108. #define B9600 0000015
  109. #define B19200 0000016
  110. #define B38400 0000017
  111. #ifdef __USE_MISC
  112. # define EXTA B19200
  113. # define EXTB B38400
  114. #endif
  115. #define CSIZE 0000060
  116. #define CS5 0000000
  117. #define CS6 0000020
  118. #define CS7 0000040
  119. #define CS8 0000060
  120. #define CSTOPB 0000100
  121. #define CREAD 0000200
  122. #define PARENB 0000400
  123. #define PARODD 0001000
  124. #define HUPCL 0002000
  125. #define CLOCAL 0004000
  126. #ifdef __USE_MISC
  127. # define CBAUDEX 0010000
  128. #endif
  129. #define B57600 0010001
  130. #define B115200 0010002
  131. #define B230400 0010003
  132. #define B460800 0010004
  133. #define B500000 0010005
  134. #define B576000 0010006
  135. #define B921600 0010007
  136. #define B1000000 0010010
  137. #define B1152000 0010011
  138. #define B1500000 0010012
  139. #define B2000000 0010013
  140. #define B2500000 0010014
  141. #define B3000000 0010015
  142. #define B3500000 0010016
  143. #define B4000000 0010017
  144. #define __MAX_BAUD B4000000
  145. #ifdef __USE_MISC
  146. # define CIBAUD 002003600000 /* input baud rate (not used) */
  147. # define CMSPAR 010000000000 /* mark or space (stick) parity */
  148. # define CRTSCTS 020000000000 /* flow control */
  149. #endif
  150. /* c_lflag bits */
  151. #define ISIG 0000001
  152. #define ICANON 0000002
  153. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  154. # define XCASE 0000004
  155. #endif
  156. #define ECHO 0000010
  157. #define ECHOE 0000020
  158. #define ECHOK 0000040
  159. #define ECHONL 0000100
  160. #define NOFLSH 0000200
  161. #define TOSTOP 0000400
  162. #ifdef __USE_MISC
  163. # define ECHOCTL 0001000
  164. # define ECHOPRT 0002000
  165. # define ECHOKE 0004000
  166. # define FLUSHO 0010000
  167. # define PENDIN 0040000
  168. #endif
  169. #define IEXTEN 0100000
  170. #ifdef __USE_MISC
  171. # define EXTPROC 0200000
  172. #endif
  173. /* tcflow() and TCXONC use these */
  174. #define TCOOFF 0
  175. #define TCOON 1
  176. #define TCIOFF 2
  177. #define TCION 3
  178. /* tcflush() and TCFLSH use these */
  179. #define TCIFLUSH 0
  180. #define TCOFLUSH 1
  181. #define TCIOFLUSH 2
  182. /* tcsetattr uses these */
  183. #define TCSANOW 0
  184. #define TCSADRAIN 1
  185. #define TCSAFLUSH 2
  186. typedef dword dev_t;
  187. typedef dword ino_t;
  188. typedef dword mode_t;
  189. typedef dword nlink_t;
  190. typedef dword uid_t;
  191. typedef dword gid_t;
  192. #ifdef SERENITY
  193. typedef void (*__sighandler_t)(int);
  194. typedef __sighandler_t sighandler_t;
  195. typedef dword sigset_t;
  196. typedef void siginfo_t;
  197. struct sigaction {
  198. union {
  199. void (*sa_handler)(int);
  200. void (*sa_sigaction)(int, siginfo_t*, void*);
  201. };
  202. sigset_t sa_mask;
  203. int sa_flags;
  204. void (*sa_restorer)(void);
  205. };
  206. #define SA_NOCLDSTOP 1
  207. #define SA_NOCLDWAIT 2
  208. #define SA_SIGINFO 4
  209. #define SIG_BLOCK 0
  210. #define SIG_UNBLOCK 1
  211. #define SIG_SETMASK 2
  212. #endif
  213. #ifdef SERENITY
  214. // FIXME: Support 64-bit offsets!
  215. typedef signed_dword off_t;
  216. typedef unsigned int time_t;
  217. #else
  218. typedef signed_qword off_t;
  219. typedef ::time_t time_t;
  220. #endif
  221. typedef dword blksize_t;
  222. typedef dword blkcnt_t;
  223. typedef dword size_t;
  224. typedef signed_dword ssize_t;
  225. #define NCCS 32
  226. typedef uint32_t tcflag_t;
  227. typedef uint8_t cc_t;
  228. struct termios {
  229. tcflag_t c_iflag;
  230. tcflag_t c_oflag;
  231. tcflag_t c_cflag;
  232. tcflag_t c_lflag;
  233. cc_t c_cc[NCCS];
  234. };
  235. struct stat {
  236. dev_t st_dev; /* ID of device containing file */
  237. ino_t st_ino; /* inode number */
  238. mode_t st_mode; /* protection */
  239. nlink_t st_nlink; /* number of hard links */
  240. uid_t st_uid; /* user ID of owner */
  241. gid_t st_gid; /* group ID of owner */
  242. dev_t st_rdev; /* device ID (if special file) */
  243. off_t st_size; /* total size, in bytes */
  244. blksize_t st_blksize; /* blocksize for file system I/O */
  245. blkcnt_t st_blocks; /* number of 512B blocks allocated */
  246. time_t st_atime; /* time of last access */
  247. time_t st_mtime; /* time of last modification */
  248. time_t st_ctime; /* time of last status change */
  249. };
  250. }
  251. }