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//go:build ignore 6// +build ignore 7 8/* 9Input to cgo -godefs. See README.md 10*/ 11 12// +godefs map struct_in_addr [4]byte /* in_addr */ 13// +godefs map struct_in6_addr [16]byte /* in6_addr */ 14 15package unix 16 17/* 18#define KERNEL 19#include <dirent.h> 20#include <fcntl.h> 21#include <poll.h> 22#include <signal.h> 23#include <termios.h> 24#include <stdio.h> 25#include <unistd.h> 26#include <sys/param.h> 27#include <sys/types.h> 28#include <sys/event.h> 29#include <sys/mman.h> 30#include <sys/mount.h> 31#include <sys/ptrace.h> 32#include <sys/resource.h> 33#include <sys/select.h> 34#include <sys/signal.h> 35#include <sys/socket.h> 36#include <sys/stat.h> 37#include <sys/statvfs.h> 38#include <sys/sysctl.h> 39#include <sys/time.h> 40#include <sys/uio.h> 41#include <sys/un.h> 42#include <sys/utsname.h> 43#include <sys/wait.h> 44#include <net/bpf.h> 45#include <net/if.h> 46#include <net/if_dl.h> 47#include <net/route.h> 48#include <netinet/in.h> 49#include <netinet/icmp6.h> 50#include <netinet/tcp.h> 51 52enum { 53 sizeofPtr = sizeof(void*), 54}; 55 56union sockaddr_all { 57 struct sockaddr s1; // this one gets used for fields 58 struct sockaddr_in s2; // these pad it out 59 struct sockaddr_in6 s3; 60 struct sockaddr_un s4; 61 struct sockaddr_dl s5; 62}; 63 64struct sockaddr_any { 65 struct sockaddr addr; 66 char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 67}; 68 69*/ 70import "C" 71 72// Machine characteristics 73 74const ( 75 SizeofPtr = C.sizeofPtr 76 SizeofShort = C.sizeof_short 77 SizeofInt = C.sizeof_int 78 SizeofLong = C.sizeof_long 79 SizeofLongLong = C.sizeof_longlong 80) 81 82// Basic types 83 84type ( 85 _C_short C.short 86 _C_int C.int 87 _C_long C.long 88 _C_long_long C.longlong 89) 90 91// Time 92 93type Timespec C.struct_timespec 94 95type Timeval C.struct_timeval 96 97// Processes 98 99type Rusage C.struct_rusage 100 101type Rlimit C.struct_rlimit 102 103type _Gid_t C.gid_t 104 105// Files 106 107type Stat_t C.struct_stat 108 109type Statfs_t C.struct_statfs 110 111type Statvfs_t C.struct_statvfs 112 113type Flock_t C.struct_flock 114 115type Dirent C.struct_dirent 116 117type Fsid C.fsid_t 118 119// File system limits 120 121const ( 122 PathMax = C.PATH_MAX 123) 124 125// Fstatvfs/Statvfs flags 126 127const ( 128 ST_WAIT = C.ST_WAIT 129 ST_NOWAIT = C.ST_NOWAIT 130) 131 132// Advice to Fadvise 133 134const ( 135 FADV_NORMAL = C.POSIX_FADV_NORMAL 136 FADV_RANDOM = C.POSIX_FADV_RANDOM 137 FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL 138 FADV_WILLNEED = C.POSIX_FADV_WILLNEED 139 FADV_DONTNEED = C.POSIX_FADV_DONTNEED 140 FADV_NOREUSE = C.POSIX_FADV_NOREUSE 141) 142 143// Sockets 144 145type RawSockaddrInet4 C.struct_sockaddr_in 146 147type RawSockaddrInet6 C.struct_sockaddr_in6 148 149type RawSockaddrUnix C.struct_sockaddr_un 150 151type RawSockaddrDatalink C.struct_sockaddr_dl 152 153type RawSockaddr C.struct_sockaddr 154 155type RawSockaddrAny C.struct_sockaddr_any 156 157type _Socklen C.socklen_t 158 159type Linger C.struct_linger 160 161type Iovec C.struct_iovec 162 163type IPMreq C.struct_ip_mreq 164 165type IPv6Mreq C.struct_ipv6_mreq 166 167type Msghdr C.struct_msghdr 168 169type Cmsghdr C.struct_cmsghdr 170 171type Inet6Pktinfo C.struct_in6_pktinfo 172 173type IPv6MTUInfo C.struct_ip6_mtuinfo 174 175type ICMPv6Filter C.struct_icmp6_filter 176 177const ( 178 SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 179 SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 180 SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 181 SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 182 SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 183 SizeofLinger = C.sizeof_struct_linger 184 SizeofIovec = C.sizeof_struct_iovec 185 SizeofIPMreq = C.sizeof_struct_ip_mreq 186 SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 187 SizeofMsghdr = C.sizeof_struct_msghdr 188 SizeofCmsghdr = C.sizeof_struct_cmsghdr 189 SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 190 SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 191 SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 192) 193 194// Ptrace requests 195 196const ( 197 PTRACE_TRACEME = C.PT_TRACE_ME 198 PTRACE_CONT = C.PT_CONTINUE 199 PTRACE_KILL = C.PT_KILL 200) 201 202// Events (kqueue, kevent) 203 204type Kevent_t C.struct_kevent 205 206// Select 207 208type FdSet C.fd_set 209 210// Routing and interface messages 211 212const ( 213 SizeofIfMsghdr = C.sizeof_struct_if_msghdr 214 SizeofIfData = C.sizeof_struct_if_data 215 SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 216 SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 217 SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 218 SizeofRtMetrics = C.sizeof_struct_rt_metrics 219) 220 221type IfMsghdr C.struct_if_msghdr 222 223type IfData C.struct_if_data 224 225type IfaMsghdr C.struct_ifa_msghdr 226 227type IfAnnounceMsghdr C.struct_if_announcemsghdr 228 229type RtMsghdr C.struct_rt_msghdr 230 231type RtMetrics C.struct_rt_metrics 232 233type Mclpool C.struct_mclpool 234 235// Berkeley packet filter 236 237const ( 238 SizeofBpfVersion = C.sizeof_struct_bpf_version 239 SizeofBpfStat = C.sizeof_struct_bpf_stat 240 SizeofBpfProgram = C.sizeof_struct_bpf_program 241 SizeofBpfInsn = C.sizeof_struct_bpf_insn 242 SizeofBpfHdr = C.sizeof_struct_bpf_hdr 243) 244 245type BpfVersion C.struct_bpf_version 246 247type BpfStat C.struct_bpf_stat 248 249type BpfProgram C.struct_bpf_program 250 251type BpfInsn C.struct_bpf_insn 252 253type BpfHdr C.struct_bpf_hdr 254 255type BpfTimeval C.struct_bpf_timeval 256 257// Terminal handling 258 259type Termios C.struct_termios 260 261type Winsize C.struct_winsize 262 263type Ptmget C.struct_ptmget 264 265// fchmodat-like syscalls. 266 267const ( 268 AT_FDCWD = C.AT_FDCWD 269 AT_EACCESS = C.AT_EACCESS 270 AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 271 AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW 272 AT_REMOVEDIR = C.AT_REMOVEDIR 273) 274 275// poll 276 277type PollFd C.struct_pollfd 278 279const ( 280 POLLERR = C.POLLERR 281 POLLHUP = C.POLLHUP 282 POLLIN = C.POLLIN 283 POLLNVAL = C.POLLNVAL 284 POLLOUT = C.POLLOUT 285 POLLPRI = C.POLLPRI 286 POLLRDBAND = C.POLLRDBAND 287 POLLRDNORM = C.POLLRDNORM 288 POLLWRBAND = C.POLLWRBAND 289 POLLWRNORM = C.POLLWRNORM 290) 291 292// Sysctl 293 294type Sysctlnode C.struct_sysctlnode 295 296// Uname 297 298type Utsname C.struct_utsname 299 300// Clockinfo 301 302const SizeofClockinfo = C.sizeof_struct_clockinfo 303 304type Clockinfo C.struct_clockinfo 305