David K. Bainbridge | 215e024 | 2017-09-05 23:18:24 -0700 | [diff] [blame] | 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 | |
| 5 | // +build ignore |
| 6 | |
| 7 | /* |
| 8 | Input to cgo -godefs. See README.md |
| 9 | */ |
| 10 | |
| 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ |
| 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ |
| 13 | |
| 14 | package unix |
| 15 | |
| 16 | /* |
| 17 | #define KERNEL |
| 18 | // These defines ensure that builds done on newer versions of Solaris are |
| 19 | // backwards-compatible with older versions of Solaris and |
| 20 | // OpenSolaris-based derivatives. |
| 21 | #define __USE_SUNOS_SOCKETS__ // msghdr |
| 22 | #define __USE_LEGACY_PROTOTYPES__ // iovec |
| 23 | #include <dirent.h> |
| 24 | #include <fcntl.h> |
| 25 | #include <netdb.h> |
| 26 | #include <limits.h> |
| 27 | #include <signal.h> |
| 28 | #include <termios.h> |
| 29 | #include <termio.h> |
| 30 | #include <stdio.h> |
| 31 | #include <unistd.h> |
| 32 | #include <sys/mman.h> |
| 33 | #include <sys/mount.h> |
| 34 | #include <sys/param.h> |
| 35 | #include <sys/resource.h> |
| 36 | #include <sys/select.h> |
| 37 | #include <sys/signal.h> |
| 38 | #include <sys/socket.h> |
| 39 | #include <sys/stat.h> |
| 40 | #include <sys/statvfs.h> |
| 41 | #include <sys/time.h> |
| 42 | #include <sys/times.h> |
| 43 | #include <sys/types.h> |
| 44 | #include <sys/utsname.h> |
| 45 | #include <sys/un.h> |
| 46 | #include <sys/wait.h> |
| 47 | #include <net/bpf.h> |
| 48 | #include <net/if.h> |
| 49 | #include <net/if_dl.h> |
| 50 | #include <net/route.h> |
| 51 | #include <netinet/in.h> |
| 52 | #include <netinet/icmp6.h> |
| 53 | #include <netinet/tcp.h> |
| 54 | #include <ustat.h> |
| 55 | #include <utime.h> |
| 56 | |
| 57 | enum { |
| 58 | sizeofPtr = sizeof(void*), |
| 59 | }; |
| 60 | |
| 61 | union sockaddr_all { |
| 62 | struct sockaddr s1; // this one gets used for fields |
| 63 | struct sockaddr_in s2; // these pad it out |
| 64 | struct sockaddr_in6 s3; |
| 65 | struct sockaddr_un s4; |
| 66 | struct sockaddr_dl s5; |
| 67 | }; |
| 68 | |
| 69 | struct sockaddr_any { |
| 70 | struct sockaddr addr; |
| 71 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; |
| 72 | }; |
| 73 | |
| 74 | */ |
| 75 | import "C" |
| 76 | |
| 77 | // Machine characteristics; for internal use. |
| 78 | |
| 79 | const ( |
| 80 | sizeofPtr = C.sizeofPtr |
| 81 | sizeofShort = C.sizeof_short |
| 82 | sizeofInt = C.sizeof_int |
| 83 | sizeofLong = C.sizeof_long |
| 84 | sizeofLongLong = C.sizeof_longlong |
| 85 | PathMax = C.PATH_MAX |
| 86 | MaxHostNameLen = C.MAXHOSTNAMELEN |
| 87 | ) |
| 88 | |
| 89 | // Basic types |
| 90 | |
| 91 | type ( |
| 92 | _C_short C.short |
| 93 | _C_int C.int |
| 94 | _C_long C.long |
| 95 | _C_long_long C.longlong |
| 96 | ) |
| 97 | |
| 98 | // Time |
| 99 | |
| 100 | type Timespec C.struct_timespec |
| 101 | |
| 102 | type Timeval C.struct_timeval |
| 103 | |
| 104 | type Timeval32 C.struct_timeval32 |
| 105 | |
| 106 | type Tms C.struct_tms |
| 107 | |
| 108 | type Utimbuf C.struct_utimbuf |
| 109 | |
| 110 | // Processes |
| 111 | |
| 112 | type Rusage C.struct_rusage |
| 113 | |
| 114 | type Rlimit C.struct_rlimit |
| 115 | |
| 116 | type _Gid_t C.gid_t |
| 117 | |
| 118 | // Files |
| 119 | |
| 120 | const ( // Directory mode bits |
| 121 | S_IFMT = C.S_IFMT |
| 122 | S_IFIFO = C.S_IFIFO |
| 123 | S_IFCHR = C.S_IFCHR |
| 124 | S_IFDIR = C.S_IFDIR |
| 125 | S_IFBLK = C.S_IFBLK |
| 126 | S_IFREG = C.S_IFREG |
| 127 | S_IFLNK = C.S_IFLNK |
| 128 | S_IFSOCK = C.S_IFSOCK |
| 129 | S_ISUID = C.S_ISUID |
| 130 | S_ISGID = C.S_ISGID |
| 131 | S_ISVTX = C.S_ISVTX |
| 132 | S_IRUSR = C.S_IRUSR |
| 133 | S_IWUSR = C.S_IWUSR |
| 134 | S_IXUSR = C.S_IXUSR |
| 135 | ) |
| 136 | |
| 137 | type Stat_t C.struct_stat |
| 138 | |
| 139 | type Flock_t C.struct_flock |
| 140 | |
| 141 | type Dirent C.struct_dirent |
| 142 | |
| 143 | // Filesystems |
| 144 | |
| 145 | type _Fsblkcnt_t C.fsblkcnt_t |
| 146 | |
| 147 | type Statvfs_t C.struct_statvfs |
| 148 | |
| 149 | // Sockets |
| 150 | |
| 151 | type RawSockaddrInet4 C.struct_sockaddr_in |
| 152 | |
| 153 | type RawSockaddrInet6 C.struct_sockaddr_in6 |
| 154 | |
| 155 | type RawSockaddrUnix C.struct_sockaddr_un |
| 156 | |
| 157 | type RawSockaddrDatalink C.struct_sockaddr_dl |
| 158 | |
| 159 | type RawSockaddr C.struct_sockaddr |
| 160 | |
| 161 | type RawSockaddrAny C.struct_sockaddr_any |
| 162 | |
| 163 | type _Socklen C.socklen_t |
| 164 | |
| 165 | type Linger C.struct_linger |
| 166 | |
| 167 | type Iovec C.struct_iovec |
| 168 | |
| 169 | type IPMreq C.struct_ip_mreq |
| 170 | |
| 171 | type IPv6Mreq C.struct_ipv6_mreq |
| 172 | |
| 173 | type Msghdr C.struct_msghdr |
| 174 | |
| 175 | type Cmsghdr C.struct_cmsghdr |
| 176 | |
| 177 | type Inet6Pktinfo C.struct_in6_pktinfo |
| 178 | |
| 179 | type IPv6MTUInfo C.struct_ip6_mtuinfo |
| 180 | |
| 181 | type ICMPv6Filter C.struct_icmp6_filter |
| 182 | |
| 183 | const ( |
| 184 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in |
| 185 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 |
| 186 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any |
| 187 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un |
| 188 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl |
| 189 | SizeofLinger = C.sizeof_struct_linger |
| 190 | SizeofIPMreq = C.sizeof_struct_ip_mreq |
| 191 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq |
| 192 | SizeofMsghdr = C.sizeof_struct_msghdr |
| 193 | SizeofCmsghdr = C.sizeof_struct_cmsghdr |
| 194 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo |
| 195 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo |
| 196 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter |
| 197 | ) |
| 198 | |
| 199 | // Select |
| 200 | |
| 201 | type FdSet C.fd_set |
| 202 | |
| 203 | // Misc |
| 204 | |
| 205 | type Utsname C.struct_utsname |
| 206 | |
| 207 | type Ustat_t C.struct_ustat |
| 208 | |
| 209 | const ( |
| 210 | AT_FDCWD = C.AT_FDCWD |
| 211 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW |
| 212 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW |
| 213 | AT_REMOVEDIR = C.AT_REMOVEDIR |
| 214 | AT_EACCESS = C.AT_EACCESS |
| 215 | ) |
| 216 | |
| 217 | // Routing and interface messages |
| 218 | |
| 219 | const ( |
| 220 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr |
| 221 | SizeofIfData = C.sizeof_struct_if_data |
| 222 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr |
| 223 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr |
| 224 | SizeofRtMetrics = C.sizeof_struct_rt_metrics |
| 225 | ) |
| 226 | |
| 227 | type IfMsghdr C.struct_if_msghdr |
| 228 | |
| 229 | type IfData C.struct_if_data |
| 230 | |
| 231 | type IfaMsghdr C.struct_ifa_msghdr |
| 232 | |
| 233 | type RtMsghdr C.struct_rt_msghdr |
| 234 | |
| 235 | type RtMetrics C.struct_rt_metrics |
| 236 | |
| 237 | // Berkeley packet filter |
| 238 | |
| 239 | const ( |
| 240 | SizeofBpfVersion = C.sizeof_struct_bpf_version |
| 241 | SizeofBpfStat = C.sizeof_struct_bpf_stat |
| 242 | SizeofBpfProgram = C.sizeof_struct_bpf_program |
| 243 | SizeofBpfInsn = C.sizeof_struct_bpf_insn |
| 244 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr |
| 245 | ) |
| 246 | |
| 247 | type BpfVersion C.struct_bpf_version |
| 248 | |
| 249 | type BpfStat C.struct_bpf_stat |
| 250 | |
| 251 | type BpfProgram C.struct_bpf_program |
| 252 | |
| 253 | type BpfInsn C.struct_bpf_insn |
| 254 | |
| 255 | type BpfTimeval C.struct_bpf_timeval |
| 256 | |
| 257 | type BpfHdr C.struct_bpf_hdr |
| 258 | |
| 259 | // sysconf information |
| 260 | |
| 261 | const _SC_PAGESIZE = C._SC_PAGESIZE |
| 262 | |
| 263 | // Terminal handling |
| 264 | |
| 265 | type Termios C.struct_termios |
| 266 | |
| 267 | type Termio C.struct_termio |
| 268 | |
| 269 | type Winsize C.struct_winsize |