25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

281 satır
5.5 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. #include <dirent.h>
  14. #include <fcntl.h>
  15. #include <poll.h>
  16. #include <signal.h>
  17. #include <termios.h>
  18. #include <stdio.h>
  19. #include <unistd.h>
  20. #include <sys/event.h>
  21. #include <sys/mman.h>
  22. #include <sys/mount.h>
  23. #include <sys/param.h>
  24. #include <sys/ptrace.h>
  25. #include <sys/resource.h>
  26. #include <sys/select.h>
  27. #include <sys/signal.h>
  28. #include <sys/socket.h>
  29. #include <sys/stat.h>
  30. #include <sys/time.h>
  31. #include <sys/types.h>
  32. #include <sys/un.h>
  33. #include <sys/utsname.h>
  34. #include <sys/wait.h>
  35. #include <net/bpf.h>
  36. #include <net/if.h>
  37. #include <net/if_dl.h>
  38. #include <net/route.h>
  39. #include <netinet/in.h>
  40. #include <netinet/icmp6.h>
  41. #include <netinet/tcp.h>
  42. enum {
  43. sizeofPtr = sizeof(void*),
  44. };
  45. union sockaddr_all {
  46. struct sockaddr s1; // this one gets used for fields
  47. struct sockaddr_in s2; // these pad it out
  48. struct sockaddr_in6 s3;
  49. struct sockaddr_un s4;
  50. struct sockaddr_dl s5;
  51. };
  52. struct sockaddr_any {
  53. struct sockaddr addr;
  54. char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
  55. };
  56. */
  57. import "C"
  58. // Machine characteristics; for internal use.
  59. const (
  60. sizeofPtr = C.sizeofPtr
  61. sizeofShort = C.sizeof_short
  62. sizeofInt = C.sizeof_int
  63. sizeofLong = C.sizeof_long
  64. sizeofLongLong = C.sizeof_longlong
  65. )
  66. // Basic types
  67. type (
  68. _C_short C.short
  69. _C_int C.int
  70. _C_long C.long
  71. _C_long_long C.longlong
  72. )
  73. // Time
  74. type Timespec C.struct_timespec
  75. type Timeval C.struct_timeval
  76. // Processes
  77. type Rusage C.struct_rusage
  78. type Rlimit C.struct_rlimit
  79. type _Gid_t C.gid_t
  80. // Files
  81. const ( // Directory mode bits
  82. S_IFMT = C.S_IFMT
  83. S_IFIFO = C.S_IFIFO
  84. S_IFCHR = C.S_IFCHR
  85. S_IFDIR = C.S_IFDIR
  86. S_IFBLK = C.S_IFBLK
  87. S_IFREG = C.S_IFREG
  88. S_IFLNK = C.S_IFLNK
  89. S_IFSOCK = C.S_IFSOCK
  90. S_ISUID = C.S_ISUID
  91. S_ISGID = C.S_ISGID
  92. S_ISVTX = C.S_ISVTX
  93. S_IRUSR = C.S_IRUSR
  94. S_IWUSR = C.S_IWUSR
  95. S_IXUSR = C.S_IXUSR
  96. )
  97. type Stat_t C.struct_stat
  98. type Statfs_t C.struct_statfs
  99. type Flock_t C.struct_flock
  100. type Dirent C.struct_dirent
  101. type Fsid C.struct_fsid
  102. // File system limits
  103. const (
  104. PathMax = C.PATH_MAX
  105. )
  106. // Sockets
  107. type RawSockaddrInet4 C.struct_sockaddr_in
  108. type RawSockaddrInet6 C.struct_sockaddr_in6
  109. type RawSockaddrUnix C.struct_sockaddr_un
  110. type RawSockaddrDatalink C.struct_sockaddr_dl
  111. type RawSockaddr C.struct_sockaddr
  112. type RawSockaddrAny C.struct_sockaddr_any
  113. type _Socklen C.socklen_t
  114. type Linger C.struct_linger
  115. type Iovec C.struct_iovec
  116. type IPMreq C.struct_ip_mreq
  117. type IPv6Mreq C.struct_ipv6_mreq
  118. type Msghdr C.struct_msghdr
  119. type Cmsghdr C.struct_cmsghdr
  120. type Inet6Pktinfo C.struct_in6_pktinfo
  121. type IPv6MTUInfo C.struct_ip6_mtuinfo
  122. type ICMPv6Filter C.struct_icmp6_filter
  123. const (
  124. SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
  125. SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
  126. SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
  127. SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
  128. SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
  129. SizeofLinger = C.sizeof_struct_linger
  130. SizeofIPMreq = C.sizeof_struct_ip_mreq
  131. SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
  132. SizeofMsghdr = C.sizeof_struct_msghdr
  133. SizeofCmsghdr = C.sizeof_struct_cmsghdr
  134. SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
  135. SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
  136. SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
  137. )
  138. // Ptrace requests
  139. const (
  140. PTRACE_TRACEME = C.PT_TRACE_ME
  141. PTRACE_CONT = C.PT_CONTINUE
  142. PTRACE_KILL = C.PT_KILL
  143. )
  144. // Events (kqueue, kevent)
  145. type Kevent_t C.struct_kevent
  146. // Select
  147. type FdSet C.fd_set
  148. // Routing and interface messages
  149. const (
  150. SizeofIfMsghdr = C.sizeof_struct_if_msghdr
  151. SizeofIfData = C.sizeof_struct_if_data
  152. SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
  153. SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
  154. SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
  155. SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
  156. SizeofRtMetrics = C.sizeof_struct_rt_metrics
  157. )
  158. type IfMsghdr C.struct_if_msghdr
  159. type IfData C.struct_if_data
  160. type IfaMsghdr C.struct_ifa_msghdr
  161. type IfmaMsghdr C.struct_ifma_msghdr
  162. type IfAnnounceMsghdr C.struct_if_announcemsghdr
  163. type RtMsghdr C.struct_rt_msghdr
  164. type RtMetrics C.struct_rt_metrics
  165. // Berkeley packet filter
  166. const (
  167. SizeofBpfVersion = C.sizeof_struct_bpf_version
  168. SizeofBpfStat = C.sizeof_struct_bpf_stat
  169. SizeofBpfProgram = C.sizeof_struct_bpf_program
  170. SizeofBpfInsn = C.sizeof_struct_bpf_insn
  171. SizeofBpfHdr = C.sizeof_struct_bpf_hdr
  172. )
  173. type BpfVersion C.struct_bpf_version
  174. type BpfStat C.struct_bpf_stat
  175. type BpfProgram C.struct_bpf_program
  176. type BpfInsn C.struct_bpf_insn
  177. type BpfHdr C.struct_bpf_hdr
  178. // Terminal handling
  179. type Termios C.struct_termios
  180. type Winsize C.struct_winsize
  181. // fchmodat-like syscalls.
  182. const (
  183. AT_FDCWD = C.AT_FDCWD
  184. AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
  185. )
  186. // poll
  187. type PollFd C.struct_pollfd
  188. const (
  189. POLLERR = C.POLLERR
  190. POLLHUP = C.POLLHUP
  191. POLLIN = C.POLLIN
  192. POLLNVAL = C.POLLNVAL
  193. POLLOUT = C.POLLOUT
  194. POLLPRI = C.POLLPRI
  195. POLLRDBAND = C.POLLRDBAND
  196. POLLRDNORM = C.POLLRDNORM
  197. POLLWRBAND = C.POLLWRBAND
  198. POLLWRNORM = C.POLLWRNORM
  199. )
  200. // Uname
  201. type Utsname C.struct_utsname