blob: 80b27781d1e169bfb0c264cc15f3becb1a93e6fa [file] [log] [blame]
David K. Bainbridge215e0242017-09-05 23:18:24 -07001// 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 <signal.h>
21#include <termios.h>
22#include <stdio.h>
23#include <unistd.h>
24#include <sys/event.h>
25#include <sys/mman.h>
26#include <sys/mount.h>
27#include <sys/param.h>
28#include <sys/ptrace.h>
29#include <sys/resource.h>
30#include <sys/select.h>
31#include <sys/signal.h>
32#include <sys/socket.h>
33#include <sys/stat.h>
34#include <sys/time.h>
35#include <sys/types.h>
36#include <sys/un.h>
37#include <sys/wait.h>
38#include <net/bpf.h>
39#include <net/if.h>
40#include <net/if_dl.h>
41#include <net/route.h>
42#include <netinet/in.h>
43#include <netinet/icmp6.h>
44#include <netinet/tcp.h>
45
46enum {
47 sizeofPtr = sizeof(void*),
48};
49
50union sockaddr_all {
51 struct sockaddr s1; // this one gets used for fields
52 struct sockaddr_in s2; // these pad it out
53 struct sockaddr_in6 s3;
54 struct sockaddr_un s4;
55 struct sockaddr_dl s5;
56};
57
58struct sockaddr_any {
59 struct sockaddr addr;
60 char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
61};
62
63*/
64import "C"
65
66// Machine characteristics; for internal use.
67
68const (
69 sizeofPtr = C.sizeofPtr
70 sizeofShort = C.sizeof_short
71 sizeofInt = C.sizeof_int
72 sizeofLong = C.sizeof_long
73 sizeofLongLong = C.sizeof_longlong
74)
75
76// Basic types
77
78type (
79 _C_short C.short
80 _C_int C.int
81 _C_long C.long
82 _C_long_long C.longlong
83)
84
85// Time
86
87type Timespec C.struct_timespec
88
89type Timeval C.struct_timeval
90
91// Processes
92
93type Rusage C.struct_rusage
94
95type Rlimit C.struct_rlimit
96
97type _Gid_t C.gid_t
98
99// Files
100
101const ( // Directory mode bits
102 S_IFMT = C.S_IFMT
103 S_IFIFO = C.S_IFIFO
104 S_IFCHR = C.S_IFCHR
105 S_IFDIR = C.S_IFDIR
106 S_IFBLK = C.S_IFBLK
107 S_IFREG = C.S_IFREG
108 S_IFLNK = C.S_IFLNK
109 S_IFSOCK = C.S_IFSOCK
110 S_ISUID = C.S_ISUID
111 S_ISGID = C.S_ISGID
112 S_ISVTX = C.S_ISVTX
113 S_IRUSR = C.S_IRUSR
114 S_IWUSR = C.S_IWUSR
115 S_IXUSR = C.S_IXUSR
116)
117
118type Stat_t C.struct_stat
119
120type Statfs_t C.struct_statfs
121
122type Flock_t C.struct_flock
123
124type Dirent C.struct_dirent
125
126type Fsid C.struct_fsid
127
128// Sockets
129
130type RawSockaddrInet4 C.struct_sockaddr_in
131
132type RawSockaddrInet6 C.struct_sockaddr_in6
133
134type RawSockaddrUnix C.struct_sockaddr_un
135
136type RawSockaddrDatalink C.struct_sockaddr_dl
137
138type RawSockaddr C.struct_sockaddr
139
140type RawSockaddrAny C.struct_sockaddr_any
141
142type _Socklen C.socklen_t
143
144type Linger C.struct_linger
145
146type Iovec C.struct_iovec
147
148type IPMreq C.struct_ip_mreq
149
150type IPv6Mreq C.struct_ipv6_mreq
151
152type Msghdr C.struct_msghdr
153
154type Cmsghdr C.struct_cmsghdr
155
156type Inet6Pktinfo C.struct_in6_pktinfo
157
158type IPv6MTUInfo C.struct_ip6_mtuinfo
159
160type ICMPv6Filter C.struct_icmp6_filter
161
162const (
163 SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
164 SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
165 SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
166 SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
167 SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
168 SizeofLinger = C.sizeof_struct_linger
169 SizeofIPMreq = C.sizeof_struct_ip_mreq
170 SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
171 SizeofMsghdr = C.sizeof_struct_msghdr
172 SizeofCmsghdr = C.sizeof_struct_cmsghdr
173 SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
174 SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
175 SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
176)
177
178// Ptrace requests
179
180const (
181 PTRACE_TRACEME = C.PT_TRACE_ME
182 PTRACE_CONT = C.PT_CONTINUE
183 PTRACE_KILL = C.PT_KILL
184)
185
186// Events (kqueue, kevent)
187
188type Kevent_t C.struct_kevent
189
190// Select
191
192type FdSet C.fd_set
193
194// Routing and interface messages
195
196const (
197 SizeofIfMsghdr = C.sizeof_struct_if_msghdr
198 SizeofIfData = C.sizeof_struct_if_data
199 SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
200 SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr
201 SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
202 SizeofRtMsghdr = C.sizeof_struct_rt_msghdr
203 SizeofRtMetrics = C.sizeof_struct_rt_metrics
204)
205
206type IfMsghdr C.struct_if_msghdr
207
208type IfData C.struct_if_data
209
210type IfaMsghdr C.struct_ifa_msghdr
211
212type IfmaMsghdr C.struct_ifma_msghdr
213
214type IfAnnounceMsghdr C.struct_if_announcemsghdr
215
216type RtMsghdr C.struct_rt_msghdr
217
218type RtMetrics C.struct_rt_metrics
219
220// Berkeley packet filter
221
222const (
223 SizeofBpfVersion = C.sizeof_struct_bpf_version
224 SizeofBpfStat = C.sizeof_struct_bpf_stat
225 SizeofBpfProgram = C.sizeof_struct_bpf_program
226 SizeofBpfInsn = C.sizeof_struct_bpf_insn
227 SizeofBpfHdr = C.sizeof_struct_bpf_hdr
228)
229
230type BpfVersion C.struct_bpf_version
231
232type BpfStat C.struct_bpf_stat
233
234type BpfProgram C.struct_bpf_program
235
236type BpfInsn C.struct_bpf_insn
237
238type BpfHdr C.struct_bpf_hdr
239
240// Terminal handling
241
242type Termios C.struct_termios
243
244// fchmodat-like syscalls.
245
246const (
247 AT_FDCWD = C.AT_FDCWD
248 AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
249)