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// +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// These defines ensure that builds done on newer versions of Solaris are
19// backwards-compatible with older versions of Solaris and
20// OpenSolaris-based derivatives.
21#define __USE_SUNOS_SOCKETS__          // msghdr
22#define __USE_LEGACY_PROTOTYPES__      // iovec
23#include <dirent.h>
24#include <fcntl.h>
25#include <netdb.h>
26#include <limits.h>
27#include <poll.h>
28#include <signal.h>
29#include <termios.h>
30#include <termio.h>
31#include <stdio.h>
32#include <unistd.h>
33#include <sys/mman.h>
34#include <sys/mount.h>
35#include <sys/param.h>
36#include <sys/resource.h>
37#include <sys/select.h>
38#include <sys/signal.h>
39#include <sys/socket.h>
40#include <sys/stat.h>
41#include <sys/statvfs.h>
42#include <sys/time.h>
43#include <sys/times.h>
44#include <sys/types.h>
45#include <sys/utsname.h>
46#include <sys/un.h>
47#include <sys/wait.h>
48#include <net/bpf.h>
49#include <net/if.h>
50#include <net/if_dl.h>
51#include <net/route.h>
52#include <netinet/in.h>
53#include <netinet/icmp6.h>
54#include <netinet/tcp.h>
55#include <ustat.h>
56#include <utime.h>
57
58enum {
59	sizeofPtr = sizeof(void*),
60};
61
62union sockaddr_all {
63	struct sockaddr s1;	// this one gets used for fields
64	struct sockaddr_in s2;	// these pad it out
65	struct sockaddr_in6 s3;
66	struct sockaddr_un s4;
67	struct sockaddr_dl s5;
68};
69
70struct sockaddr_any {
71	struct sockaddr addr;
72	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
73};
74
75*/
76import "C"
77
78// Machine characteristics
79
80const (
81	SizeofPtr      = C.sizeofPtr
82	SizeofShort    = C.sizeof_short
83	SizeofInt      = C.sizeof_int
84	SizeofLong     = C.sizeof_long
85	SizeofLongLong = C.sizeof_longlong
86	PathMax        = C.PATH_MAX
87	MaxHostNameLen = C.MAXHOSTNAMELEN
88)
89
90// Basic types
91
92type (
93	_C_short     C.short
94	_C_int       C.int
95	_C_long      C.long
96	_C_long_long C.longlong
97)
98
99// Time
100
101type Timespec C.struct_timespec
102
103type Timeval C.struct_timeval
104
105type Timeval32 C.struct_timeval32
106
107type Tms C.struct_tms
108
109type Utimbuf C.struct_utimbuf
110
111// Processes
112
113type Rusage C.struct_rusage
114
115type Rlimit C.struct_rlimit
116
117type _Gid_t C.gid_t
118
119// Files
120
121type Stat_t C.struct_stat
122
123type Flock_t C.struct_flock
124
125type Dirent C.struct_dirent
126
127// Filesystems
128
129type _Fsblkcnt_t C.fsblkcnt_t
130
131type Statvfs_t C.struct_statvfs
132
133// Sockets
134
135type RawSockaddrInet4 C.struct_sockaddr_in
136
137type RawSockaddrInet6 C.struct_sockaddr_in6
138
139type RawSockaddrUnix C.struct_sockaddr_un
140
141type RawSockaddrDatalink C.struct_sockaddr_dl
142
143type RawSockaddr C.struct_sockaddr
144
145type RawSockaddrAny C.struct_sockaddr_any
146
147type _Socklen C.socklen_t
148
149type Linger C.struct_linger
150
151type Iovec C.struct_iovec
152
153type IPMreq C.struct_ip_mreq
154
155type IPv6Mreq C.struct_ipv6_mreq
156
157type Msghdr C.struct_msghdr
158
159type Cmsghdr C.struct_cmsghdr
160
161type Inet4Pktinfo C.struct_in_pktinfo
162
163type Inet6Pktinfo C.struct_in6_pktinfo
164
165type IPv6MTUInfo C.struct_ip6_mtuinfo
166
167type ICMPv6Filter C.struct_icmp6_filter
168
169const (
170	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
171	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
172	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
173	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
174	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
175	SizeofLinger           = C.sizeof_struct_linger
176	SizeofIPMreq           = C.sizeof_struct_ip_mreq
177	SizeofIPv6Mreq         = C.sizeof_struct_ipv6_mreq
178	SizeofMsghdr           = C.sizeof_struct_msghdr
179	SizeofCmsghdr          = C.sizeof_struct_cmsghdr
180	SizeofInet4Pktinfo     = C.sizeof_struct_in_pktinfo
181	SizeofInet6Pktinfo     = C.sizeof_struct_in6_pktinfo
182	SizeofIPv6MTUInfo      = C.sizeof_struct_ip6_mtuinfo
183	SizeofICMPv6Filter     = C.sizeof_struct_icmp6_filter
184)
185
186// Select
187
188type FdSet C.fd_set
189
190// Misc
191
192type Utsname C.struct_utsname
193
194type Ustat_t C.struct_ustat
195
196const (
197	AT_FDCWD            = C.AT_FDCWD
198	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
199	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
200	AT_REMOVEDIR        = C.AT_REMOVEDIR
201	AT_EACCESS          = C.AT_EACCESS
202)
203
204// Routing and interface messages
205
206const (
207	SizeofIfMsghdr  = C.sizeof_struct_if_msghdr
208	SizeofIfData    = C.sizeof_struct_if_data
209	SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr
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 RtMsghdr C.struct_rt_msghdr
221
222type RtMetrics C.struct_rt_metrics
223
224// Berkeley packet filter
225
226const (
227	SizeofBpfVersion = C.sizeof_struct_bpf_version
228	SizeofBpfStat    = C.sizeof_struct_bpf_stat
229	SizeofBpfProgram = C.sizeof_struct_bpf_program
230	SizeofBpfInsn    = C.sizeof_struct_bpf_insn
231	SizeofBpfHdr     = C.sizeof_struct_bpf_hdr
232)
233
234type BpfVersion C.struct_bpf_version
235
236type BpfStat C.struct_bpf_stat
237
238type BpfProgram C.struct_bpf_program
239
240type BpfInsn C.struct_bpf_insn
241
242type BpfTimeval C.struct_bpf_timeval
243
244type BpfHdr C.struct_bpf_hdr
245
246// Terminal handling
247
248type Termios C.struct_termios
249
250type Termio C.struct_termio
251
252type Winsize C.struct_winsize
253
254// poll
255
256type PollFd C.struct_pollfd
257
258const (
259	POLLERR    = C.POLLERR
260	POLLHUP    = C.POLLHUP
261	POLLIN     = C.POLLIN
262	POLLNVAL   = C.POLLNVAL
263	POLLOUT    = C.POLLOUT
264	POLLPRI    = C.POLLPRI
265	POLLRDBAND = C.POLLRDBAND
266	POLLRDNORM = C.POLLRDNORM
267	POLLWRBAND = C.POLLWRBAND
268	POLLWRNORM = C.POLLWRNORM
269)
270