Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

284 righe
5.7 KiB

  1. // Copyright 2009 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build ignore
  5. /*
  6. Input to cgo -godefs. See README.md
  7. */
  8. // +godefs map struct_in_addr [4]byte /* in_addr */
  9. // +godefs map struct_in6_addr [16]byte /* in6_addr */
  10. package unix
  11. /*
  12. #define KERNEL
  13. // These defines ensure that builds done on newer versions of Solaris are
  14. // backwards-compatible with older versions of Solaris and
  15. // OpenSolaris-based derivatives.
  16. #define __USE_SUNOS_SOCKETS__ // msghdr
  17. #define __USE_LEGACY_PROTOTYPES__ // iovec
  18. #include <dirent.h>
  19. #include <fcntl.h>
  20. #include <netdb.h>
  21. #include <limits.h>
  22. #include <poll.h>
  23. #include <signal.h>
  24. #include <termios.h>
  25. #include <termio.h>
  26. #include <stdio.h>
  27. #include <unistd.h>
  28. #include <sys/mman.h>
  29. #include <sys/mount.h>
  30. #include <sys/param.h>
  31. #include <sys/resource.h>
  32. #include <sys/select.h>
  33. #include <sys/signal.h>
  34. #include <sys/socket.h>
  35. #include <sys/stat.h>
  36. #include <sys/statvfs.h>
  37. #include <sys/time.h>
  38. #include <sys/times.h>
  39. #include <sys/types.h>
  40. #include <sys/utsname.h>
  41. #include <sys/un.h>
  42. #include <sys/wait.h>
  43. #include <net/bpf.h>
  44. #include <net/if.h>
  45. #include <net/if_dl.h>
  46. #include <net/route.h>
  47. #include <netinet/in.h>
  48. #include <netinet/icmp6.h>
  49. #include <netinet/tcp.h>
  50. #include <ustat.h>
  51. #include <utime.h>
  52. enum {
  53. sizeofPtr = sizeof(void*),
  54. };
  55. union sockaddr_all {
  56. struct sockaddr s1; // this one gets used for fields
  57. struct sockaddr_in s2; // these pad it out
  58. struct sockaddr_in6 s3;
  59. struct sockaddr_un s4;
  60. struct sockaddr_dl s5;
  61. };
  62. struct sockaddr_any {
  63. struct sockaddr addr;
  64. char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
  65. };
  66. */
  67. import "C"
  68. // Machine characteristics; for internal use.
  69. const (
  70. sizeofPtr = C.sizeofPtr
  71. sizeofShort = C.sizeof_short
  72. sizeofInt = C.sizeof_int
  73. sizeofLong = C.sizeof_long
  74. sizeofLongLong = C.sizeof_longlong
  75. PathMax = C.PATH_MAX
  76. MaxHostNameLen = C.MAXHOSTNAMELEN
  77. )
  78. // Basic types
  79. type (
  80. _C_short C.short
  81. _C_int C.int
  82. _C_long C.long
  83. _C_long_long C.longlong
  84. )
  85. // Time
  86. type Timespec C.struct_timespec
  87. type Timeval C.struct_timeval
  88. type Timeval32 C.struct_timeval32
  89. type Tms C.struct_tms
  90. type Utimbuf C.struct_utimbuf
  91. // Processes
  92. type Rusage C.struct_rusage
  93. type Rlimit C.struct_rlimit
  94. type _Gid_t C.gid_t
  95. // Files
  96. const ( // Directory mode bits
  97. S_IFMT = C.S_IFMT
  98. S_IFIFO = C.S_IFIFO
  99. S_IFCHR = C.S_IFCHR
  100. S_IFDIR = C.S_IFDIR
  101. S_IFBLK = C.S_IFBLK
  102. S_IFREG = C.S_IFREG
  103. S_IFLNK = C.S_IFLNK
  104. S_IFSOCK = C.S_IFSOCK
  105. S_ISUID = C.S_ISUID
  106. S_ISGID = C.S_ISGID
  107. S_ISVTX = C.S_ISVTX
  108. S_IRUSR = C.S_IRUSR
  109. S_IWUSR = C.S_IWUSR
  110. S_IXUSR = C.S_IXUSR
  111. )
  112. type Stat_t C.struct_stat
  113. type Flock_t C.struct_flock
  114. type Dirent C.struct_dirent
  115. // Filesystems
  116. type _Fsblkcnt_t C.fsblkcnt_t
  117. type Statvfs_t C.struct_statvfs
  118. // Sockets
  119. type RawSockaddrInet4 C.struct_sockaddr_in
  120. type RawSockaddrInet6 C.struct_sockaddr_in6
  121. type RawSockaddrUnix C.struct_sockaddr_un
  122. type RawSockaddrDatalink C.struct_sockaddr_dl
  123. type RawSockaddr C.struct_sockaddr
  124. type RawSockaddrAny C.struct_sockaddr_any
  125. type _Socklen C.socklen_t
  126. type Linger C.struct_linger
  127. type Iovec C.struct_iovec
  128. type IPMreq C.struct_ip_mreq
  129. type IPv6Mreq C.struct_ipv6_mreq
  130. type Msghdr C.struct_msghdr
  131. type Cmsghdr C.struct_cmsghdr
  132. type Inet6Pktinfo C.struct_in6_pktinfo
  133. type IPv6MTUInfo C.struct_ip6_mtuinfo
  134. type ICMPv6Filter C.struct_icmp6_filter
  135. const (
  136. SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
  137. SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
  138. SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
  139. SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
  140. SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
  141. SizeofLinger = C.sizeof_struct_linger
  142. SizeofIPMreq = C.sizeof_struct_ip_mreq
  143. SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
  144. SizeofMsghdr = C.sizeof_struct_msghdr
  145. SizeofCmsghdr = C.sizeof_struct_cmsghdr
  146. SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
  147. SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
  148. SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
  149. )
  150. // Select
  151. type FdSet C.fd_set
  152. // Misc
  153. type Utsname C.struct_utsname
  154. type Ustat_t C.struct_ustat
  155. const (
  156. AT_FDCWD = C.AT_FDCWD
  157. AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
  158. AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW
  159. AT_REMOVEDIR = C.AT_REMOVEDIR
  160. AT_EACCESS = C.AT_EACCESS
  161. )
  162. // Routing and interface messages
  163. const (
  164. SizeofIfMsghdr = C.sizeof_struct_if_msghdr
  165. SizeofIfData = C.sizeof_struct_if_data
  166. SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
  167. SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
  168. SizeofRtMetrics = C.sizeof_struct_rt_metrics
  169. )
  170. type IfMsghdr C.struct_if_msghdr
  171. type IfData C.struct_if_data
  172. type IfaMsghdr C.struct_ifa_msghdr
  173. type RtMsghdr C.struct_rt_msghdr
  174. type RtMetrics C.struct_rt_metrics
  175. // Berkeley packet filter
  176. const (
  177. SizeofBpfVersion = C.sizeof_struct_bpf_version
  178. SizeofBpfStat = C.sizeof_struct_bpf_stat
  179. SizeofBpfProgram = C.sizeof_struct_bpf_program
  180. SizeofBpfInsn = C.sizeof_struct_bpf_insn
  181. SizeofBpfHdr = C.sizeof_struct_bpf_hdr
  182. )
  183. type BpfVersion C.struct_bpf_version
  184. type BpfStat C.struct_bpf_stat
  185. type BpfProgram C.struct_bpf_program
  186. type BpfInsn C.struct_bpf_insn
  187. type BpfTimeval C.struct_bpf_timeval
  188. type BpfHdr C.struct_bpf_hdr
  189. // Terminal handling
  190. type Termios C.struct_termios
  191. type Termio C.struct_termio
  192. type Winsize C.struct_winsize
  193. // poll
  194. type PollFd C.struct_pollfd
  195. const (
  196. POLLERR = C.POLLERR
  197. POLLHUP = C.POLLHUP
  198. POLLIN = C.POLLIN
  199. POLLNVAL = C.POLLNVAL
  200. POLLOUT = C.POLLOUT
  201. POLLPRI = C.POLLPRI
  202. POLLRDBAND = C.POLLRDBAND
  203. POLLRDNORM = C.POLLRDNORM
  204. POLLWRBAND = C.POLLWRBAND
  205. POLLWRNORM = C.POLLWRNORM
  206. )