linux_types.h 2.7 KB

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