mksysinfo.sh 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  1. #!/bin/sh
  2. # Copyright 2009 The Go Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style
  4. # license that can be found in the LICENSE file.
  5. # Create sysinfo.go.
  6. # This shell script creates the sysinfo.go file which holds types and
  7. # constants extracted from the system header files. This relies on a
  8. # hook in gcc: the -fdump-go-spec option will generate debugging
  9. # information in Go syntax.
  10. # We currently #include all the files at once, which works, but leads
  11. # to exposing some names which ideally should not be exposed, as they
  12. # match grep patterns. E.g., WCHAR_MIN gets exposed because it starts
  13. # with W, like the wait flags.
  14. CC=${CC:-gcc}
  15. OUT=tmp-sysinfo.go
  16. set -e
  17. rm -f sysinfo.c
  18. cat > sysinfo.c <<EOF
  19. #include "config.h"
  20. #include <sys/types.h>
  21. #include <dirent.h>
  22. #include <errno.h>
  23. #include <fcntl.h>
  24. #include <netinet/in.h>
  25. /* <netinet/tcp.h> needs u_char/u_short, but <sys/bsd_types> is only
  26. included by <netinet/in.h> if _SGIAPI (i.e. _SGI_SOURCE
  27. && !_XOPEN_SOURCE.
  28. <sys/termios.h> only defines TIOCNOTTY if !_XOPEN_SOURCE, while
  29. <sys/ttold.h> does so unconditionally. */
  30. #ifdef __sgi__
  31. #include <sys/bsd_types.h>
  32. #include <sys/ttold.h>
  33. #endif
  34. #include <netinet/tcp.h>
  35. #if defined(HAVE_NETINET_IN_SYSTM_H)
  36. #include <netinet/in_systm.h>
  37. #endif
  38. #if defined(HAVE_NETINET_IP_H)
  39. #include <netinet/ip.h>
  40. #endif
  41. #if defined(HAVE_NETINET_IP_MROUTE_H)
  42. #include <netinet/ip_mroute.h>
  43. #endif
  44. #if defined(HAVE_NETINET_IF_ETHER_H)
  45. #include <netinet/if_ether.h>
  46. #endif
  47. #include <signal.h>
  48. #include <sys/ioctl.h>
  49. #include <termios.h>
  50. #if defined(HAVE_SYSCALL_H)
  51. #include <syscall.h>
  52. #endif
  53. #if defined(HAVE_SYS_SYSCALL_H)
  54. #include <sys/syscall.h>
  55. #endif
  56. #if defined(HAVE_SYS_EPOLL_H)
  57. #include <sys/epoll.h>
  58. #endif
  59. #if defined(HAVE_SYS_FILE_H)
  60. #include <sys/file.h>
  61. #endif
  62. #if defined(HAVE_SYS_MMAN_H)
  63. #include <sys/mman.h>
  64. #endif
  65. #if defined(HAVE_SYS_PRCTL_H)
  66. #include <sys/prctl.h>
  67. #endif
  68. #if defined(HAVE_SYS_PTRACE_H)
  69. #include <sys/ptrace.h>
  70. #endif
  71. #include <sys/resource.h>
  72. #include <sys/uio.h>
  73. #include <sys/socket.h>
  74. #include <sys/stat.h>
  75. #include <sys/time.h>
  76. #include <sys/times.h>
  77. #include <sys/wait.h>
  78. #include <sys/un.h>
  79. #if defined(HAVE_SYS_USER_H)
  80. #include <sys/user.h>
  81. #endif
  82. #if defined(HAVE_SYS_UTSNAME_H)
  83. #include <sys/utsname.h>
  84. #endif
  85. #if defined(HAVE_SYS_SELECT_H)
  86. #include <sys/select.h>
  87. #endif
  88. #include <time.h>
  89. #include <unistd.h>
  90. #include <netdb.h>
  91. #include <pwd.h>
  92. #if defined(HAVE_LINUX_FILTER_H)
  93. #include <linux/filter.h>
  94. #endif
  95. #if defined(HAVE_LINUX_IF_ADDR_H)
  96. #include <linux/if_addr.h>
  97. #endif
  98. #if defined(HAVE_LINUX_IF_ETHER_H)
  99. #include <linux/if_ether.h>
  100. #endif
  101. #if defined(HAVE_LINUX_IF_TUN_H)
  102. #include <linux/if_tun.h>
  103. #endif
  104. #if defined(HAVE_LINUX_NETLINK_H)
  105. #include <linux/netlink.h>
  106. #endif
  107. #if defined(HAVE_LINUX_RTNETLINK_H)
  108. #include <linux/rtnetlink.h>
  109. #endif
  110. #if defined(HAVE_NET_IF_H)
  111. #include <net/if.h>
  112. #endif
  113. #if defined(HAVE_NET_IF_ARP_H)
  114. #include <net/if_arp.h>
  115. #endif
  116. #if defined(HAVE_NET_ROUTE_H)
  117. #include <net/route.h>
  118. #endif
  119. #if defined (HAVE_NETPACKET_PACKET_H)
  120. #include <netpacket/packet.h>
  121. #endif
  122. #if defined(HAVE_SYS_MOUNT_H)
  123. #include <sys/mount.h>
  124. #endif
  125. #if defined(HAVE_SYS_VFS_H)
  126. #include <sys/vfs.h>
  127. #endif
  128. #if defined(HAVE_STATFS_H)
  129. #include <sys/statfs.h>
  130. #endif
  131. #if defined(HAVE_SYS_TIMEX_H)
  132. #include <sys/timex.h>
  133. #endif
  134. #if defined(HAVE_SYS_SYSINFO_H)
  135. #include <sys/sysinfo.h>
  136. #endif
  137. #if defined(HAVE_USTAT_H)
  138. #include <ustat.h>
  139. #endif
  140. #if defined(HAVE_UTIME_H)
  141. #include <utime.h>
  142. #endif
  143. #if defined(HAVE_LINUX_ETHER_H)
  144. #include <linux/ether.h>
  145. #endif
  146. #if defined(HAVE_LINUX_FS_H)
  147. #include <linux/fs.h>
  148. #endif
  149. #if defined(HAVE_LINUX_REBOOT_H)
  150. #include <linux/reboot.h>
  151. #endif
  152. #if defined(HAVE_SYS_INOTIFY_H)
  153. #include <sys/inotify.h>
  154. #endif
  155. #if defined(HAVE_NETINET_ICMP6_H)
  156. #include <netinet/icmp6.h>
  157. #endif
  158. #if defined(HAVE_SCHED_H)
  159. #include <sched.h>
  160. #endif
  161. /* Constants that may only be defined as expressions on some systems,
  162. expressions too complex for -fdump-go-spec to handle. These are
  163. handled specially below. */
  164. enum {
  165. #ifdef TIOCGWINSZ
  166. TIOCGWINSZ_val = TIOCGWINSZ,
  167. #endif
  168. #ifdef TIOCSWINSZ
  169. TIOCSWINSZ_val = TIOCSWINSZ,
  170. #endif
  171. #ifdef TIOCNOTTY
  172. TIOCNOTTY_val = TIOCNOTTY,
  173. #endif
  174. #ifdef TIOCSCTTY
  175. TIOCSCTTY_val = TIOCSCTTY,
  176. #endif
  177. #ifdef TIOCGPTN
  178. TIOCGPTN_val = TIOCGPTN,
  179. #endif
  180. #ifdef TIOCSPTLCK
  181. TIOCSPTLCK_val = TIOCSPTLCK,
  182. #endif
  183. #ifdef TIOCGDEV
  184. TIOCGDEV_val = TIOCGDEV,
  185. #endif
  186. #ifdef TIOCSIG
  187. TIOCSIG_val = TIOCSIG,
  188. #endif
  189. #ifdef TCGETS
  190. TCGETS_val = TCGETS,
  191. #endif
  192. #ifdef TCSETS
  193. TCSETS_val = TCSETS,
  194. #endif
  195. };
  196. EOF
  197. ${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c
  198. echo 'package syscall' > ${OUT}
  199. echo 'import "unsafe"' >> ${OUT}
  200. echo 'type _ unsafe.Pointer' >> ${OUT}
  201. # Get all the consts and types, skipping ones which could not be
  202. # represented in Go and ones which we need to rewrite. We also skip
  203. # function declarations, as we don't need them here. All the symbols
  204. # will all have a leading underscore.
  205. grep -v '^// ' gen-sysinfo.go | \
  206. grep -v '^func' | \
  207. grep -v '^type _timeval ' | \
  208. grep -v '^type _timespec_t ' | \
  209. grep -v '^type _timespec ' | \
  210. grep -v '^type _timestruc_t ' | \
  211. grep -v '^type _epoll_' | \
  212. grep -v 'in6_addr' | \
  213. grep -v 'sockaddr_in6' | \
  214. sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
  215. -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
  216. -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
  217. -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
  218. >> ${OUT}
  219. # The errno constants. These get type Errno.
  220. echo '#include <errno.h>' | ${CC} -x c - -E -dM | \
  221. egrep '#define E[A-Z0-9_]+ ' | \
  222. sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
  223. # The O_xxx flags.
  224. egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
  225. sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  226. if ! grep '^const O_ASYNC' ${OUT} >/dev/null 2>&1; then
  227. echo "const O_ASYNC = 0" >> ${OUT}
  228. fi
  229. if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then
  230. echo "const O_CLOEXEC = 0" >> ${OUT}
  231. fi
  232. # The os package requires F_DUPFD_CLOEXEC to be defined.
  233. if ! grep '^const F_DUPFD_CLOEXEC' ${OUT} >/dev/null 2>&1; then
  234. echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT}
  235. fi
  236. # These flags can be lost on i386 GNU/Linux when using
  237. # -D_FILE_OFFSET_BITS=64, because we see "#define F_SETLK F_SETLK64"
  238. # before we see the definition of F_SETLK64.
  239. for flag in F_GETLK F_SETLK F_SETLKW; do
  240. if ! grep "^const ${flag} " ${OUT} >/dev/null 2>&1 \
  241. && grep "^const ${flag}64 " ${OUT} >/dev/null 2>&1; then
  242. echo "const ${flag} = ${flag}64" >> ${OUT}
  243. fi
  244. done
  245. # The Flock_t struct for fcntl.
  246. grep '^type _flock ' gen-sysinfo.go | \
  247. sed -e 's/type _flock/type Flock_t/' \
  248. -e 's/l_type/Type/' \
  249. -e 's/l_whence/Whence/' \
  250. -e 's/l_start/Start/' \
  251. -e 's/l_len/Len/' \
  252. -e 's/l_pid/Pid/' \
  253. >> ${OUT}
  254. # The signal numbers.
  255. grep '^const _SIG[^_]' gen-sysinfo.go | \
  256. grep -v '^const _SIGEV_' | \
  257. sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = Signal(_\2)/' >> ${OUT}
  258. if ! grep '^const SIGPOLL ' ${OUT} >/dev/null 2>&1; then
  259. if grep '^const SIGIO ' ${OUT} > /dev/null 2>&1; then
  260. echo "const SIGPOLL = SIGIO" >> ${OUT}
  261. fi
  262. fi
  263. if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then
  264. if grep '^const SIGCHLD ' ${OUT} >/dev/null 2>&1; then
  265. echo "const SIGCLD = SIGCHLD" >> ${OUT}
  266. fi
  267. fi
  268. # The syscall numbers. We force the names to upper case.
  269. grep '^const _SYS_' gen-sysinfo.go | \
  270. sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
  271. while read sys; do
  272. sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
  273. echo "const $sup = _$sys" >> ${OUT}
  274. done
  275. # The GNU/Linux support wants to use SYS_GETDENTS64 if available.
  276. if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then
  277. echo "const SYS_GETDENTS = 0" >> ${OUT}
  278. fi
  279. if ! grep '^const SYS_GETDENTS64 ' ${OUT} >/dev/null 2>&1; then
  280. echo "const SYS_GETDENTS64 = 0" >> ${OUT}
  281. fi
  282. # Stat constants.
  283. grep '^const _S_' gen-sysinfo.go | \
  284. sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  285. # Mmap constants.
  286. grep '^const _PROT_' gen-sysinfo.go | \
  287. sed -e 's/^\(const \)_\(PROT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  288. grep '^const _MAP_' gen-sysinfo.go | \
  289. sed -e 's/^\(const \)_\(MAP_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  290. grep '^const _MADV_' gen-sysinfo.go | \
  291. sed -e 's/^\(const \)_\(MADV_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  292. grep '^const _MCL_' gen-sysinfo.go | \
  293. sed -e 's/^\(const \)_\(MCL_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  294. # Process status constants.
  295. grep '^const _W' gen-sysinfo.go |
  296. sed -e 's/^\(const \)_\(W[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  297. # WSTOPPED was introduced in glibc 2.3.4.
  298. if ! grep '^const _WSTOPPED = ' gen-sysinfo.go >/dev/null 2>&1; then
  299. if grep '^const _WUNTRACED = ' gen-sysinfo.go > /dev/null 2>&1; then
  300. echo 'const WSTOPPED = _WUNTRACED' >> ${OUT}
  301. else
  302. echo 'const WSTOPPED = 2' >> ${OUT}
  303. fi
  304. fi
  305. if grep '^const ___WALL = ' gen-sysinfo.go >/dev/null 2>&1 \
  306. && ! grep '^const _WALL = ' gen-sysinfo.go >/dev/null 2>&1; then
  307. echo 'const WALL = ___WALL' >> ${OUT}
  308. fi
  309. # Networking constants.
  310. egrep '^const _(AF|ARPHRD|ETH|IN|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
  311. sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  312. grep '^const _SOMAXCONN' gen-sysinfo.go |
  313. sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
  314. >> ${OUT}
  315. grep '^const _SHUT_' gen-sysinfo.go |
  316. sed -e 's/^\(const \)_\(SHUT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  317. # The net package requires some const definitions.
  318. for m in IP_PKTINFO IPV6_V6ONLY IPPROTO_IPV6 IPV6_JOIN_GROUP IPV6_LEAVE_GROUP IPV6_TCLASS SO_REUSEPORT; do
  319. if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
  320. echo "const $m = 0" >> ${OUT}
  321. fi
  322. done
  323. for m in SOCK_CLOEXEC SOCK_NONBLOCK; do
  324. if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
  325. echo "const $m = -1" >> ${OUT}
  326. fi
  327. done
  328. # The syscall package requires AF_LOCAL.
  329. if ! grep '^const AF_LOCAL ' ${OUT} >/dev/null 2>&1; then
  330. if grep '^const AF_UNIX ' ${OUT} >/dev/null 2>&1; then
  331. echo "const AF_LOCAL = AF_UNIX" >> ${OUT}
  332. fi
  333. fi
  334. # pathconf constants.
  335. grep '^const __PC' gen-sysinfo.go |
  336. sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
  337. # The PATH_MAX constant.
  338. if grep '^const _PATH_MAX ' gen-sysinfo.go >/dev/null 2>&1; then
  339. echo 'const PathMax = _PATH_MAX' >> ${OUT}
  340. fi
  341. # epoll constants.
  342. grep '^const _EPOLL' gen-sysinfo.go |
  343. sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  344. # Make sure EPOLLRDHUP and EPOLL_CLOEXEC are defined.
  345. if ! grep '^const EPOLLRDHUP' ${OUT} >/dev/null 2>&1; then
  346. echo "const EPOLLRDHUP = 0x2000" >> ${OUT}
  347. fi
  348. if ! grep '^const EPOLL_CLOEXEC' ${OUT} >/dev/null 2>&1; then
  349. echo "const EPOLL_CLOEXEC = 02000000" >> ${OUT}
  350. fi
  351. # Prctl constants.
  352. grep '^const _PR_' gen-sysinfo.go |
  353. sed -e 's/^\(const \)_\(PR_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  354. # Ptrace constants.
  355. grep '^const _PTRACE' gen-sysinfo.go |
  356. sed -e 's/^\(const \)_\(PTRACE[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  357. # We need some ptrace options that are not defined in older versions
  358. # of glibc.
  359. if ! grep '^const PTRACE_SETOPTIONS' ${OUT} > /dev/null 2>&1; then
  360. echo "const PTRACE_SETOPTIONS = 0x4200" >> ${OUT}
  361. fi
  362. if ! grep '^const PTRACE_O_TRACESYSGOOD' ${OUT} > /dev/null 2>&1; then
  363. echo "const PTRACE_O_TRACESYSGOOD = 0x1" >> ${OUT}
  364. fi
  365. if ! grep '^const PTRACE_O_TRACEFORK' ${OUT} > /dev/null 2>&1; then
  366. echo "const PTRACE_O_TRACEFORK = 0x2" >> ${OUT}
  367. fi
  368. if ! grep '^const PTRACE_O_TRACEVFORK' ${OUT} > /dev/null 2>&1; then
  369. echo "const PTRACE_O_TRACEVFORK = 0x4" >> ${OUT}
  370. fi
  371. if ! grep '^const PTRACE_O_TRACECLONE' ${OUT} > /dev/null 2>&1; then
  372. echo "const PTRACE_O_TRACECLONE = 0x8" >> ${OUT}
  373. fi
  374. if ! grep '^const PTRACE_O_TRACEEXEC' ${OUT} > /dev/null 2>&1; then
  375. echo "const PTRACE_O_TRACEEXEC = 0x10" >> ${OUT}
  376. fi
  377. if ! grep '^const PTRACE_O_TRACEVFORKDONE' ${OUT} > /dev/null 2>&1; then
  378. echo "const PTRACE_O_TRACEVFORKDONE = 0x20" >> ${OUT}
  379. fi
  380. if ! grep '^const PTRACE_O_TRACEEXIT' ${OUT} > /dev/null 2>&1; then
  381. echo "const PTRACE_O_TRACEEXIT = 0x40" >> ${OUT}
  382. fi
  383. if ! grep '^const PTRACE_O_MASK' ${OUT} > /dev/null 2>&1; then
  384. echo "const PTRACE_O_MASK = 0x7f" >> ${OUT}
  385. fi
  386. if ! grep '^const _PTRACE_GETEVENTMSG' ${OUT} > /dev/null 2>&1; then
  387. echo "const PTRACE_GETEVENTMSG = 0x4201" >> ${OUT}
  388. fi
  389. if ! grep '^const PTRACE_EVENT_FORK' ${OUT} > /dev/null 2>&1; then
  390. echo "const PTRACE_EVENT_FORK = 1" >> ${OUT}
  391. fi
  392. if ! grep '^const PTRACE_EVENT_VFORK' ${OUT} > /dev/null 2>&1; then
  393. echo "const PTRACE_EVENT_VFORK = 2" >> ${OUT}
  394. fi
  395. if ! grep '^const PTRACE_EVENT_CLONE' ${OUT} > /dev/null 2>&1; then
  396. echo "const PTRACE_EVENT_CLONE = 3" >> ${OUT}
  397. fi
  398. if ! grep '^const PTRACE_EVENT_EXEC' ${OUT} > /dev/null 2>&1; then
  399. echo "const PTRACE_EVENT_EXEC = 4" >> ${OUT}
  400. fi
  401. if ! grep '^const PTRACE_EVENT_VFORK_DONE' ${OUT} > /dev/null 2>&1; then
  402. echo "const PTRACE_EVENT_VFORK_DONE = 5" >> ${OUT}
  403. fi
  404. if ! grep '^const PTRACE_EVENT_EXIT' ${OUT} > /dev/null 2>&1; then
  405. echo "const PTRACE_EVENT_EXIT = 6" >> ${OUT}
  406. fi
  407. if ! grep '^const _PTRACE_TRACEME' ${OUT} > /dev/null 2>&1; then
  408. echo "const _PTRACE_TRACEME = 0" >> ${OUT}
  409. fi
  410. # A helper function that prints a structure from gen-sysinfo.go with the first
  411. # letter of the field names in upper case. $1 is the name of structure. If $2
  412. # is not empty, the structure or type is renamed to $2.
  413. upcase_fields () {
  414. name="$1"
  415. def=`grep "^type $name" gen-sysinfo.go`
  416. fields=`echo $def | sed -e 's/^[^{]*{\(.*\)}$/\1/'`
  417. prefix=`echo $def | sed -e 's/{.*//'`
  418. if test "$2" != ""; then
  419. prefix=`echo $prefix | sed -e "s/$1/$2/"`
  420. fi
  421. if test "$fields" != ""; then
  422. nfields=
  423. while test -n "$fields"; do
  424. field=`echo $fields | sed -e 's/^\([^;]*\);.*$/\1/'`
  425. fields=`echo $fields | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
  426. # capitalize the next character.
  427. f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
  428. r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
  429. f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
  430. field="$f$r"
  431. nfields="$nfields $field;"
  432. done
  433. echo "${prefix} {$nfields }"
  434. fi
  435. }
  436. # The registers returned by PTRACE_GETREGS. This is probably
  437. # GNU/Linux specific; it should do no harm if there is no
  438. # _user_regs_struct.
  439. regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true`
  440. if test "$regs" == ""; then
  441. # s390
  442. regs=`grep '^type __user_regs_struct struct' gen-sysinfo.go || true`
  443. if test "$regs" != ""; then
  444. # Substructures of __user_regs_struct on s390
  445. upcase_fields "__user_psw_struct" "PtracePsw" >> ${OUT} || true
  446. upcase_fields "__user_fpregs_struct" "PtraceFpregs" >> ${OUT} || true
  447. upcase_fields "__user_per_struct" "PtracePer" >> ${OUT} || true
  448. fi
  449. fi
  450. if test "$regs" != ""; then
  451. regs=`echo $regs |
  452. sed -e 's/type __*user_regs_struct struct //' -e 's/[{}]//g'`
  453. regs=`echo $regs | sed -e s'/^ *//'`
  454. nregs=
  455. while test -n "$regs"; do
  456. field=`echo $regs | sed -e 's/^\([^;]*\);.*$/\1/'`
  457. regs=`echo $regs | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
  458. # Capitalize the first character of the field.
  459. f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
  460. r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
  461. f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
  462. field="$f$r"
  463. field=`echo "$field" | sed \
  464. -e 's/__user_psw_struct/PtracePsw/' \
  465. -e 's/__user_fpregs_struct/PtraceFpregs/' \
  466. -e 's/__user_per_struct/PtracePer/'`
  467. nregs="$nregs $field;"
  468. done
  469. echo "type PtraceRegs struct {$nregs }" >> ${OUT}
  470. fi
  471. # Some basic types.
  472. echo 'type Size_t _size_t' >> ${OUT}
  473. echo "type Ssize_t _ssize_t" >> ${OUT}
  474. if grep '^const _HAVE_OFF64_T = ' gen-sysinfo.go > /dev/null 2>&1; then
  475. echo "type Offset_t _off64_t" >> ${OUT}
  476. else
  477. echo "type Offset_t _off_t" >> ${OUT}
  478. fi
  479. echo "type Mode_t _mode_t" >> ${OUT}
  480. echo "type Pid_t _pid_t" >> ${OUT}
  481. echo "type Uid_t _uid_t" >> ${OUT}
  482. echo "type Gid_t _gid_t" >> ${OUT}
  483. echo "type Socklen_t _socklen_t" >> ${OUT}
  484. # The C int type.
  485. sizeof_int=`grep '^const ___SIZEOF_INT__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
  486. if test "$sizeof_int" = "4"; then
  487. echo "type _C_int int32" >> ${OUT}
  488. echo "type _C_uint uint32" >> ${OUT}
  489. elif test "$sizeof_int" = "8"; then
  490. echo "type _C_int int64" >> ${OUT}
  491. echo "type _C_uint uint64" >> ${OUT}
  492. else
  493. echo 1>&2 "mksysinfo.sh: could not determine size of int (got $sizeof_int)"
  494. exit 1
  495. fi
  496. # The C long type, needed because that is the type that ptrace returns.
  497. sizeof_long=`grep '^const ___SIZEOF_LONG__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
  498. if test "$sizeof_long" = "4"; then
  499. echo "type _C_long int32" >> ${OUT}
  500. elif test "$sizeof_long" = "8"; then
  501. echo "type _C_long int64" >> ${OUT}
  502. else
  503. echo 1>&2 "mksysinfo.sh: could not determine size of long (got $sizeof_long)"
  504. exit 1
  505. fi
  506. # Solaris 2 needs _u?pad128_t, but its default definition in terms of long
  507. # double is commented by -fdump-go-spec.
  508. if grep "^// type _pad128_t" gen-sysinfo.go > /dev/null 2>&1; then
  509. echo "type _pad128_t struct { _l [4]int32; }" >> ${OUT}
  510. fi
  511. if grep "^// type _upad128_t" gen-sysinfo.go > /dev/null 2>&1; then
  512. echo "type _upad128_t struct { _l [4]uint32; }" >> ${OUT}
  513. fi
  514. # The time_t type.
  515. if grep '^type _time_t ' gen-sysinfo.go > /dev/null 2>&1; then
  516. echo 'type Time_t _time_t' >> ${OUT}
  517. fi
  518. # The time structures need special handling: we need to name the
  519. # types, so that we can cast integers to the right types when
  520. # assigning to the structures.
  521. timeval=`grep '^type _timeval ' gen-sysinfo.go`
  522. timeval_sec=`echo $timeval | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
  523. timeval_usec=`echo $timeval | sed -n -e 's/^.*tv_usec \([^ ]*\);.*$/\1/p'`
  524. echo "type Timeval_sec_t $timeval_sec" >> ${OUT}
  525. echo "type Timeval_usec_t $timeval_usec" >> ${OUT}
  526. echo $timeval | \
  527. sed -e 's/type _timeval /type Timeval /' \
  528. -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timeval_sec_t/' \
  529. -e 's/tv_usec *[a-zA-Z0-9_]*/Usec Timeval_usec_t/' >> ${OUT}
  530. timespec=`grep '^type _timespec ' gen-sysinfo.go || true`
  531. if test "$timespec" = ""; then
  532. # IRIX 6.5 has __timespec instead.
  533. timespec=`grep '^type ___timespec ' gen-sysinfo.go || true`
  534. fi
  535. timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
  536. timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
  537. echo "type Timespec_sec_t $timespec_sec" >> ${OUT}
  538. echo "type Timespec_nsec_t $timespec_nsec" >> ${OUT}
  539. echo $timespec | \
  540. sed -e 's/^type ___timespec /type Timespec /' \
  541. -e 's/^type _timespec /type Timespec /' \
  542. -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \
  543. -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT}
  544. timestruc=`grep '^type _timestruc_t ' gen-sysinfo.go || true`
  545. if test "$timestruc" != ""; then
  546. timestruc_sec=`echo $timestruc | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
  547. timestruc_nsec=`echo $timestruc | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
  548. echo "type Timestruc_sec_t $timestruc_sec" >> ${OUT}
  549. echo "type Timestruc_nsec_t $timestruc_nsec" >> ${OUT}
  550. echo $timestruc | \
  551. sed -e 's/^type _timestruc_t /type Timestruc /' \
  552. -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timestruc_sec_t/' \
  553. -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timestruc_nsec_t/' >> ${OUT}
  554. fi
  555. # The tms struct.
  556. grep '^type _tms ' gen-sysinfo.go | \
  557. sed -e 's/type _tms/type Tms/' \
  558. -e 's/tms_utime/Utime/' \
  559. -e 's/tms_stime/Stime/' \
  560. -e 's/tms_cutime/Cutime/' \
  561. -e 's/tms_cstime/Cstime/' \
  562. >> ${OUT}
  563. # The stat type.
  564. # Prefer largefile variant if available.
  565. stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
  566. if test "$stat" != ""; then
  567. grep '^type _stat64 ' gen-sysinfo.go
  568. else
  569. grep '^type _stat ' gen-sysinfo.go
  570. fi | sed -e 's/type _stat64/type Stat_t/' \
  571. -e 's/type _stat/type Stat_t/' \
  572. -e 's/st_dev/Dev/' \
  573. -e 's/st_ino/Ino/g' \
  574. -e 's/st_nlink/Nlink/' \
  575. -e 's/st_mode/Mode/' \
  576. -e 's/st_uid/Uid/' \
  577. -e 's/st_gid/Gid/' \
  578. -e 's/st_rdev/Rdev/' \
  579. -e 's/st_size/Size/' \
  580. -e 's/st_blksize/Blksize/' \
  581. -e 's/st_blocks/Blocks/' \
  582. -e 's/st_atim/Atim/' \
  583. -e 's/st_mtim/Mtim/' \
  584. -e 's/st_ctim/Ctim/' \
  585. -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
  586. -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
  587. -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
  588. -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
  589. -e 's/Godump_[0-9] struct { \([^;]*;\) };/\1/g' \
  590. >> ${OUT}
  591. # The directory searching types.
  592. # Prefer largefile variant if available.
  593. dirent=`grep '^type _dirent64 ' gen-sysinfo.go || true`
  594. if test "$dirent" != ""; then
  595. grep '^type _dirent64 ' gen-sysinfo.go
  596. else
  597. grep '^type _dirent ' gen-sysinfo.go
  598. fi | sed -e 's/type _dirent64/type Dirent/' \
  599. -e 's/type _dirent/type Dirent/' \
  600. -e 's/d_name \[0+1\]/d_name [0+256]/' \
  601. -e 's/d_name/Name/' \
  602. -e 's/]int8/]byte/' \
  603. -e 's/d_ino/Ino/' \
  604. -e 's/d_off/Off/' \
  605. -e 's/d_reclen/Reclen/' \
  606. -e 's/d_type/Type/' \
  607. >> ${OUT}
  608. echo "type DIR _DIR" >> ${OUT}
  609. # Values for d_type field in dirent.
  610. grep '^const _DT_' gen-sysinfo.go |
  611. sed -e 's/^\(const \)_\(DT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  612. # The rusage struct.
  613. rusage=`grep '^type _rusage struct' gen-sysinfo.go`
  614. if test "$rusage" != ""; then
  615. # Remove anonymous unions from GNU/Linux <bits/resource.h>.
  616. rusage=`echo $rusage | sed -e 's/Godump_[0-9][0-9]* struct {\([^}]*\)};/\1/g'`
  617. rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'`
  618. rusage=`echo $rusage | sed -e 's/^ *//'`
  619. nrusage=
  620. while test -n "$rusage"; do
  621. field=`echo $rusage | sed -e 's/^\([^;]*\);.*$/\1/'`
  622. rusage=`echo $rusage | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
  623. # Drop the leading ru_, capitalize the next character.
  624. field=`echo $field | sed -e 's/^ru_//'`
  625. f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
  626. r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
  627. f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
  628. # Fix _timeval _timespec, and _timestruc_t.
  629. r=`echo $r | sed -e s'/ _timeval$/ Timeval/'`
  630. r=`echo $r | sed -e s'/ _timespec$/ Timespec/'`
  631. r=`echo $r | sed -e s'/ _timestruc_t$/ Timestruc/'`
  632. field="$f$r"
  633. nrusage="$nrusage $field;"
  634. done
  635. echo "type Rusage struct {$nrusage }" >> ${OUT}
  636. else
  637. echo "type Rusage struct {}" >> ${OUT}
  638. fi
  639. # The RUSAGE constants.
  640. grep '^const _RUSAGE_' gen-sysinfo.go | \
  641. sed -e 's/^\(const \)_\(RUSAGE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  642. # The utsname struct.
  643. grep '^type _utsname ' gen-sysinfo.go | \
  644. sed -e 's/_utsname/Utsname/' \
  645. -e 's/sysname/Sysname/' \
  646. -e 's/nodename/Nodename/' \
  647. -e 's/release/Release/' \
  648. -e 's/version/Version/' \
  649. -e 's/machine/Machine/' \
  650. -e 's/domainname/Domainname/' \
  651. >> ${OUT}
  652. # The iovec struct.
  653. iovec=`grep '^type _iovec ' gen-sysinfo.go`
  654. iovec_len=`echo $iovec | sed -n -e 's/^.*iov_len \([^ ]*\);.*$/\1/p'`
  655. echo "type Iovec_len_t $iovec_len" >> ${OUT}
  656. echo $iovec | \
  657. sed -e 's/_iovec/Iovec/' \
  658. -e 's/iov_base/Base/' \
  659. -e 's/iov_len *[a-zA-Z0-9_]*/Len Iovec_len_t/' \
  660. >> ${OUT}
  661. # The msghdr struct.
  662. msghdr=`grep '^type _msghdr ' gen-sysinfo.go`
  663. msghdr_controllen=`echo $msghdr | sed -n -e 's/^.*msg_controllen \([^ ]*\);.*$/\1/p'`
  664. echo "type Msghdr_controllen_t $msghdr_controllen" >> ${OUT}
  665. echo $msghdr | \
  666. sed -e 's/_msghdr/Msghdr/' \
  667. -e 's/msg_name/Name/' \
  668. -e 's/msg_namelen/Namelen/' \
  669. -e 's/msg_iov/Iov/' \
  670. -e 's/msg_iovlen/Iovlen/' \
  671. -e 's/_iovec/Iovec/' \
  672. -e 's/msg_control/Control/' \
  673. -e 's/msg_controllen *[a-zA-Z0-9_]*/Controllen Msghdr_controllen_t/' \
  674. -e 's/msg_flags/Flags/' \
  675. >> ${OUT}
  676. # The MSG_ flags for Msghdr.
  677. grep '^const _MSG_' gen-sysinfo.go | \
  678. sed -e 's/^\(const \)_\(MSG_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  679. # The cmsghdr struct.
  680. cmsghdr=`grep '^type _cmsghdr ' gen-sysinfo.go`
  681. if test -n "$cmsghdr"; then
  682. cmsghdr_len=`echo $cmsghdr | sed -n -e 's/^.*cmsg_len \([^ ]*\);.*$/\1/p'`
  683. echo "type Cmsghdr_len_t $cmsghdr_len" >> ${OUT}
  684. echo "$cmsghdr" | \
  685. sed -e 's/_cmsghdr/Cmsghdr/' \
  686. -e 's/cmsg_len *[a-zA-Z0-9_]*/Len Cmsghdr_len_t/' \
  687. -e 's/cmsg_level/Level/' \
  688. -e 's/cmsg_type/Type/' \
  689. -e 's/\[\]/[0]/' \
  690. >> ${OUT}
  691. fi
  692. # The SCM_ flags for Cmsghdr.
  693. grep '^const _SCM_' gen-sysinfo.go | \
  694. sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  695. # The ucred struct.
  696. upcase_fields "_ucred" "Ucred" >> ${OUT} || true
  697. # The ip_mreq struct.
  698. grep '^type _ip_mreq ' gen-sysinfo.go | \
  699. sed -e 's/_ip_mreq/IPMreq/' \
  700. -e 's/imr_multiaddr/Multiaddr/' \
  701. -e 's/imr_interface/Interface/' \
  702. -e 's/_in_addr/[4]byte/g' \
  703. >> ${OUT}
  704. # We need IPMreq to compile the net package.
  705. if ! grep 'type IPMreq ' ${OUT} >/dev/null 2>&1; then
  706. echo 'type IPMreq struct { Multiaddr [4]byte; Interface [4]byte; }' >> ${OUT}
  707. fi
  708. # The ipv6_mreq struct.
  709. grep '^type _ipv6_mreq ' gen-sysinfo.go | \
  710. sed -e 's/_ipv6_mreq/IPv6Mreq/' \
  711. -e 's/ipv6mr_multiaddr/Multiaddr/' \
  712. -e 's/ipv6mr_interface/Interface/' \
  713. -e 's/_in6_addr/[16]byte/' \
  714. >> ${OUT}
  715. # We need IPv6Mreq to compile the net package.
  716. if ! grep 'type IPv6Mreq ' ${OUT} >/dev/null 2>&1; then
  717. echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT}
  718. fi
  719. # The ip_mreqn struct.
  720. grep '^type _ip_mreqn ' gen-sysinfo.go | \
  721. sed -e 's/_ip_mreqn/IPMreqn/' \
  722. -e 's/imr_multiaddr/Multiaddr/' \
  723. -e 's/imr_address/Address/' \
  724. -e 's/imr_ifindex/Ifindex/' \
  725. -e 's/_in_addr/[4]byte/g' \
  726. >> ${OUT}
  727. # We need IPMreq to compile the net package.
  728. if ! grep 'type IPMreqn ' ${OUT} >/dev/null 2>&1; then
  729. echo 'type IPMreqn struct { Multiaddr [4]byte; Interface [4]byte; Ifindex int32 }' >> ${OUT}
  730. fi
  731. # The icmp6_filter struct.
  732. grep '^type _icmp6_filter ' gen-sysinfo.go | \
  733. sed -e 's/_icmp6_filter/ICMPv6Filter/' \
  734. -e 's/data/Data/' \
  735. -e 's/filt/Filt/' \
  736. >> ${OUT}
  737. # We need ICMPv6Filter to compile the syscall package.
  738. if ! grep 'type ICMPv6Filter ' ${OUT} > /dev/null 2>&1; then
  739. echo 'type ICMPv6Filter struct { Data [8]uint32 }' >> ${OUT}
  740. fi
  741. # Try to guess the type to use for fd_set.
  742. fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true`
  743. fds_bits_type="_C_long"
  744. if test "$fd_set" != ""; then
  745. fds_bits_type=`echo $fd_set | sed -e 's/.*[]]\([^;]*\); }$/\1/'`
  746. fi
  747. echo "type fds_bits_type $fds_bits_type" >> ${OUT}
  748. # The addrinfo struct.
  749. grep '^type _addrinfo ' gen-sysinfo.go | \
  750. sed -e 's/_addrinfo/Addrinfo/g' \
  751. -e 's/ ai_/ Ai_/g' \
  752. >> ${OUT}
  753. # The addrinfo flags and errors.
  754. grep '^const _AI_' gen-sysinfo.go | \
  755. sed -e 's/^\(const \)_\(AI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  756. grep '^const _EAI_' gen-sysinfo.go | \
  757. sed -e 's/^\(const \)_\(EAI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  758. # The passwd struct.
  759. grep '^type _passwd ' gen-sysinfo.go | \
  760. sed -e 's/_passwd/Passwd/' \
  761. -e 's/ pw_/ Pw_/g' \
  762. >> ${OUT}
  763. # The ioctl flags for the controlling TTY.
  764. grep '^const _TIOC' gen-sysinfo.go | \
  765. grep -v '_val =' | \
  766. sed -e 's/^\(const \)_\(TIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  767. # We need TIOCGWINSZ.
  768. if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then
  769. if grep '^const _TIOCGWINSZ_val' ${OUT} >/dev/null 2>&1; then
  770. echo 'const TIOCGWINSZ = _TIOCGWINSZ_val' >> ${OUT}
  771. fi
  772. fi
  773. if ! grep '^const TIOCSWINSZ' ${OUT} >/dev/null 2>&1; then
  774. if grep '^const _TIOCSWINSZ_val' ${OUT} >/dev/null 2>&1; then
  775. echo 'const TIOCSWINSZ = _TIOCSWINSZ_val' >> ${OUT}
  776. fi
  777. fi
  778. if ! grep '^const TIOCNOTTY' ${OUT} >/dev/null 2>&1; then
  779. if grep '^const _TIOCNOTTY_val' ${OUT} >/dev/null 2>&1; then
  780. echo 'const TIOCNOTTY = _TIOCNOTTY_val' >> ${OUT}
  781. fi
  782. fi
  783. if ! grep '^const TIOCSCTTY' ${OUT} >/dev/null 2>&1; then
  784. if grep '^const _TIOCSCTTY_val' ${OUT} >/dev/null 2>&1; then
  785. echo 'const TIOCSCTTY = _TIOCSCTTY_val' >> ${OUT}
  786. fi
  787. fi
  788. if ! grep '^const TIOCGPTN' ${OUT} >/dev/null 2>&1; then
  789. if grep '^const _TIOCGPTN_val' ${OUT} >/dev/null 2>&1; then
  790. echo 'const TIOCGPTN = _TIOCGPTN_val' >> ${OUT}
  791. fi
  792. fi
  793. if ! grep '^const TIOCSPTLCK' ${OUT} >/dev/null 2>&1; then
  794. if grep '^const _TIOCSPTLCK_val' ${OUT} >/dev/null 2>&1; then
  795. echo 'const TIOCSPTLCK = _TIOCSPTLCK_val' >> ${OUT}
  796. fi
  797. fi
  798. if ! grep '^const TIOCGDEV' ${OUT} >/dev/null 2>&1; then
  799. if grep '^const _TIOCGDEV_val' ${OUT} >/dev/null 2>&1; then
  800. echo 'const TIOCGDEV = _TIOCGDEV_val' >> ${OUT}
  801. fi
  802. fi
  803. if ! grep '^const TIOCSIG' ${OUT} >/dev/null 2>&1; then
  804. if grep '^const _TIOCSIG_val' ${OUT} >/dev/null 2>&1; then
  805. echo 'const TIOCSIG = _TIOCSIG_val' >> ${OUT}
  806. fi
  807. fi
  808. # The ioctl flags for terminal control
  809. grep '^const _TC[GS]ET' gen-sysinfo.go | grep -v _val | \
  810. sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  811. if ! grep '^const TCGETS' ${OUT} >/dev/null 2>&1; then
  812. if grep '^const _TCGETS_val' ${OUT} >/dev/null 2>&1; then
  813. echo 'const TCGETS = _TCGETS_val' >> ${OUT}
  814. fi
  815. fi
  816. if ! grep '^const TCSETS' ${OUT} >/dev/null 2>&1; then
  817. if grep '^const _TCSETS_val' ${OUT} >/dev/null 2>&1; then
  818. echo 'const TCSETS = _TCSETS_val' >> ${OUT}
  819. fi
  820. fi
  821. # ioctl constants. Might fall back to 0 if TIOCNXCL is missing, too, but
  822. # needs handling in syscalls.exec.go.
  823. if ! grep '^const _TIOCSCTTY ' gen-sysinfo.go >/dev/null 2>&1; then
  824. if grep '^const _TIOCNXCL ' gen-sysinfo.go >/dev/null 2>&1; then
  825. echo "const TIOCSCTTY = TIOCNXCL" >> ${OUT}
  826. fi
  827. fi
  828. # The nlmsghdr struct.
  829. grep '^type _nlmsghdr ' gen-sysinfo.go | \
  830. sed -e 's/_nlmsghdr/NlMsghdr/' \
  831. -e 's/nlmsg_len/Len/' \
  832. -e 's/nlmsg_type/Type/' \
  833. -e 's/nlmsg_flags/Flags/' \
  834. -e 's/nlmsg_seq/Seq/' \
  835. -e 's/nlmsg_pid/Pid/' \
  836. >> ${OUT}
  837. # The nlmsg flags and operators.
  838. grep '^const _NLM' gen-sysinfo.go | \
  839. sed -e 's/^\(const \)_\(NLM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  840. # NLMSG_HDRLEN is defined as an expression using sizeof.
  841. if ! grep '^const NLMSG_HDRLEN' ${OUT} > /dev/null 2>&1; then
  842. if grep '^const _sizeof_nlmsghdr ' ${OUT} > /dev/null 2>&1; then
  843. echo 'const NLMSG_HDRLEN = (_sizeof_nlmsghdr + (NLMSG_ALIGNTO-1)) &^ (NLMSG_ALIGNTO-1)' >> ${OUT}
  844. fi
  845. fi
  846. # The rtmsg struct.
  847. grep '^type _rtmsg ' gen-sysinfo.go | \
  848. sed -e 's/_rtmsg/RtMsg/' \
  849. -e 's/rtm_family/Family/' \
  850. -e 's/rtm_dst_len/Dst_len/' \
  851. -e 's/rtm_src_len/Src_len/' \
  852. -e 's/rtm_tos/Tos/' \
  853. -e 's/rtm_table/Table/' \
  854. -e 's/rtm_protocol/Protocol/' \
  855. -e 's/rtm_scope/Scope/' \
  856. -e 's/rtm_type/Type/' \
  857. -e 's/rtm_flags/Flags/' \
  858. >> ${OUT}
  859. # The rtgenmsg struct.
  860. grep '^type _rtgenmsg ' gen-sysinfo.go | \
  861. sed -e 's/_rtgenmsg/RtGenmsg/' \
  862. -e 's/rtgen_family/Family/' \
  863. >> ${OUT}
  864. # The routing message flags.
  865. grep '^const _RT_' gen-sysinfo.go | \
  866. sed -e 's/^\(const \)_\(RT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  867. grep '^const _RTA' gen-sysinfo.go | \
  868. sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  869. grep '^const _RTF' gen-sysinfo.go | \
  870. sed -e 's/^\(const \)_\(RTF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  871. grep '^const _RTCF' gen-sysinfo.go | \
  872. sed -e 's/^\(const \)_\(RTCF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  873. grep '^const _RTM' gen-sysinfo.go | \
  874. sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  875. grep '^const _RTN' gen-sysinfo.go | \
  876. sed -e 's/^\(const \)_\(RTN[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  877. grep '^const _RTPROT' gen-sysinfo.go | \
  878. sed -e 's/^\(const \)_\(RTPROT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  879. # The ifinfomsg struct.
  880. grep '^type _ifinfomsg ' gen-sysinfo.go | \
  881. sed -e 's/_ifinfomsg/IfInfomsg/' \
  882. -e 's/ifi_family/Family/' \
  883. -e 's/ifi_type/Type/' \
  884. -e 's/ifi_index/Index/' \
  885. -e 's/ifi_flags/Flags/' \
  886. -e 's/ifi_change/Change/' \
  887. >> ${OUT}
  888. # The interface information types and flags.
  889. grep '^const _IFA' gen-sysinfo.go | \
  890. sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  891. grep '^const _IFLA' gen-sysinfo.go | \
  892. sed -e 's/^\(const \)_\(IFLA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  893. grep '^const _IFF' gen-sysinfo.go | \
  894. sed -e 's/^\(const \)_\(IFF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  895. grep '^const _IFNAMSIZ' gen-sysinfo.go | \
  896. sed -e 's/^\(const \)_\(IFNAMSIZ[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  897. grep '^const _SIOC' gen-sysinfo.go |
  898. sed -e 's/^\(const \)_\(SIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  899. # The ifaddrmsg struct.
  900. grep '^type _ifaddrmsg ' gen-sysinfo.go | \
  901. sed -e 's/_ifaddrmsg/IfAddrmsg/' \
  902. -e 's/ifa_family/Family/' \
  903. -e 's/ifa_prefixlen/Prefixlen/' \
  904. -e 's/ifa_flags/Flags/' \
  905. -e 's/ifa_scope/Scope/' \
  906. -e 's/ifa_index/Index/' \
  907. >> ${OUT}
  908. # The rtattr struct.
  909. grep '^type _rtattr ' gen-sysinfo.go | \
  910. sed -e 's/_rtattr/RtAttr/' \
  911. -e 's/rta_len/Len/' \
  912. -e 's/rta_type/Type/' \
  913. >> ${OUT}
  914. # The in_pktinfo struct.
  915. grep '^type _in_pktinfo ' gen-sysinfo.go | \
  916. sed -e 's/_in_pktinfo/Inet4Pktinfo/' \
  917. -e 's/ipi_ifindex/Ifindex/' \
  918. -e 's/ipi_spec_dst/Spec_dst/' \
  919. -e 's/ipi_addr/Addr/' \
  920. -e 's/_in_addr/[4]byte/g' \
  921. >> ${OUT}
  922. # The in6_pktinfo struct.
  923. grep '^type _in6_pktinfo ' gen-sysinfo.go | \
  924. sed -e 's/_in6_pktinfo/Inet6Pktinfo/' \
  925. -e 's/ipi6_addr/Addr/' \
  926. -e 's/ipi6_ifindex/Ifindex/' \
  927. -e 's/_in6_addr/[16]byte/' \
  928. >> ${OUT}
  929. # The termios struct.
  930. grep '^type _termios ' gen-sysinfo.go | \
  931. sed -e 's/_termios/Termios/' \
  932. -e 's/c_iflag/Iflag/' \
  933. -e 's/c_oflag/Oflag/' \
  934. -e 's/c_cflag/Cflag/' \
  935. -e 's/c_lflag/Lflag/' \
  936. -e 's/c_line/Line/' \
  937. -e 's/c_cc/Cc/' \
  938. -e 's/c_ispeed/Ispeed/' \
  939. -e 's/c_ospeed/Ospeed/' \
  940. >> ${OUT}
  941. # The termios constants.
  942. for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \
  943. IXON IXANY IXOFF IMAXBEL IUTF8 OPOST OLCUC ONLCR OCRNL ONOCR ONLRET \
  944. OFILL OFDEL NLDLY NL0 NL1 CRDLY CR0 CR1 CR2 CR3 CS5 CS6 CS7 CS8 TABDLY \
  945. BSDLY VTDLY FFDLY CBAUD CBAUDEX CSIZE CSTOPB CREAD PARENB PARODD HUPCL \
  946. CLOCAL LOBLK CIBAUD CMSPAR CRTSCTS ISIG ICANON XCASE ECHO ECHOE ECHOK \
  947. ECHONL ECHOCTL ECHOPRT ECHOKE DEFECHO FLUSHO NOFLSH TOSTOP PENDIN IEXTEN \
  948. VINTR VQUIT VERASE VKILL VEOF VMIN VEOL VTIME VEOL2 VSWTCH VSTART VSTOP \
  949. VSUSP VDSUSP VLNEXT VWERASE VREPRINT VDISCARD VSTATUS TCSANOW TCSADRAIN \
  950. TCSAFLUSH TCIFLUSH TCOFLUSH TCIOFLUSH TCOOFF TCOON TCIOFF TCION B0 B50 \
  951. B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 \
  952. B38400 B57600 B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \
  953. B1152000 B1500000 B2000000 B2500000 B3000000 B3500000 B4000000; do
  954. grep "^const _$n " gen-sysinfo.go | \
  955. sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  956. done
  957. # The mount flags
  958. grep '^const _MNT_' gen-sysinfo.go |
  959. sed -e 's/^\(const \)_\(MNT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  960. grep '^const _MS_' gen-sysinfo.go |
  961. sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  962. # The fallocate flags.
  963. grep '^const _FALLOC_' gen-sysinfo.go |
  964. sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  965. # The statfs struct.
  966. # Prefer largefile variant if available.
  967. statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true`
  968. if test "$statfs" != ""; then
  969. grep '^type _statfs64 ' gen-sysinfo.go
  970. else
  971. grep '^type _statfs ' gen-sysinfo.go
  972. fi | sed -e 's/type _statfs64/type Statfs_t/' \
  973. -e 's/type _statfs/type Statfs_t/' \
  974. -e 's/f_type/Type/' \
  975. -e 's/f_bsize/Bsize/' \
  976. -e 's/f_blocks/Blocks/' \
  977. -e 's/f_bfree/Bfree/' \
  978. -e 's/f_bavail/Bavail/' \
  979. -e 's/f_files/Files/' \
  980. -e 's/f_ffree/Ffree/' \
  981. -e 's/f_fsid/Fsid/' \
  982. -e 's/f_namelen/Namelen/' \
  983. -e 's/f_frsize/Frsize/' \
  984. -e 's/f_flags/Flags/' \
  985. -e 's/f_spare/Spare/' \
  986. >> ${OUT}
  987. # The timex struct.
  988. timex=`grep '^type _timex ' gen-sysinfo.go || true`
  989. if test "$timex" = ""; then
  990. timex=`grep '^// type _timex ' gen-sysinfo.go || true`
  991. if test "$timex" != ""; then
  992. timex=`echo $timex | sed -e 's|// ||' -e 's/INVALID-bit-field/int32/g'`
  993. fi
  994. fi
  995. if test "$timex" != ""; then
  996. echo "$timex" | \
  997. sed -e 's/_timex/Timex/' \
  998. -e 's/modes/Modes/' \
  999. -e 's/offset/Offset/' \
  1000. -e 's/freq/Freq/' \
  1001. -e 's/maxerror/Maxerror/' \
  1002. -e 's/esterror/Esterror/' \
  1003. -e 's/status/Status/' \
  1004. -e 's/constant/Constant/' \
  1005. -e 's/precision/Precision/' \
  1006. -e 's/tolerance/Tolerance/' \
  1007. -e 's/ time / Time /' \
  1008. -e 's/tick/Tick/' \
  1009. -e 's/ppsfreq/Ppsfreq/' \
  1010. -e 's/jitter/Jitter/' \
  1011. -e 's/shift/Shift/' \
  1012. -e 's/stabil/Stabil/' \
  1013. -e 's/jitcnt/Jitcnt/' \
  1014. -e 's/calcnt/Calcnt/' \
  1015. -e 's/errcnt/Errcnt/' \
  1016. -e 's/stbcnt/Stbcnt/' \
  1017. -e 's/tai/Tai/' \
  1018. -e 's/_timeval/Timeval/' \
  1019. >> ${OUT}
  1020. fi
  1021. # The rlimit struct.
  1022. grep '^type _rlimit ' gen-sysinfo.go | \
  1023. sed -e 's/_rlimit/Rlimit/' \
  1024. -e 's/rlim_cur/Cur/' \
  1025. -e 's/rlim_max/Max/' \
  1026. >> ${OUT}
  1027. # The RLIMIT constants.
  1028. grep '^const _RLIMIT_' gen-sysinfo.go |
  1029. sed -e 's/^\(const \)_\(RLIMIT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1030. grep '^const _RLIM_' gen-sysinfo.go |
  1031. sed -e 's/^\(const \)_\(RLIM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1032. # The sysinfo struct.
  1033. grep '^type _sysinfo ' gen-sysinfo.go | \
  1034. sed -e 's/_sysinfo/Sysinfo_t/' \
  1035. -e 's/uptime/Uptime/' \
  1036. -e 's/loads/Loads/' \
  1037. -e 's/totalram/Totalram/' \
  1038. -e 's/freeram/Freeram/' \
  1039. -e 's/sharedram/Sharedram/' \
  1040. -e 's/bufferram/Bufferram/' \
  1041. -e 's/totalswap/Totalswap/' \
  1042. -e 's/freeswap/Freeswap/' \
  1043. -e 's/procs/Procs/' \
  1044. -e 's/totalhigh/Totalhigh/' \
  1045. -e 's/freehigh/Freehigh/' \
  1046. -e 's/mem_unit/Unit/' \
  1047. >> ${OUT}
  1048. # The ustat struct.
  1049. grep '^type _ustat ' gen-sysinfo.go | \
  1050. sed -e 's/_ustat/Ustat_t/' \
  1051. -e 's/f_tfree/Tfree/' \
  1052. -e 's/f_tinode/Tinoe/' \
  1053. -e 's/f_fname/Fname/' \
  1054. -e 's/f_fpack/Fpack/' \
  1055. >> ${OUT}
  1056. # Force it to be defined, as on some older GNU/Linux systems the
  1057. # header file fails when using with <linux/filter.h>.
  1058. if ! grep 'type _ustat ' gen-sysinfo.go >/dev/null 2>&1; then
  1059. echo 'type Ustat_t struct { Tfree int32; Tinoe uint64; Fname [5+1]int8; Fpack [5+1]int8; }' >> ${OUT}
  1060. fi
  1061. # The utimbuf struct.
  1062. grep '^type _utimbuf ' gen-sysinfo.go | \
  1063. sed -e 's/_utimbuf/Utimbuf/' \
  1064. -e 's/actime/Actime/' \
  1065. -e 's/modtime/Modtime/' \
  1066. >> ${OUT}
  1067. # The LOCK flags for flock.
  1068. grep '^const _LOCK_' gen-sysinfo.go |
  1069. sed -e 's/^\(const \)_\(LOCK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1070. # The PRIO constants.
  1071. grep '^const _PRIO_' gen-sysinfo.go | \
  1072. sed -e 's/^\(const \)_\(PRIO_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1073. # The GNU/Linux LINUX_REBOOT flags.
  1074. grep '^const _LINUX_REBOOT_' gen-sysinfo.go |
  1075. sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1076. # The GNU/Linux sock_filter struct.
  1077. grep '^type _sock_filter ' gen-sysinfo.go | \
  1078. sed -e 's/_sock_filter/SockFilter/' \
  1079. -e 's/code/Code/' \
  1080. -e 's/jt/Jt/' \
  1081. -e 's/jf/Jf/' \
  1082. -e 's/k /K /' \
  1083. >> ${OUT}
  1084. # The GNU/Linux sock_fprog struct.
  1085. grep '^type _sock_fprog ' gen-sysinfo.go | \
  1086. sed -e 's/_sock_fprog/SockFprog/' \
  1087. -e 's/len/Len/' \
  1088. -e 's/filter/Filter/' \
  1089. -e 's/_sock_filter/SockFilter/' \
  1090. >> ${OUT}
  1091. # The GNU/Linux filter flags.
  1092. grep '^const _BPF_' gen-sysinfo.go | \
  1093. sed -e 's/^\(const \)_\(BPF_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1094. # The GNU/Linux nlattr struct.
  1095. grep '^type _nlattr ' gen-sysinfo.go | \
  1096. sed -e 's/_nlattr/NlAttr/' \
  1097. -e 's/nla_len/Len/' \
  1098. -e 's/nla_type/Type/' \
  1099. >> ${OUT}
  1100. # The GNU/Linux nlmsgerr struct.
  1101. grep '^type _nlmsgerr ' gen-sysinfo.go | \
  1102. sed -e 's/_nlmsgerr/NlMsgerr/' \
  1103. -e 's/error/Error/' \
  1104. -e 's/msg/Msg/' \
  1105. -e 's/_nlmsghdr/NlMsghdr/' \
  1106. >> ${OUT}
  1107. # The GNU/Linux rtnexthop struct.
  1108. grep '^type _rtnexthop ' gen-sysinfo.go | \
  1109. sed -e 's/_rtnexthop/RtNexthop/' \
  1110. -e 's/rtnh_len/Len/' \
  1111. -e 's/rtnh_flags/Flags/' \
  1112. -e 's/rtnh_hops/Hops/' \
  1113. -e 's/rtnh_ifindex/Ifindex/' \
  1114. >> ${OUT}
  1115. # The GNU/Linux netlink flags.
  1116. grep '^const _NETLINK_' gen-sysinfo.go | \
  1117. sed -e 's/^\(const \)_\(NETLINK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1118. grep '^const _NLA_' gen-sysinfo.go | \
  1119. sed -e 's/^\(const \)_\(NLA_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1120. # The GNU/Linux packet socket flags.
  1121. grep '^const _PACKET_' gen-sysinfo.go | \
  1122. sed -e 's/^\(const \)_\(PACKET_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1123. # The GNU/Linux inotify_event struct.
  1124. grep '^type _inotify_event ' gen-sysinfo.go | \
  1125. sed -e 's/_inotify_event/InotifyEvent/' \
  1126. -e 's/wd/Wd/' \
  1127. -e 's/mask/Mask/' \
  1128. -e 's/cookie/Cookie/' \
  1129. -e 's/len/Len/' \
  1130. -e 's/name/Name/' \
  1131. -e 's/\[\]/[0]/' \
  1132. -e 's/\[0\]byte/[0]int8/' \
  1133. >> ${OUT}
  1134. # The GNU/Linux CLONE flags.
  1135. grep '^const _CLONE_' gen-sysinfo.go | \
  1136. sed -e 's/^\(const \)_\(CLONE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
  1137. # Struct sizes.
  1138. set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \
  1139. ifaddrmsg IfAddrmsg ifinfomsg IfInfomsg in_pktinfo Inet4Pktinfo \
  1140. in6_pktinfo Inet6Pktinfo inotify_event InotifyEvent linger Linger \
  1141. msghdr Msghdr nlattr NlAttr nlmsgerr NlMsgerr nlmsghdr NlMsghdr \
  1142. rtattr RtAttr rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \
  1143. sock_filter SockFilter sock_fprog SockFprog ucred Ucred \
  1144. icmp6_filter ICMPv6Filter
  1145. while test $# != 0; do
  1146. nc=$1
  1147. ngo=$2
  1148. shift
  1149. shift
  1150. if grep "^const _sizeof_$nc =" gen-sysinfo.go >/dev/null 2>&1; then
  1151. echo "const Sizeof$ngo = _sizeof_$nc" >> ${OUT}
  1152. fi
  1153. done
  1154. # In order to compile the net package, we need some sizes to exist
  1155. # even if the types do not.
  1156. if ! grep 'const SizeofIPMreq ' ${OUT} >/dev/null 2>&1; then
  1157. echo 'const SizeofIPMreq = 8' >> ${OUT}
  1158. fi
  1159. if ! grep 'const SizeofIPv6Mreq ' ${OUT} >/dev/null 2>&1; then
  1160. echo 'const SizeofIPv6Mreq = 20' >> ${OUT}
  1161. fi
  1162. if ! grep 'const SizeofIPMreqn ' ${OUT} >/dev/null 2>&1; then
  1163. echo 'const SizeofIPMreqn = 12' >> ${OUT}
  1164. fi
  1165. if ! grep 'const SizeofICMPv6Filter ' ${OUT} >/dev/null 2>&1; then
  1166. echo 'const SizeofICMPv6Filter = 32' >> ${OUT}
  1167. fi
  1168. # The Solaris 11 Update 1 _zone_net_addr_t struct.
  1169. grep '^type _zone_net_addr_t ' gen-sysinfo.go | \
  1170. sed -e 's/_in6_addr/[16]byte/' \
  1171. >> ${OUT}
  1172. exit $?