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.

types_darwin.go 5.6KB

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