/include/posix.h

https://github.com/phoenix-rtos/phoenix-rtos-kernel · C Header · 182 lines · 130 code · 38 blank · 14 comment · 7 complexity · c41a15fde88991f869a857b3ca4e5d9f MD5 · raw file

  1. /*
  2. * Phoenix-RTOS
  3. *
  4. * Operating system kernel
  5. *
  6. * POSIX-compatibility definitions
  7. *
  8. * Copyright 2018 Phoenix Systems
  9. * Author: Jan Sikorski
  10. *
  11. * This file is part of Phoenix-RTOS.
  12. *
  13. * %LICENSE%
  14. */
  15. #ifndef _PHOENIX_POSIX_H_
  16. #define _PHOENIX_POSIX_H_
  17. enum { F_DUPFD = 0, F_DUPFD_CLOEXEC, F_GETFD, F_SETFD, F_GETFL, F_SETFL,
  18. F_GETOWN, F_SETOWN, F_GETLK, F_SETLK, F_SETLKW };
  19. #define FD_CLOEXEC 1
  20. #define O_RDONLY 0x0001
  21. #define O_WRONLY 0x0002
  22. #define O_RDWR 0x0004
  23. #define O_APPEND 0x0008
  24. #define O_CREAT 0x0100
  25. #define O_TRUNC 0x0200
  26. #define O_EXCL 0x0400
  27. #define O_SYNC 0x0800
  28. #define O_NONBLOCK 0x1000
  29. #define O_NOCTTY 0x2000
  30. #define O_CLOEXEC 0x4000
  31. typedef int ssize_t;
  32. typedef size_t socklen_t;
  33. typedef unsigned short sa_family_t;
  34. struct sockaddr {
  35. sa_family_t sa_family;
  36. char sa_data[14];
  37. };
  38. #define S_IFMT 0170000
  39. #define S_IFIFO 0010000
  40. #define S_IFCHR 0020000
  41. #define S_IFDIR 0040000
  42. #define S_IFBLK 0060000
  43. #define S_IFREG 0100000
  44. #define S_IFLNK 0120000
  45. #define S_IFSOCK 0140000
  46. #define S_BLKSIZE 512
  47. #define S_ISDIR(m) (((m) & (0170000)) == 0040000)
  48. #define S_ISCHR(m) (((m) & (0170000)) == 0020000)
  49. #define S_ISBLK(m) (((m) & (0170000)) == 0060000)
  50. #define S_ISREG(m) (((m) & (0170000)) == 0100000)
  51. #define S_ISFIFO(m) (((m) & (0170000)) == 0010000)
  52. #define S_ISLNK(m) (((m) & (0170000)) == 0120000)
  53. #define S_ISSOCK(m) (((m) & (0170000)) == 0140000)
  54. #define SEEK_SET 0
  55. #define SEEK_CUR 1
  56. #define SEEK_END 2
  57. typedef int dev_t;
  58. typedef int pid_t;
  59. typedef int mode_t;
  60. typedef int gid_t;
  61. typedef int uid_t;
  62. typedef int dev_t;
  63. typedef int ino_t; /* FIXME: should be unsigned long long to encode id_t? */
  64. typedef int nlink_t;
  65. typedef int blksize_t;
  66. typedef long long blkcnt_t;
  67. typedef long long off64_t;
  68. typedef off64_t off_t;
  69. struct stat {
  70. dev_t st_dev;
  71. ino_t st_ino;
  72. mode_t st_mode;
  73. nlink_t st_nlink;
  74. uid_t st_uid;
  75. gid_t st_gid;
  76. dev_t st_rdev;
  77. off_t st_size;
  78. time_t st_atime;
  79. time_t st_mtime;
  80. time_t st_ctime;
  81. blksize_t st_blksize;
  82. blkcnt_t st_blocks;
  83. };
  84. struct timeval {
  85. };
  86. #define AF_UNSPEC 0
  87. #define AF_UNIX 1
  88. #define AF_INET 2
  89. #define AF_INET6 10
  90. #define AF_KEY 15
  91. #define AF_PACKET 17
  92. #define PF_UNSPEC AF_UNSPEC
  93. #define PF_UNIX AF_UNIX
  94. #define PF_INET AF_INET
  95. #define PF_INET6 AF_INET6
  96. #define PF_KEY AF_KEY
  97. #define PF_PACKET AF_PACKET
  98. #define SOCK_STREAM 1
  99. #define SOCK_DGRAM 2
  100. #define SOCK_RAW 3
  101. #define SOCK_SEQPACKET 4
  102. #define SOCK_RDM 5
  103. #define SOL_SOCKET 0xFFF
  104. #define MSG_PEEK 0x01
  105. #define MSG_WAITALL 0x02
  106. #define MSG_OOB 0x04
  107. #define MSG_DONTWAIT 0x08
  108. #define MSG_MORE 0x10
  109. #define SCM_RIGHTS 1
  110. #define POLLIN 0x1
  111. #define POLLRDNORM 0x2
  112. #define POLLRDBAND 0x4
  113. #define POLLPRI 0x8
  114. #define POLLOUT 0x10
  115. #define POLLWRNORM 0x20
  116. #define POLLWRBAND 0x40
  117. #define POLLERR 0x80
  118. #define POLLHUP 0x100
  119. #define POLLNVAL 0x200
  120. typedef unsigned int nfds_t;
  121. struct pollfd {
  122. int fd;
  123. short events;
  124. short revents;
  125. };
  126. struct iovec {
  127. void *iov_base;
  128. size_t iov_len;
  129. };
  130. struct msghdr {
  131. void *msg_name;
  132. socklen_t msg_namelen;
  133. struct iovec *msg_iov;
  134. int msg_iovlen;
  135. void *msg_control;
  136. socklen_t msg_controllen;
  137. int msg_flags;
  138. };
  139. struct cmsghdr {
  140. socklen_t cmsg_len;
  141. int cmsg_level;
  142. int cmsg_type;
  143. };
  144. #endif