posix_types.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #ifndef __POSIX_TYPES_H__
  2. #define __POSIX_TYPES_H__
  3. #include <rtthread.h>
  4. /* compatible in different compiler and C runtime library */
  5. #ifdef RT_USING_NEWLIB
  6. /* normarlly, GNU GCC will use newlib as C runtime library */
  7. #include <sys/types.h>
  8. #include <sys/time.h>
  9. #include <sys/signal.h>
  10. #include <sys/fcntl.h>
  11. #include <errno.h>
  12. #include <stdarg.h>
  13. #else
  14. /* ARM compiler and IAR compiler */
  15. #if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)
  16. #include <stddef.h>
  17. #include <stdarg.h>
  18. #include <string.h>
  19. typedef rt_int32_t clockid_t;
  20. typedef rt_int32_t key_t; /* Used for interprocess communication. */
  21. typedef rt_int32_t pid_t; /* Used for process IDs and process group IDs. */
  22. typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */
  23. typedef signed long time_t; /* Used for time in seconds. */
  24. struct timespec {
  25. time_t tv_sec; /* seconds */
  26. long tv_nsec; /* nanoseconds */
  27. };
  28. struct timeval {
  29. long tv_sec; /* seconds */
  30. long tv_usec; /* microseconds */
  31. };
  32. /* errno definitions */
  33. #define EPERM 1 /* Operation not permitted */
  34. #define ENOENT 2 /* No such file or directory */
  35. #define ESRCH 3 /* No such process */
  36. #define EINTR 4 /* Interrupted system call */
  37. #define EIO 5 /* I/O error */
  38. #define ENXIO 6 /* No such device or address */
  39. #define E2BIG 7 /* Arg list too long */
  40. #define ENOEXEC 8 /* Exec format error */
  41. #define EBADF 9 /* Bad file number */
  42. #define ECHILD 10 /* No child processes */
  43. #define EAGAIN 11 /* Try again */
  44. #define ENOMEM 12 /* Out of memory */
  45. #define EACCES 13 /* Permission denied */
  46. #define EFAULT 14 /* Bad address */
  47. #define ENOTBLK 15 /* Block device required */
  48. #define EBUSY 16 /* Device or resource busy */
  49. #define EEXIST 17 /* File exists */
  50. #define EXDEV 18 /* Cross-device link */
  51. #define ENODEV 19 /* No such device */
  52. #define ENOTDIR 20 /* Not a directory */
  53. #define EISDIR 21 /* Is a directory */
  54. #define EINVAL 22 /* Invalid argument */
  55. #define ENFILE 23 /* File table overflow */
  56. #define EMFILE 24 /* Too many open files */
  57. #define ENOTTY 25 /* Not a typewriter */
  58. #define ETXTBSY 26 /* Text file busy */
  59. #define EFBIG 27 /* File too large */
  60. #define ENOSPC 28 /* No space left on device */
  61. #define ESPIPE 29 /* Illegal seek */
  62. #define EROFS 30 /* Read-only file system */
  63. #define EMLINK 31 /* Too many links */
  64. #define EPIPE 32 /* Broken pipe */
  65. #define EDOM 33 /* Math argument out of domain of func */
  66. #define ERANGE 34 /* Math result not representable */
  67. #define ENOMSG 35 /* No message of desired type */
  68. #define EIDRM 36 /* Identifier removed */
  69. #define ECHRNG 37 /* Channel number out of range */
  70. #define EL2NSYNC 38 /* Level 2 not synchronized */
  71. #define EL3HLT 39 /* Level 3 halted */
  72. #define EL3RST 40 /* Level 3 reset */
  73. #define ELNRNG 41 /* Link number out of range */
  74. #define EUNATCH 42 /* Protocol driver not attached */
  75. #define ENOCSI 43 /* No CSI structure available */
  76. #define EL2HLT 44 /* Level 2 halted */
  77. #define EDEADLK 45 /* Resource deadlock would occur */
  78. #define ENOLCK 46 /* No record locks available */
  79. #define EBADE 50 /* Invalid exchange */
  80. #define EBADR 51 /* Invalid request descriptor */
  81. #define EXFULL 52 /* Exchange full */
  82. #define ENOANO 53 /* No anode */
  83. #define EBADRQC 54 /* Invalid request code */
  84. #define EBADSLT 55 /* Invalid slot */
  85. #define EDEADLOCK 56 /* File locking deadlock error */
  86. #define EBFONT 59 /* Bad font file format */
  87. #define ENOSTR 60 /* Device not a stream */
  88. #define ENODATA 61 /* No data available */
  89. #define ETIME 62 /* Timer expired */
  90. #define ENOSR 63 /* Out of streams resources */
  91. #define ENONET 64 /* Machine is not on the network */
  92. #define ENOPKG 65 /* Package not installed */
  93. #define EREMOTE 66 /* Object is remote */
  94. #define ENOLINK 67 /* Link has been severed */
  95. #define EADV 68 /* Advertise error */
  96. #define ESRMNT 69 /* Srmount error */
  97. #define ECOMM 70 /* Communication error on send */
  98. #define EPROTO 71 /* Protocol error */
  99. #define EDOTDOT 73 /* RFS specific error */
  100. #define EMULTIHOP 74 /* Multihop attempted */
  101. #define EBADMSG 77 /* Not a data message */
  102. #define ENAMETOOLONG 78 /* File name too long */
  103. #define EOVERFLOW 79 /* Value too large for defined data type */
  104. #define ENOTUNIQ 80 /* Name not unique on network */
  105. #define EBADFD 81 /* File descriptor in bad state */
  106. #define EREMCHG 82 /* Remote address changed */
  107. #define ELIBACC 83 /* Can not access a needed shared library */
  108. #define ELIBBAD 84 /* Accessing a corrupted shared library */
  109. #define ELIBSCN 85 /* .lib section in a.out corrupted */
  110. #define ELIBMAX 86 /* Attempting to link in too many shared libraries */
  111. #define ELIBEXEC 87 /* Cannot exec a shared library directly */
  112. #define EILSEQ 88 /* Illegal byte sequence */
  113. #define ENOSYS 89 /* Function not implemented */
  114. #define ELOOP 90 /* Too many symbolic links encountered */
  115. #define ERESTART 91 /* Interrupted system call should be restarted */
  116. #define ESTRPIPE 92 /* Streams pipe error */
  117. #define ENOTEMPTY 93 /* Directory not empty */
  118. #define EUSERS 94 /* Too many users */
  119. #define ENOTSOCK 95 /* Socket operation on non-socket */
  120. #define EDESTADDRREQ 96 /* Destination address required */
  121. #define EMSGSIZE 97 /* Message too long */
  122. #define EPROTOTYPE 98 /* Protocol wrong type for socket */
  123. #define ENOPROTOOPT 99 /* Protocol not available */
  124. #define EPROTONOSUPPORT 120 /* Protocol not supported */
  125. #define ESOCKTNOSUPPORT 121 /* Socket type not supported */
  126. #define EOPNOTSUPP 122 /* Operation not supported on transport endpoint */
  127. #define ENOTSUP EOPNOTSUPP/* Operation not supported on transport endpoint */
  128. #define EPFNOSUPPORT 123 /* Protocol family not supported */
  129. #define EAFNOSUPPORT 124 /* Address family not supported by protocol */
  130. #define EADDRINUSE 125 /* Address already in use */
  131. #define EADDRNOTAVAIL 126 /* Cannot assign requested address */
  132. #define ENETDOWN 127 /* Network is down */
  133. #define ENETUNREACH 128 /* Network is unreachable */
  134. #define ENETRESET 129 /* Network dropped connection because of reset */
  135. #define ECONNABORTED 130 /* Software caused connection abort */
  136. #define ECONNRESET 131 /* Connection reset by peer */
  137. #define ENOBUFS 132 /* No buffer space available */
  138. #define EISCONN 133 /* Transport endpoint is already connected */
  139. #define ENOTCONN 134 /* Transport endpoint is not connected */
  140. #define EUCLEAN 135 /* Structure needs cleaning */
  141. #define ENOTNAM 137 /* Not a XENIX named type file */
  142. #define ENAVAIL 138 /* No XENIX semaphores available */
  143. #define EISNAM 139 /* Is a named type file */
  144. #define EREMOTEIO 140 /* Remote I/O error */
  145. #define EINIT 141 /* Reserved */
  146. #define EREMDEV 142 /* Error 142 */
  147. #define ESHUTDOWN 143 /* Cannot send after transport endpoint shutdown */
  148. #define ETOOMANYREFS 144 /* Too many references: cannot splice */
  149. #define ETIMEDOUT 145 /* Connection timed out */
  150. #define ECONNREFUSED 146 /* Connection refused */
  151. #define EHOSTDOWN 147 /* Host is down */
  152. #define EHOSTUNREACH 148 /* No route to host */
  153. #define EWOULDBLOCK EAGAIN /* Operation would block */
  154. #define EALREADY 149 /* Operation already in progress */
  155. #define EINPROGRESS 150 /* Operation now in progress */
  156. #define ESTALE 151 /* Stale NFS file handle */
  157. #define ECANCELED 158 /* AIO operation canceled */
  158. #define ENOMEDIUM 159 /* No medium found */
  159. #define EMEDIUMTYPE 160 /* Wrong medium type */
  160. #define ENOKEY 161 /* Required key not available */
  161. #define EKEYEXPIRED 162 /* Key has expired */
  162. #define EKEYREVOKED 163 /* Key has been revoked */
  163. #define EKEYREJECTED 164 /* Key was rejected by service */
  164. #define EDQUOT 1133 /* Quota exceeded */
  165. #ifdef RT_USING_DFS
  166. #include <dfs_posix.h>
  167. #else
  168. typedef rt_uint16_t mode_t;
  169. #define O_RDONLY 0x0000000
  170. #define O_WRONLY 0x0000001
  171. #define O_RDWR 0x0000002
  172. #define O_ACCMODE 0x0000003
  173. #define O_CREAT 0x0000100
  174. #define O_EXCL 0x0000200
  175. #define O_TRUNC 0x0001000
  176. #define O_APPEND 0x0002000
  177. #define O_DIRECTORY 0x0200000
  178. #endif
  179. #elif defined (__GNUC__) /* GNU GCC Compiler, with minilibc */
  180. #endif
  181. #endif
  182. #endif