linux_types.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #ifndef __LINUX_TYPES_H__
  2. #define __LINUX_TYPES_H__
  3. #include <linux/socket.h>
  4. #include <linux/time.h>
  5. #define __timespec_defined
  6. #undef __USE_POSIX199309
  7. #include <asm/fcntl.h>
  8. #include <asm/posix_types.h>
  9. #include <asm/stat.h>
  10. #include <linux/poll.h>
  11. #include <linux/sched.h>
  12. #include <sigset.h>
  13. #include <stdint.h>
  14. #ifndef size_t
  15. typedef __kernel_size_t size_t;
  16. #endif
  17. struct linux_dirent64 {
  18. unsigned long d_ino;
  19. unsigned long d_off;
  20. unsigned short d_reclen;
  21. unsigned char d_type;
  22. char d_name[];
  23. };
  24. #define DT_UNKNOWN 0
  25. #define DT_FIFO 1
  26. #define DT_CHR 2
  27. #define DT_DIR 4
  28. #define DT_BLK 6
  29. #define DT_REG 8
  30. #define DT_LNK 10
  31. #define DT_SOCK 12
  32. #define DT_WHT 14
  33. typedef unsigned short int sa_family_t;
  34. struct sockaddr {
  35. sa_family_t sa_family;
  36. char sa_data[128 - sizeof(unsigned short)];
  37. };
  38. #ifndef AF_UNIX
  39. #define AF_UNIX 1
  40. #endif
  41. #ifndef AF_INET
  42. #define AF_INET 2
  43. #endif
  44. #ifndef AF_INET6
  45. #define AF_INET6 10
  46. #endif
  47. #ifndef SOCK_STREAM
  48. #define SOCK_STREAM 1
  49. #endif
  50. #ifndef SOCK_DGRAM
  51. #define SOCK_DGRAM 2
  52. #endif
  53. #ifndef SOCK_NONBLOCK
  54. #define SOCK_NONBLOCK 04000
  55. #endif
  56. #ifndef SOCK_CLOEXEC
  57. #define SOCK_CLOEXEC 02000000
  58. #endif
  59. #ifndef MSG_NOSIGNAL
  60. #define MSG_NOSIGNAL 0x4000
  61. #endif
  62. #ifndef SHUT_RD
  63. #define SHUT_RD 0
  64. #endif
  65. #ifndef SHUT_WR
  66. #define SHUT_WR 1
  67. #endif
  68. #ifndef SHUT_RDWR
  69. #define SHUT_RDWR 2
  70. #endif
  71. typedef unsigned int socklen_t;
  72. struct msghdr {
  73. void* msg_name;
  74. socklen_t msg_namelen;
  75. struct iovec* msg_iov;
  76. size_t msg_iovlen;
  77. void* msg_control;
  78. size_t msg_controllen;
  79. int msg_flags;
  80. };
  81. struct cmsghdr {
  82. size_t cmsg_len;
  83. int cmsg_level;
  84. int cmsg_type;
  85. };
  86. #ifndef SCM_RIGHTS
  87. #define SCM_RIGHTS 1
  88. #endif
  89. #define CMSG_DATA(cmsg) ((unsigned char*)((struct cmsghdr*)(cmsg) + 1))
  90. #define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr(mhdr, cmsg)
  91. #define CMSG_FIRSTHDR(mhdr) \
  92. ((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) \
  93. ? (struct cmsghdr*)(mhdr)->msg_control \
  94. : (struct cmsghdr*)0)
  95. #define CMSG_ALIGN(len) ALIGN_UP(len, sizeof(size_t))
  96. #define CMSG_SPACE(len) (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr)))
  97. #define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
  98. #include <linux/uio.h>
  99. struct sockopt {
  100. int receivebuf, sendbuf;
  101. int receivetimeout, sendtimeout;
  102. int linger;
  103. int reuseaddr : 1;
  104. int tcp_cork : 1;
  105. int tcp_keepalive : 1;
  106. int tcp_nodelay : 1;
  107. };
  108. #endif