You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

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