UnixTypes.h 6.3 KB

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