A lightweight mechanism to provide an *instant kickstart* to a Go web server instance upon changing any Go source files under the project directory (and its subdirectories).

types_freebsd.go 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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 <signal.h>
  16. #include <termios.h>
  17. #include <stdio.h>
  18. #include <unistd.h>
  19. #include <sys/event.h>
  20. #include <sys/mman.h>
  21. #include <sys/mount.h>
  22. #include <sys/param.h>
  23. #include <sys/ptrace.h>
  24. #include <sys/resource.h>
  25. #include <sys/select.h>
  26. #include <sys/signal.h>
  27. #include <sys/socket.h>
  28. #include <sys/stat.h>
  29. #include <sys/time.h>
  30. #include <sys/types.h>
  31. #include <sys/un.h>
  32. #include <sys/wait.h>
  33. #include <net/bpf.h>
  34. #include <net/if.h>
  35. #include <net/if_dl.h>
  36. #include <net/route.h>
  37. #include <netinet/in.h>
  38. #include <netinet/icmp6.h>
  39. #include <netinet/tcp.h>
  40. enum {
  41. sizeofPtr = sizeof(void*),
  42. };
  43. union sockaddr_all {
  44. struct sockaddr s1; // this one gets used for fields
  45. struct sockaddr_in s2; // these pad it out
  46. struct sockaddr_in6 s3;
  47. struct sockaddr_un s4;
  48. struct sockaddr_dl s5;
  49. };
  50. struct sockaddr_any {
  51. struct sockaddr addr;
  52. char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
  53. };
  54. // This structure is a duplicate of stat on FreeBSD 8-STABLE.
  55. // See /usr/include/sys/stat.h.
  56. struct stat8 {
  57. #undef st_atimespec st_atim
  58. #undef st_mtimespec st_mtim
  59. #undef st_ctimespec st_ctim
  60. #undef st_birthtimespec st_birthtim
  61. __dev_t st_dev;
  62. ino_t st_ino;
  63. mode_t st_mode;
  64. nlink_t st_nlink;
  65. uid_t st_uid;
  66. gid_t st_gid;
  67. __dev_t st_rdev;
  68. #if __BSD_VISIBLE
  69. struct timespec st_atimespec;
  70. struct timespec st_mtimespec;
  71. struct timespec st_ctimespec;
  72. #else
  73. time_t st_atime;
  74. long __st_atimensec;
  75. time_t st_mtime;
  76. long __st_mtimensec;
  77. time_t st_ctime;
  78. long __st_ctimensec;
  79. #endif
  80. off_t st_size;
  81. blkcnt_t st_blocks;
  82. blksize_t st_blksize;
  83. fflags_t st_flags;
  84. __uint32_t st_gen;
  85. __int32_t st_lspare;
  86. #if __BSD_VISIBLE
  87. struct timespec st_birthtimespec;
  88. unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
  89. unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
  90. #else
  91. time_t st_birthtime;
  92. long st_birthtimensec;
  93. unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
  94. unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
  95. #endif
  96. };
  97. // This structure is a duplicate of if_data on FreeBSD 8-STABLE.
  98. // See /usr/include/net/if.h.
  99. struct if_data8 {
  100. u_char ifi_type;
  101. u_char ifi_physical;
  102. u_char ifi_addrlen;
  103. u_char ifi_hdrlen;
  104. u_char ifi_link_state;
  105. u_char ifi_spare_char1;
  106. u_char ifi_spare_char2;
  107. u_char ifi_datalen;
  108. u_long ifi_mtu;
  109. u_long ifi_metric;
  110. u_long ifi_baudrate;
  111. u_long ifi_ipackets;
  112. u_long ifi_ierrors;
  113. u_long ifi_opackets;
  114. u_long ifi_oerrors;
  115. u_long ifi_collisions;
  116. u_long ifi_ibytes;
  117. u_long ifi_obytes;
  118. u_long ifi_imcasts;
  119. u_long ifi_omcasts;
  120. u_long ifi_iqdrops;
  121. u_long ifi_noproto;
  122. u_long ifi_hwassist;
  123. time_t ifi_epoch;
  124. struct timeval ifi_lastchange;
  125. };
  126. // This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
  127. // See /usr/include/net/if.h.
  128. struct if_msghdr8 {
  129. u_short ifm_msglen;
  130. u_char ifm_version;
  131. u_char ifm_type;
  132. int ifm_addrs;
  133. int ifm_flags;
  134. u_short ifm_index;
  135. struct if_data8 ifm_data;
  136. };
  137. */
  138. import "C"
  139. // Machine characteristics; for internal use.
  140. const (
  141. sizeofPtr = C.sizeofPtr
  142. sizeofShort = C.sizeof_short
  143. sizeofInt = C.sizeof_int
  144. sizeofLong = C.sizeof_long
  145. sizeofLongLong = C.sizeof_longlong
  146. )
  147. // Basic types
  148. type (
  149. _C_short C.short
  150. _C_int C.int
  151. _C_long C.long
  152. _C_long_long C.longlong
  153. )
  154. // Time
  155. type Timespec C.struct_timespec
  156. type Timeval C.struct_timeval
  157. // Processes
  158. type Rusage C.struct_rusage
  159. type Rlimit C.struct_rlimit
  160. type _Gid_t C.gid_t
  161. // Files
  162. const ( // Directory mode bits
  163. S_IFMT = C.S_IFMT
  164. S_IFIFO = C.S_IFIFO
  165. S_IFCHR = C.S_IFCHR
  166. S_IFDIR = C.S_IFDIR
  167. S_IFBLK = C.S_IFBLK
  168. S_IFREG = C.S_IFREG
  169. S_IFLNK = C.S_IFLNK
  170. S_IFSOCK = C.S_IFSOCK
  171. S_ISUID = C.S_ISUID
  172. S_ISGID = C.S_ISGID
  173. S_ISVTX = C.S_ISVTX
  174. S_IRUSR = C.S_IRUSR
  175. S_IWUSR = C.S_IWUSR
  176. S_IXUSR = C.S_IXUSR
  177. )
  178. type Stat_t C.struct_stat8
  179. type Statfs_t C.struct_statfs
  180. type Flock_t C.struct_flock
  181. type Dirent C.struct_dirent
  182. type Fsid C.struct_fsid
  183. // Advice to Fadvise
  184. const (
  185. FADV_NORMAL = C.POSIX_FADV_NORMAL
  186. FADV_RANDOM = C.POSIX_FADV_RANDOM
  187. FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
  188. FADV_WILLNEED = C.POSIX_FADV_WILLNEED
  189. FADV_DONTNEED = C.POSIX_FADV_DONTNEED
  190. FADV_NOREUSE = C.POSIX_FADV_NOREUSE
  191. )
  192. // Sockets
  193. type RawSockaddrInet4 C.struct_sockaddr_in
  194. type RawSockaddrInet6 C.struct_sockaddr_in6
  195. type RawSockaddrUnix C.struct_sockaddr_un
  196. type RawSockaddrDatalink C.struct_sockaddr_dl
  197. type RawSockaddr C.struct_sockaddr
  198. type RawSockaddrAny C.struct_sockaddr_any
  199. type _Socklen C.socklen_t
  200. type Linger C.struct_linger
  201. type Iovec C.struct_iovec
  202. type IPMreq C.struct_ip_mreq
  203. type IPMreqn C.struct_ip_mreqn
  204. type IPv6Mreq C.struct_ipv6_mreq
  205. type Msghdr C.struct_msghdr
  206. type Cmsghdr C.struct_cmsghdr
  207. type Inet6Pktinfo C.struct_in6_pktinfo
  208. type IPv6MTUInfo C.struct_ip6_mtuinfo
  209. type ICMPv6Filter C.struct_icmp6_filter
  210. const (
  211. SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
  212. SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
  213. SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
  214. SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
  215. SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
  216. SizeofLinger = C.sizeof_struct_linger
  217. SizeofIPMreq = C.sizeof_struct_ip_mreq
  218. SizeofIPMreqn = C.sizeof_struct_ip_mreqn
  219. SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
  220. SizeofMsghdr = C.sizeof_struct_msghdr
  221. SizeofCmsghdr = C.sizeof_struct_cmsghdr
  222. SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
  223. SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
  224. SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
  225. )
  226. // Ptrace requests
  227. const (
  228. PTRACE_TRACEME = C.PT_TRACE_ME
  229. PTRACE_CONT = C.PT_CONTINUE
  230. PTRACE_KILL = C.PT_KILL
  231. )
  232. // Events (kqueue, kevent)
  233. type Kevent_t C.struct_kevent
  234. // Select
  235. type FdSet C.fd_set
  236. // Routing and interface messages
  237. const (
  238. sizeofIfMsghdr = C.sizeof_struct_if_msghdr
  239. SizeofIfMsghdr = C.sizeof_struct_if_msghdr8
  240. sizeofIfData = C.sizeof_struct_if_data
  241. SizeofIfData = C.sizeof_struct_if_data8
  242. SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
  243. SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
  244. SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
  245. SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
  246. SizeofRtMetrics = C.sizeof_struct_rt_metrics
  247. )
  248. type ifMsghdr C.struct_if_msghdr
  249. type IfMsghdr C.struct_if_msghdr8
  250. type ifData C.struct_if_data
  251. type IfData C.struct_if_data8
  252. type IfaMsghdr C.struct_ifa_msghdr
  253. type IfmaMsghdr C.struct_ifma_msghdr
  254. type IfAnnounceMsghdr C.struct_if_announcemsghdr
  255. type RtMsghdr C.struct_rt_msghdr
  256. type RtMetrics C.struct_rt_metrics
  257. // Berkeley packet filter
  258. const (
  259. SizeofBpfVersion = C.sizeof_struct_bpf_version
  260. SizeofBpfStat = C.sizeof_struct_bpf_stat
  261. SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf
  262. SizeofBpfProgram = C.sizeof_struct_bpf_program
  263. SizeofBpfInsn = C.sizeof_struct_bpf_insn
  264. SizeofBpfHdr = C.sizeof_struct_bpf_hdr
  265. SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
  266. )
  267. type BpfVersion C.struct_bpf_version
  268. type BpfStat C.struct_bpf_stat
  269. type BpfZbuf C.struct_bpf_zbuf
  270. type BpfProgram C.struct_bpf_program
  271. type BpfInsn C.struct_bpf_insn
  272. type BpfHdr C.struct_bpf_hdr
  273. type BpfZbufHeader C.struct_bpf_zbuf_header
  274. // Terminal handling
  275. type Termios C.struct_termios