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