UnixTypes.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. #pragma once
  2. #include <AK/Types.h>
  3. #define WNOHANG 1
  4. #define R_OK 4
  5. #define W_OK 2
  6. #define X_OK 1
  7. #define F_OK 0
  8. #define SIG_DFL ((void*)0)
  9. #define SIG_ERR ((void*)-1)
  10. #define SIG_IGN ((void*)1)
  11. #define SEEK_SET 0
  12. #define SEEK_CUR 1
  13. #define SEEK_END 2
  14. #define MAP_SHARED 0x01
  15. #define MAP_PRIVATE 0x02
  16. #define MAP_FIXED 0x10
  17. #define MAP_ANONYMOUS 0x20
  18. #define MAP_ANON MAP_ANONYMOUS
  19. #define PROT_READ 0x1
  20. #define PROT_WRITE 0x2
  21. #define PROT_EXEC 0x4
  22. #define PROT_NONE 0x0
  23. #define F_DUPFD 0
  24. #define F_GETFD 1
  25. #define F_SETFD 2
  26. #define F_GETFL 3
  27. #define F_SETFL 4
  28. #define FD_CLOEXEC 1
  29. /* c_cc characters */
  30. #define VINTR 0
  31. #define VQUIT 1
  32. #define VERASE 2
  33. #define VKILL 3
  34. #define VEOF 4
  35. #define VTIME 5
  36. #define VMIN 6
  37. #define VSWTC 7
  38. #define VSTART 8
  39. #define VSTOP 9
  40. #define VSUSP 10
  41. #define VEOL 11
  42. #define VREPRINT 12
  43. #define VDISCARD 13
  44. #define VWERASE 14
  45. #define VLNEXT 15
  46. #define VEOL2 16
  47. /* c_iflag bits */
  48. #define IGNBRK 0000001
  49. #define BRKINT 0000002
  50. #define IGNPAR 0000004
  51. #define PARMRK 0000010
  52. #define INPCK 0000020
  53. #define ISTRIP 0000040
  54. #define INLCR 0000100
  55. #define IGNCR 0000200
  56. #define ICRNL 0000400
  57. #define IUCLC 0001000
  58. #define IXON 0002000
  59. #define IXANY 0004000
  60. #define IXOFF 0010000
  61. #define IMAXBEL 0020000
  62. #define IUTF8 0040000
  63. /* c_oflag bits */
  64. #define OPOST 0000001
  65. #define OLCUC 0000002
  66. #define ONLCR 0000004
  67. #define OCRNL 0000010
  68. #define ONOCR 0000020
  69. #define ONLRET 0000040
  70. #define OFILL 0000100
  71. #define OFDEL 0000200
  72. #if defined __USE_MISC || defined __USE_XOPEN
  73. # define NLDLY 0000400
  74. # define NL0 0000000
  75. # define NL1 0000400
  76. # define CRDLY 0003000
  77. # define CR0 0000000
  78. # define CR1 0001000
  79. # define CR2 0002000
  80. # define CR3 0003000
  81. # define TABDLY 0014000
  82. # define TAB0 0000000
  83. # define TAB1 0004000
  84. # define TAB2 0010000
  85. # define TAB3 0014000
  86. # define BSDLY 0020000
  87. # define BS0 0000000
  88. # define BS1 0020000
  89. # define FFDLY 0100000
  90. # define FF0 0000000
  91. # define FF1 0100000
  92. #endif
  93. #define VTDLY 0040000
  94. #define VT0 0000000
  95. #define VT1 0040000
  96. #ifdef __USE_MISC
  97. # define XTABS 0014000
  98. #endif
  99. /* c_cflag bit meaning */
  100. #ifdef __USE_MISC
  101. # define CBAUD 0010017
  102. #endif
  103. #define B0 0000000 /* hang up */
  104. #define B50 0000001
  105. #define B75 0000002
  106. #define B110 0000003
  107. #define B134 0000004
  108. #define B150 0000005
  109. #define B200 0000006
  110. #define B300 0000007
  111. #define B600 0000010
  112. #define B1200 0000011
  113. #define B1800 0000012
  114. #define B2400 0000013
  115. #define B4800 0000014
  116. #define B9600 0000015
  117. #define B19200 0000016
  118. #define B38400 0000017
  119. #ifdef __USE_MISC
  120. # define EXTA B19200
  121. # define EXTB B38400
  122. #endif
  123. #define CSIZE 0000060
  124. #define CS5 0000000
  125. #define CS6 0000020
  126. #define CS7 0000040
  127. #define CS8 0000060
  128. #define CSTOPB 0000100
  129. #define CREAD 0000200
  130. #define PARENB 0000400
  131. #define PARODD 0001000
  132. #define HUPCL 0002000
  133. #define CLOCAL 0004000
  134. #ifdef __USE_MISC
  135. # define CBAUDEX 0010000
  136. #endif
  137. #define B57600 0010001
  138. #define B115200 0010002
  139. #define B230400 0010003
  140. #define B460800 0010004
  141. #define B500000 0010005
  142. #define B576000 0010006
  143. #define B921600 0010007
  144. #define B1000000 0010010
  145. #define B1152000 0010011
  146. #define B1500000 0010012
  147. #define B2000000 0010013
  148. #define B2500000 0010014
  149. #define B3000000 0010015
  150. #define B3500000 0010016
  151. #define B4000000 0010017
  152. #define __MAX_BAUD B4000000
  153. #ifdef __USE_MISC
  154. # define CIBAUD 002003600000 /* input baud rate (not used) */
  155. # define CMSPAR 010000000000 /* mark or space (stick) parity */
  156. # define CRTSCTS 020000000000 /* flow control */
  157. #endif
  158. /* c_lflag bits */
  159. #define ISIG 0000001
  160. #define ICANON 0000002
  161. #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
  162. # define XCASE 0000004
  163. #endif
  164. #define ECHO 0000010
  165. #define ECHOE 0000020
  166. #define ECHOK 0000040
  167. #define ECHONL 0000100
  168. #define NOFLSH 0000200
  169. #define TOSTOP 0000400
  170. #ifdef __USE_MISC
  171. # define ECHOCTL 0001000
  172. # define ECHOPRT 0002000
  173. # define ECHOKE 0004000
  174. # define FLUSHO 0010000
  175. # define PENDIN 0040000
  176. #endif
  177. #define IEXTEN 0100000
  178. #ifdef __USE_MISC
  179. # define EXTPROC 0200000
  180. #endif
  181. /* tcflow() and TCXONC use these */
  182. #define TCOOFF 0
  183. #define TCOON 1
  184. #define TCIOFF 2
  185. #define TCION 3
  186. /* tcflush() and TCFLSH use these */
  187. #define TCIFLUSH 0
  188. #define TCOFLUSH 1
  189. #define TCIOFLUSH 2
  190. /* tcsetattr uses these */
  191. #define TCSANOW 0
  192. #define TCSADRAIN 1
  193. #define TCSAFLUSH 2
  194. struct winsize {
  195. unsigned short ws_row;
  196. unsigned short ws_col;
  197. };
  198. typedef dword dev_t;
  199. typedef dword ino_t;
  200. typedef word mode_t;
  201. typedef dword nlink_t;
  202. typedef dword uid_t;
  203. typedef dword gid_t;
  204. typedef dword clock_t;
  205. typedef dword socklen_t;
  206. typedef int pid_t;
  207. struct tms {
  208. clock_t tms_utime;
  209. clock_t tms_stime;
  210. clock_t tms_cutime;
  211. clock_t tms_cstime;
  212. };
  213. typedef void (*__sighandler_t)(int);
  214. typedef __sighandler_t sighandler_t;
  215. typedef dword sigset_t;
  216. typedef void siginfo_t;
  217. struct sigaction {
  218. union {
  219. void (*sa_handler)(int);
  220. void (*sa_sigaction)(int, siginfo_t*, void*);
  221. };
  222. sigset_t sa_mask;
  223. int sa_flags;
  224. };
  225. #define SA_NOCLDSTOP 1
  226. #define SA_NOCLDWAIT 2
  227. #define SA_SIGINFO 4
  228. #define SA_NODEFER 0x40000000
  229. #define SIG_BLOCK 0
  230. #define SIG_UNBLOCK 1
  231. #define SIG_SETMASK 2
  232. #define OFF_T_MAX 2147483647
  233. typedef signed_dword off_t;
  234. typedef dword time_t;
  235. struct utimbuf {
  236. time_t actime;
  237. time_t modtime;
  238. };
  239. typedef dword blksize_t;
  240. typedef dword blkcnt_t;
  241. #define NCCS 32
  242. typedef uint32_t tcflag_t;
  243. typedef uint8_t cc_t;
  244. typedef uint32_t speed_t;
  245. struct termios {
  246. tcflag_t c_iflag;
  247. tcflag_t c_oflag;
  248. tcflag_t c_cflag;
  249. tcflag_t c_lflag;
  250. cc_t c_cc[NCCS];
  251. speed_t c_ispeed;
  252. speed_t c_ospeed;
  253. };
  254. struct stat {
  255. dev_t st_dev; /* ID of device containing file */
  256. ino_t st_ino; /* inode number */
  257. mode_t st_mode; /* protection */
  258. nlink_t st_nlink; /* number of hard links */
  259. uid_t st_uid; /* user ID of owner */
  260. gid_t st_gid; /* group ID of owner */
  261. dev_t st_rdev; /* device ID (if special file) */
  262. off_t st_size; /* total size, in bytes */
  263. blksize_t st_blksize; /* blocksize for file system I/O */
  264. blkcnt_t st_blocks; /* number of 512B blocks allocated */
  265. time_t st_atime; /* time of last access */
  266. time_t st_mtime; /* time of last modification */
  267. time_t st_ctime; /* time of last status change */
  268. };
  269. #define POLLIN (1u << 0)
  270. #define POLLPRI (1u << 2)
  271. #define POLLOUT (1u << 3)
  272. #define POLLERR (1u << 4)
  273. #define POLLHUP (1u << 5)
  274. #define POLLNVAL (1u << 6)
  275. struct pollfd {
  276. int fd;
  277. short events;
  278. short revents;
  279. };
  280. #define AF_MASK 0xff
  281. #define AF_UNSPEC 0
  282. #define AF_LOCAL 1
  283. #define AF_INET 2
  284. #define PF_LOCAL AF_LOCAL
  285. #define PF_INET AF_INET
  286. #define SOCK_TYPE_MASK 0xff
  287. #define SOCK_STREAM 1
  288. #define SOCK_RAW 3
  289. #define SOCK_DGRAM 2
  290. #define SOCK_NONBLOCK 04000
  291. #define SOCK_CLOEXEC 02000000
  292. #define MSG_DONTWAIT 0x40
  293. #define SOL_SOCKET 1
  294. #define SO_RCVTIMEO 1
  295. #define SO_SNDTIMEO 2
  296. #define IPPROTO_ICMP 1
  297. #define IPPROTO_TCP 6
  298. #define IPPROTO_UDP 17
  299. struct sockaddr {
  300. word sa_family;
  301. char sa_data[14];
  302. };
  303. #define S_IFSOCK 0140000
  304. #define UNIX_PATH_MAX 108
  305. struct sockaddr_un {
  306. word sun_family;
  307. char sun_path[UNIX_PATH_MAX];
  308. };
  309. struct in_addr {
  310. uint32_t s_addr;
  311. };
  312. struct sockaddr_in {
  313. int16_t sin_family;
  314. uint16_t sin_port;
  315. struct in_addr sin_addr;
  316. char sin_zero[8];
  317. };
  318. typedef dword __u32;
  319. typedef word __u16;
  320. typedef byte __u8;
  321. typedef int __s32;
  322. typedef short __s16;
  323. typedef dword useconds_t;
  324. typedef signed_dword suseconds_t;
  325. struct timeval {
  326. time_t tv_sec;
  327. suseconds_t tv_usec;
  328. };
  329. #define UTSNAME_ENTRY_LEN 65
  330. struct utsname {
  331. char sysname[UTSNAME_ENTRY_LEN];
  332. char nodename[UTSNAME_ENTRY_LEN];
  333. char release[UTSNAME_ENTRY_LEN];
  334. char version[UTSNAME_ENTRY_LEN];
  335. char machine[UTSNAME_ENTRY_LEN];
  336. };
  337. struct [[gnu::packed]] FarPtr {
  338. dword offset { 0 };
  339. word selector { 0 };
  340. };
  341. struct iovec {
  342. void* iov_base;
  343. size_t iov_len;
  344. };