blob: 392da69bf0a121215740a6e457380af6cd998200 [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/param.h>
25#include <sys/types.h>
26#include <sys/event.h>
27#include <sys/mman.h>
28#include <sys/mount.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/uio.h>
37#include <sys/un.h>
38#include <sys/wait.h>
39#include <net/bpf.h>
40#include <net/if.h>
41#include <net/if_dl.h>
42#include <net/route.h>
43#include <netinet/in.h>
44#include <netinet/icmp6.h>
45#include <netinet/tcp.h>
46
47enum {
48 sizeofPtr = sizeof(void*),
49};
50
51union sockaddr_all {
52 struct sockaddr s1; // this one gets used for fields
53 struct sockaddr_in s2; // these pad it out
54 struct sockaddr_in6 s3;
55 struct sockaddr_un s4;
56 struct sockaddr_dl s5;
57};
58
59struct sockaddr_any {
60 struct sockaddr addr;
61 char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
62};
63
64*/
65import "C"
66
67// Machine characteristics; for internal use.
68
69const (
70 sizeofPtr = C.sizeofPtr
71 sizeofShort = C.sizeof_short
72 sizeofInt = C.sizeof_int
73 sizeofLong = C.sizeof_long
74 sizeofLongLong = C.sizeof_longlong
75)
76
77// Basic types
78
79type (
80 _C_short C.short
81 _C_int C.int
82 _C_long C.long
83 _C_long_long C.longlong
84)
85
86// Time
87
88type Timespec C.struct_timespec
89
90type Timeval C.struct_timeval
91
92// Processes
93
94type Rusage C.struct_rusage
95
96type Rlimit C.struct_rlimit
97
98type _Gid_t C.gid_t
99
100// Files
101
102const ( // Directory mode bits
103 S_IFMT = C.S_IFMT
104 S_IFIFO = C.S_IFIFO
105 S_IFCHR = C.S_IFCHR
106 S_IFDIR = C.S_IFDIR
107 S_IFBLK = C.S_IFBLK
108 S_IFREG = C.S_IFREG
109 S_IFLNK = C.S_IFLNK
110 S_IFSOCK = C.S_IFSOCK
111 S_ISUID = C.S_ISUID
112 S_ISGID = C.S_ISGID
113 S_ISVTX = C.S_ISVTX
114 S_IRUSR = C.S_IRUSR
115 S_IWUSR = C.S_IWUSR
116 S_IXUSR = C.S_IXUSR
117)
118
119type Stat_t C.struct_stat
120
121type Statfs_t C.struct_statfs
122
123type Flock_t C.struct_flock
124
125type Dirent C.struct_dirent
126
127type Fsid C.fsid_t
128
129// Sockets
130
131type RawSockaddrInet4 C.struct_sockaddr_in
132
133type RawSockaddrInet6 C.struct_sockaddr_in6
134
135type RawSockaddrUnix C.struct_sockaddr_un
136
137type RawSockaddrDatalink C.struct_sockaddr_dl
138
139type RawSockaddr C.struct_sockaddr
140
141type RawSockaddrAny C.struct_sockaddr_any
142
143type _Socklen C.socklen_t
144
145type Linger C.struct_linger
146
147type Iovec C.struct_iovec
148
149type IPMreq C.struct_ip_mreq
150
151type IPv6Mreq C.struct_ipv6_mreq
152
153type Msghdr C.struct_msghdr
154
155type Cmsghdr C.struct_cmsghdr
156
157type Inet6Pktinfo C.struct_in6_pktinfo
158
159type IPv6MTUInfo C.struct_ip6_mtuinfo
160
161type ICMPv6Filter C.struct_icmp6_filter
162
163const (
164 SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in
165 SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
166 SizeofSockaddrAny = C.sizeof_struct_sockaddr_any
167 SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un
168 SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
169 SizeofLinger = C.sizeof_struct_linger
170 SizeofIPMreq = C.sizeof_struct_ip_mreq
171 SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
172 SizeofMsghdr = C.sizeof_struct_msghdr
173 SizeofCmsghdr = C.sizeof_struct_cmsghdr
174 SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
175 SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo
176 SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
177)
178
179// Ptrace requests
180
181const (
182 PTRACE_TRACEME = C.PT_TRACE_ME
183 PTRACE_CONT = C.PT_CONTINUE
184 PTRACE_KILL = C.PT_KILL
185)
186
187// Events (kqueue, kevent)
188
189type Kevent_t C.struct_kevent
190
191// Select
192
193type FdSet C.fd_set
194
195// Routing and interface messages
196
197const (
198 SizeofIfMsghdr = C.sizeof_struct_if_msghdr
199 SizeofIfData = C.sizeof_struct_if_data
200 SizeofIfaMsghdr = C.sizeof_struct_ifa_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 IfAnnounceMsghdr C.struct_if_announcemsghdr
213
214type RtMsghdr C.struct_rt_msghdr
215
216type RtMetrics C.struct_rt_metrics
217
218type Mclpool C.struct_mclpool
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
240type BpfTimeval C.struct_bpf_timeval
241
242// Terminal handling
243
244type Termios C.struct_termios
245
246// fchmodat-like syscalls.
247
248const (
249 AT_FDCWD = C.AT_FDCWD
250 AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
251)