posix_types.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifdef RT_USING_LWIP
  61. #include <lwip/arch.h>
  62. #else
  63. #define EPERM 1 /* Operation not permitted */
  64. #define ENOENT 2 /* No such file or directory */
  65. #define ESRCH 3 /* No such process */
  66. #define EINTR 4 /* Interrupted system call */
  67. #define EBADF 9 /* Bad file number */
  68. #define EAGAIN 11 /* Try again */
  69. #define ENOMEM 12 /* Out of memory */
  70. #define EBUSY 16 /* Device or resource busy */
  71. #define EEXIST 17 /* File exists */
  72. #define EINVAL 22 /* Invalid argument */
  73. #define ENFILE 23 /* File table overflow */
  74. #define EDEADLK 45 /* Resource deadlock would occur */
  75. #define EBADMSG 77 /* Not a data message */
  76. #define ENOSYS 89 /* Function not implemented */
  77. #define EOPNOTSUPP 122 /* Operation not supported on transport endpoint */
  78. #define ETIMEDOUT 145 /* Connection timed out */
  79. #endif
  80. #ifdef RT_USING_DFS
  81. #include <dfs_posix.h>
  82. #else
  83. typedef rt_uint16_t mode_t;
  84. #define O_RDONLY 0x0000000
  85. #define O_WRONLY 0x0000001
  86. #define O_RDWR 0x0000002
  87. #define O_ACCMODE 0x0000003
  88. #define O_CREAT 0x0000100
  89. #define O_EXCL 0x0000200
  90. #define O_TRUNC 0x0001000
  91. #define O_APPEND 0x0002000
  92. #define O_DIRECTORY 0x0200000
  93. #endif
  94. #elif defined (__GNUC__) /* GNU GCC Compiler, with minilibc */
  95. #include <sys/time.h>
  96. #include <sys/types.h>
  97. #include <sys/stat.h>
  98. #include <errno.h>
  99. #endif
  100. #endif
  101. #endif