posix_types.h 9.6 KB

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