1// created by cgo -cdefs and then converted to Go
2// cgo -cdefs defs_linux.go defs1_linux.go
3
4package runtime
5
6import "unsafe"
7
8const (
9	_EINTR  = 0x4
10	_EAGAIN = 0xb
11	_ENOMEM = 0xc
12	_ENOSYS = 0x26
13
14	_PROT_NONE  = 0x0
15	_PROT_READ  = 0x1
16	_PROT_WRITE = 0x2
17	_PROT_EXEC  = 0x4
18
19	_MAP_ANON    = 0x20
20	_MAP_PRIVATE = 0x2
21	_MAP_FIXED   = 0x10
22
23	_MADV_DONTNEED   = 0x4
24	_MADV_FREE       = 0x8
25	_MADV_HUGEPAGE   = 0xe
26	_MADV_NOHUGEPAGE = 0xf
27
28	_SA_RESTART  = 0x10000000
29	_SA_ONSTACK  = 0x8000000
30	_SA_RESTORER = 0x4000000
31	_SA_SIGINFO  = 0x4
32
33	_SI_KERNEL = 0x80
34	_SI_TIMER  = -0x2
35
36	_SIGHUP    = 0x1
37	_SIGINT    = 0x2
38	_SIGQUIT   = 0x3
39	_SIGILL    = 0x4
40	_SIGTRAP   = 0x5
41	_SIGABRT   = 0x6
42	_SIGBUS    = 0x7
43	_SIGFPE    = 0x8
44	_SIGKILL   = 0x9
45	_SIGUSR1   = 0xa
46	_SIGSEGV   = 0xb
47	_SIGUSR2   = 0xc
48	_SIGPIPE   = 0xd
49	_SIGALRM   = 0xe
50	_SIGSTKFLT = 0x10
51	_SIGCHLD   = 0x11
52	_SIGCONT   = 0x12
53	_SIGSTOP   = 0x13
54	_SIGTSTP   = 0x14
55	_SIGTTIN   = 0x15
56	_SIGTTOU   = 0x16
57	_SIGURG    = 0x17
58	_SIGXCPU   = 0x18
59	_SIGXFSZ   = 0x19
60	_SIGVTALRM = 0x1a
61	_SIGPROF   = 0x1b
62	_SIGWINCH  = 0x1c
63	_SIGIO     = 0x1d
64	_SIGPWR    = 0x1e
65	_SIGSYS    = 0x1f
66
67	_FPE_INTDIV = 0x1
68	_FPE_INTOVF = 0x2
69	_FPE_FLTDIV = 0x3
70	_FPE_FLTOVF = 0x4
71	_FPE_FLTUND = 0x5
72	_FPE_FLTRES = 0x6
73	_FPE_FLTINV = 0x7
74	_FPE_FLTSUB = 0x8
75
76	_BUS_ADRALN = 0x1
77	_BUS_ADRERR = 0x2
78	_BUS_OBJERR = 0x3
79
80	_SEGV_MAPERR = 0x1
81	_SEGV_ACCERR = 0x2
82
83	_ITIMER_REAL    = 0x0
84	_ITIMER_VIRTUAL = 0x1
85	_ITIMER_PROF    = 0x2
86
87	_CLOCK_THREAD_CPUTIME_ID = 0x3
88
89	_SIGEV_THREAD_ID = 0x4
90
91	_EPOLLIN       = 0x1
92	_EPOLLOUT      = 0x4
93	_EPOLLERR      = 0x8
94	_EPOLLHUP      = 0x10
95	_EPOLLRDHUP    = 0x2000
96	_EPOLLET       = 0x80000000
97	_EPOLL_CLOEXEC = 0x80000
98	_EPOLL_CTL_ADD = 0x1
99	_EPOLL_CTL_DEL = 0x2
100	_EPOLL_CTL_MOD = 0x3
101
102	_AF_UNIX    = 0x1
103	_SOCK_DGRAM = 0x2
104)
105
106type timespec struct {
107	tv_sec  int64
108	tv_nsec int64
109}
110
111//go:nosplit
112func (ts *timespec) setNsec(ns int64) {
113	ts.tv_sec = ns / 1e9
114	ts.tv_nsec = ns % 1e9
115}
116
117type timeval struct {
118	tv_sec  int64
119	tv_usec int64
120}
121
122func (tv *timeval) set_usec(x int32) {
123	tv.tv_usec = int64(x)
124}
125
126type sigactiont struct {
127	sa_handler  uintptr
128	sa_flags    uint64
129	sa_restorer uintptr
130	sa_mask     uint64
131}
132
133type siginfoFields struct {
134	si_signo int32
135	si_errno int32
136	si_code  int32
137	// below here is a union; si_addr is the only field we use
138	si_addr uint64
139}
140
141type siginfo struct {
142	siginfoFields
143
144	// Pad struct to the max size in the kernel.
145	_ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
146}
147
148type itimerspec struct {
149	it_interval timespec
150	it_value    timespec
151}
152
153type itimerval struct {
154	it_interval timeval
155	it_value    timeval
156}
157
158type sigeventFields struct {
159	value  uintptr
160	signo  int32
161	notify int32
162	// below here is a union; sigev_notify_thread_id is the only field we use
163	sigev_notify_thread_id int32
164}
165
166type sigevent struct {
167	sigeventFields
168
169	// Pad struct to the max size in the kernel.
170	_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
171}
172
173type epollevent struct {
174	events uint32
175	data   [8]byte // unaligned uintptr
176}
177
178// created by cgo -cdefs and then converted to Go
179// cgo -cdefs defs_linux.go defs1_linux.go
180
181const (
182	_O_RDONLY   = 0x0
183	_O_NONBLOCK = 0x800
184	_O_CLOEXEC  = 0x80000
185)
186
187type usigset struct {
188	__val [16]uint64
189}
190
191type fpxreg struct {
192	significand [4]uint16
193	exponent    uint16
194	padding     [3]uint16
195}
196
197type xmmreg struct {
198	element [4]uint32
199}
200
201type fpstate struct {
202	cwd       uint16
203	swd       uint16
204	ftw       uint16
205	fop       uint16
206	rip       uint64
207	rdp       uint64
208	mxcsr     uint32
209	mxcr_mask uint32
210	_st       [8]fpxreg
211	_xmm      [16]xmmreg
212	padding   [24]uint32
213}
214
215type fpxreg1 struct {
216	significand [4]uint16
217	exponent    uint16
218	padding     [3]uint16
219}
220
221type xmmreg1 struct {
222	element [4]uint32
223}
224
225type fpstate1 struct {
226	cwd       uint16
227	swd       uint16
228	ftw       uint16
229	fop       uint16
230	rip       uint64
231	rdp       uint64
232	mxcsr     uint32
233	mxcr_mask uint32
234	_st       [8]fpxreg1
235	_xmm      [16]xmmreg1
236	padding   [24]uint32
237}
238
239type fpreg1 struct {
240	significand [4]uint16
241	exponent    uint16
242}
243
244type stackt struct {
245	ss_sp     *byte
246	ss_flags  int32
247	pad_cgo_0 [4]byte
248	ss_size   uintptr
249}
250
251type mcontext struct {
252	gregs       [23]uint64
253	fpregs      *fpstate
254	__reserved1 [8]uint64
255}
256
257type ucontext struct {
258	uc_flags     uint64
259	uc_link      *ucontext
260	uc_stack     stackt
261	uc_mcontext  mcontext
262	uc_sigmask   usigset
263	__fpregs_mem fpstate
264}
265
266type sigcontext struct {
267	r8          uint64
268	r9          uint64
269	r10         uint64
270	r11         uint64
271	r12         uint64
272	r13         uint64
273	r14         uint64
274	r15         uint64
275	rdi         uint64
276	rsi         uint64
277	rbp         uint64
278	rbx         uint64
279	rdx         uint64
280	rax         uint64
281	rcx         uint64
282	rsp         uint64
283	rip         uint64
284	eflags      uint64
285	cs          uint16
286	gs          uint16
287	fs          uint16
288	__pad0      uint16
289	err         uint64
290	trapno      uint64
291	oldmask     uint64
292	cr2         uint64
293	fpstate     *fpstate1
294	__reserved1 [8]uint64
295}
296
297type sockaddr_un struct {
298	family uint16
299	path   [108]byte
300}
301