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.
 
 
 

283 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/time.h>
  32. #include <sys/uio.h>
  33. #include <sys/un.h>
  34. #include <sys/utsname.h>
  35. #include <sys/wait.h>
  36. #include <net/bpf.h>
  37. #include <net/if.h>
  38. #include <net/if_dl.h>
  39. #include <net/route.h>
  40. #include <netinet/in.h>
  41. #include <netinet/icmp6.h>
  42. #include <netinet/tcp.h>
  43. enum {
  44. sizeofPtr = sizeof(void*),
  45. };
  46. union sockaddr_all {
  47. struct sockaddr s1; // this one gets used for fields
  48. struct sockaddr_in s2; // these pad it out
  49. struct sockaddr_in6 s3;
  50. struct sockaddr_un s4;
  51. struct sockaddr_dl s5;
  52. };
  53. struct sockaddr_any {
  54. struct sockaddr addr;
  55. char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
  56. };
  57. */
  58. import "C"
  59. // Machine characteristics; for internal use.
  60. const (
  61. sizeofPtr = C.sizeofPtr
  62. sizeofShort = C.sizeof_short
  63. sizeofInt = C.sizeof_int
  64. sizeofLong = C.sizeof_long
  65. sizeofLongLong = C.sizeof_longlong
  66. )
  67. // Basic types
  68. type (
  69. _C_short C.short
  70. _C_int C.int
  71. _C_long C.long
  72. _C_long_long C.longlong
  73. )
  74. // Time
  75. type Timespec C.struct_timespec
  76. type Timeval C.struct_timeval
  77. // Processes
  78. type Rusage C.struct_rusage
  79. type Rlimit C.struct_rlimit
  80. type _Gid_t C.gid_t
  81. // Files
  82. const ( // Directory mode bits
  83. S_IFMT = C.S_IFMT
  84. S_IFIFO = C.S_IFIFO
  85. S_IFCHR = C.S_IFCHR
  86. S_IFDIR = C.S_IFDIR
  87. S_IFBLK = C.S_IFBLK
  88. S_IFREG = C.S_IFREG
  89. S_IFLNK = C.S_IFLNK
  90. S_IFSOCK = C.S_IFSOCK
  91. S_ISUID = C.S_ISUID
  92. S_ISGID = C.S_ISGID
  93. S_ISVTX = C.S_ISVTX
  94. S_IRUSR = C.S_IRUSR
  95. S_IWUSR = C.S_IWUSR
  96. S_IXUSR = C.S_IXUSR
  97. )
  98. type Stat_t C.struct_stat
  99. type Statfs_t C.struct_statfs
  100. type Flock_t C.struct_flock
  101. type Dirent C.struct_dirent
  102. type Fsid C.fsid_t
  103. // File system limits
  104. const (
  105. PathMax = C.PATH_MAX
  106. )
  107. // Sockets
  108. type RawSockaddrInet4 C.struct_sockaddr_in
  109. type RawSockaddrInet6 C.struct_sockaddr_in6
  110. type RawSockaddrUnix C.struct_sockaddr_un
  111. type RawSockaddrDatalink C.struct_sockaddr_dl
  112. type RawSockaddr C.struct_sockaddr
  113. type RawSockaddrAny C.struct_sockaddr_any
  114. type _Socklen C.socklen_t
  115. type Linger C.struct_linger
  116. type Iovec C.struct_iovec
  117. type IPMreq C.struct_ip_mreq
  118. type IPv6Mreq C.struct_ipv6_mreq
  119. type Msghdr C.struct_msghdr
  120. type Cmsghdr C.struct_cmsghdr
  121. type Inet6Pktinfo C.struct_in6_pktinfo
  122. type IPv6MTUInfo C.struct_ip6_mtuinfo
  123. type ICMPv6Filter C.struct_icmp6_filter
  124. const (
  125. SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
  126. SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
  127. SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
  128. SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
  129. SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
  130. SizeofLinger = C.sizeof_struct_linger
  131. SizeofIPMreq = C.sizeof_struct_ip_mreq
  132. SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
  133. SizeofMsghdr = C.sizeof_struct_msghdr
  134. SizeofCmsghdr = C.sizeof_struct_cmsghdr
  135. SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
  136. SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
  137. SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
  138. )
  139. // Ptrace requests
  140. const (
  141. PTRACE_TRACEME = C.PT_TRACE_ME
  142. PTRACE_CONT = C.PT_CONTINUE
  143. PTRACE_KILL = C.PT_KILL
  144. )
  145. // Events (kqueue, kevent)
  146. type Kevent_t C.struct_kevent
  147. // Select
  148. type FdSet C.fd_set
  149. // Routing and interface messages
  150. const (
  151. SizeofIfMsghdr = C.sizeof_struct_if_msghdr
  152. SizeofIfData = C.sizeof_struct_if_data
  153. SizeofIfaMsghdr = C.sizeof_struct_ifa_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 IfAnnounceMsghdr C.struct_if_announcemsghdr
  162. type RtMsghdr C.struct_rt_msghdr
  163. type RtMetrics C.struct_rt_metrics
  164. type Mclpool C.struct_mclpool
  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. type BpfTimeval C.struct_bpf_timeval
  179. // Terminal handling
  180. type Termios C.struct_termios
  181. type Winsize C.struct_winsize
  182. // fchmodat-like syscalls.
  183. const (
  184. AT_FDCWD = C.AT_FDCWD
  185. AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
  186. )
  187. // poll
  188. type PollFd C.struct_pollfd
  189. const (
  190. POLLERR = C.POLLERR
  191. POLLHUP = C.POLLHUP
  192. POLLIN = C.POLLIN
  193. POLLNVAL = C.POLLNVAL
  194. POLLOUT = C.POLLOUT
  195. POLLPRI = C.POLLPRI
  196. POLLRDBAND = C.POLLRDBAND
  197. POLLRDNORM = C.POLLRDNORM
  198. POLLWRBAND = C.POLLWRBAND
  199. POLLWRNORM = C.POLLWRNORM
  200. )
  201. // Uname
  202. type Utsname C.struct_utsname