UnixTypes.h 5.9 KB

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