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