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/event.h>
27#include <sys/mman.h>
28#include <sys/mount.h>
29#include <sys/param.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/types.h>
38#include <sys/un.h>
39#include <sys/utsname.h>
40#include <sys/wait.h>
41#include <net/bpf.h>
42#include <net/if.h>
43#include <net/if_dl.h>
44#include <net/route.h>
45#include <netinet/in.h>
46#include <netinet/icmp6.h>
47#include <netinet/tcp.h>
48
49enum {
50	sizeofPtr = sizeof(void*),
51};
52
53union sockaddr_all {
54	struct sockaddr s1;	// this one gets used for fields
55	struct sockaddr_in s2;	// these pad it out
56	struct sockaddr_in6 s3;
57	struct sockaddr_un s4;
58	struct sockaddr_dl s5;
59};
60
61struct sockaddr_any {
62	struct sockaddr addr;
63	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
64};
65
66*/
67import "C"
68
69// Machine characteristics
70
71const (
72	SizeofPtr      = C.sizeofPtr
73	SizeofShort    = C.sizeof_short
74	SizeofInt      = C.sizeof_int
75	SizeofLong     = C.sizeof_long
76	SizeofLongLong = C.sizeof_longlong
77)
78
79// Basic types
80
81type (
82	_C_short     C.short
83	_C_int       C.int
84	_C_long      C.long
85	_C_long_long C.longlong
86)
87
88// Time
89
90type Timespec C.struct_timespec
91
92type Timeval C.struct_timeval
93
94// Processes
95
96type Rusage C.struct_rusage
97
98type Rlimit C.struct_rlimit
99
100type _Gid_t C.gid_t
101
102// Files
103
104type Stat_t C.struct_stat
105
106type Statfs_t C.struct_statfs
107
108type Flock_t C.struct_flock
109
110type Dirent C.struct_dirent
111
112type Fsid C.struct_fsid
113
114// File system limits
115
116const (
117	PathMax = C.PATH_MAX
118)
119
120// Sockets
121
122type RawSockaddrInet4 C.struct_sockaddr_in
123
124type RawSockaddrInet6 C.struct_sockaddr_in6
125
126type RawSockaddrUnix C.struct_sockaddr_un
127
128type RawSockaddrDatalink C.struct_sockaddr_dl
129
130type RawSockaddr C.struct_sockaddr
131
132type RawSockaddrAny C.struct_sockaddr_any
133
134type _Socklen C.socklen_t
135
136type Linger C.struct_linger
137
138type Iovec C.struct_iovec
139
140type IPMreq C.struct_ip_mreq
141
142type IPv6Mreq C.struct_ipv6_mreq
143
144type Msghdr C.struct_msghdr
145
146type Cmsghdr C.struct_cmsghdr
147
148type Inet6Pktinfo C.struct_in6_pktinfo
149
150type IPv6MTUInfo C.struct_ip6_mtuinfo
151
152type ICMPv6Filter C.struct_icmp6_filter
153
154const (
155	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
156	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
157	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
158	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
159	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
160	SizeofLinger           = C.sizeof_struct_linger
161	SizeofIovec            = C.sizeof_struct_iovec
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	SizeofIfmaMsghdr       = C.sizeof_struct_ifma_msghdr
194	SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
195	SizeofRtMsghdr         = C.sizeof_struct_rt_msghdr
196	SizeofRtMetrics        = C.sizeof_struct_rt_metrics
197)
198
199type IfMsghdr C.struct_if_msghdr
200
201type IfData C.struct_if_data
202
203type IfaMsghdr C.struct_ifa_msghdr
204
205type IfmaMsghdr C.struct_ifma_msghdr
206
207type IfAnnounceMsghdr C.struct_if_announcemsghdr
208
209type RtMsghdr C.struct_rt_msghdr
210
211type RtMetrics C.struct_rt_metrics
212
213// Berkeley packet filter
214
215const (
216	SizeofBpfVersion = C.sizeof_struct_bpf_version
217	SizeofBpfStat    = C.sizeof_struct_bpf_stat
218	SizeofBpfProgram = C.sizeof_struct_bpf_program
219	SizeofBpfInsn    = C.sizeof_struct_bpf_insn
220	SizeofBpfHdr     = C.sizeof_struct_bpf_hdr
221)
222
223type BpfVersion C.struct_bpf_version
224
225type BpfStat C.struct_bpf_stat
226
227type BpfProgram C.struct_bpf_program
228
229type BpfInsn C.struct_bpf_insn
230
231type BpfHdr C.struct_bpf_hdr
232
233// Terminal handling
234
235type Termios C.struct_termios
236
237type Winsize C.struct_winsize
238
239// fchmodat-like syscalls.
240
241const (
242	AT_FDCWD            = C.AT_FDCWD
243	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
244	AT_REMOVEDIR        = C.AT_REMOVEDIR
245	AT_EACCESS          = C.AT_EACCESS
246	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
247)
248
249// poll
250
251type PollFd C.struct_pollfd
252
253const (
254	POLLERR    = C.POLLERR
255	POLLHUP    = C.POLLHUP
256	POLLIN     = C.POLLIN
257	POLLNVAL   = C.POLLNVAL
258	POLLOUT    = C.POLLOUT
259	POLLPRI    = C.POLLPRI
260	POLLRDBAND = C.POLLRDBAND
261	POLLRDNORM = C.POLLRDNORM
262	POLLWRBAND = C.POLLWRBAND
263	POLLWRNORM = C.POLLWRNORM
264)
265
266// Uname
267
268type Utsname C.struct_utsname
269
270// Clockinfo
271
272const SizeofClockinfo = C.sizeof_struct_clockinfo
273
274type Clockinfo C.struct_clockinfo
275