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