1// created by cgo -cdefs and then converted to Go
2// cgo -cdefs defs2_linux.go
3
4package runtime
5
6import "unsafe"
7
8const (
9	_EINTR  = 0x4
10	_EAGAIN = 0xb
11	_ENOMEM = 0xc
12
13	_PROT_NONE  = 0x0
14	_PROT_READ  = 0x1
15	_PROT_WRITE = 0x2
16	_PROT_EXEC  = 0x4
17
18	_MAP_ANON    = 0x20
19	_MAP_PRIVATE = 0x2
20	_MAP_FIXED   = 0x10
21
22	_MADV_DONTNEED   = 0x4
23	_MADV_FREE       = 0x8
24	_MADV_HUGEPAGE   = 0xe
25	_MADV_NOHUGEPAGE = 0xf
26	_MADV_COLLAPSE   = 0x19
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	_SIGRTMIN = 0x20
68
69	_FPE_INTDIV = 0x1
70	_FPE_INTOVF = 0x2
71	_FPE_FLTDIV = 0x3
72	_FPE_FLTOVF = 0x4
73	_FPE_FLTUND = 0x5
74	_FPE_FLTRES = 0x6
75	_FPE_FLTINV = 0x7
76	_FPE_FLTSUB = 0x8
77
78	_BUS_ADRALN = 0x1
79	_BUS_ADRERR = 0x2
80	_BUS_OBJERR = 0x3
81
82	_SEGV_MAPERR = 0x1
83	_SEGV_ACCERR = 0x2
84
85	_ITIMER_REAL    = 0x0
86	_ITIMER_VIRTUAL = 0x1
87	_ITIMER_PROF    = 0x2
88
89	_CLOCK_THREAD_CPUTIME_ID = 0x3
90
91	_SIGEV_THREAD_ID = 0x4
92
93	_O_RDONLY   = 0x0
94	_O_WRONLY   = 0x1
95	_O_CREAT    = 0x40
96	_O_TRUNC    = 0x200
97	_O_NONBLOCK = 0x800
98	_O_CLOEXEC  = 0x80000
99
100	_AF_UNIX    = 0x1
101	_SOCK_DGRAM = 0x2
102)
103
104type fpreg struct {
105	significand [4]uint16
106	exponent    uint16
107}
108
109type fpxreg struct {
110	significand [4]uint16
111	exponent    uint16
112	padding     [3]uint16
113}
114
115type xmmreg struct {
116	element [4]uint32
117}
118
119type fpstate struct {
120	cw        uint32
121	sw        uint32
122	tag       uint32
123	ipoff     uint32
124	cssel     uint32
125	dataoff   uint32
126	datasel   uint32
127	_st       [8]fpreg
128	status    uint16
129	magic     uint16
130	_fxsr_env [6]uint32
131	mxcsr     uint32
132	reserved  uint32
133	_fxsr_st  [8]fpxreg
134	_xmm      [8]xmmreg
135	padding1  [44]uint32
136	anon0     [48]byte
137}
138
139type timespec struct {
140	tv_sec  int32
141	tv_nsec int32
142}
143
144//go:nosplit
145func (ts *timespec) setNsec(ns int64) {
146	ts.tv_sec = timediv(ns, 1e9, &ts.tv_nsec)
147}
148
149type timeval struct {
150	tv_sec  int32
151	tv_usec int32
152}
153
154func (tv *timeval) set_usec(x int32) {
155	tv.tv_usec = x
156}
157
158type sigactiont struct {
159	sa_handler  uintptr
160	sa_flags    uint32
161	sa_restorer uintptr
162	sa_mask     uint64
163}
164
165type siginfoFields struct {
166	si_signo int32
167	si_errno int32
168	si_code  int32
169	// below here is a union; si_addr is the only field we use
170	si_addr uint32
171}
172
173type siginfo struct {
174	siginfoFields
175
176	// Pad struct to the max size in the kernel.
177	_ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
178}
179
180type stackt struct {
181	ss_sp    *byte
182	ss_flags int32
183	ss_size  uintptr
184}
185
186type sigcontext struct {
187	gs            uint16
188	__gsh         uint16
189	fs            uint16
190	__fsh         uint16
191	es            uint16
192	__esh         uint16
193	ds            uint16
194	__dsh         uint16
195	edi           uint32
196	esi           uint32
197	ebp           uint32
198	esp           uint32
199	ebx           uint32
200	edx           uint32
201	ecx           uint32
202	eax           uint32
203	trapno        uint32
204	err           uint32
205	eip           uint32
206	cs            uint16
207	__csh         uint16
208	eflags        uint32
209	esp_at_signal uint32
210	ss            uint16
211	__ssh         uint16
212	fpstate       *fpstate
213	oldmask       uint32
214	cr2           uint32
215}
216
217type ucontext struct {
218	uc_flags    uint32
219	uc_link     *ucontext
220	uc_stack    stackt
221	uc_mcontext sigcontext
222	uc_sigmask  uint32
223}
224
225type itimerspec struct {
226	it_interval timespec
227	it_value    timespec
228}
229
230type itimerval struct {
231	it_interval timeval
232	it_value    timeval
233}
234
235type sigeventFields struct {
236	value  uintptr
237	signo  int32
238	notify int32
239	// below here is a union; sigev_notify_thread_id is the only field we use
240	sigev_notify_thread_id int32
241}
242
243type sigevent struct {
244	sigeventFields
245
246	// Pad struct to the max size in the kernel.
247	_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
248}
249
250type sockaddr_un struct {
251	family uint16
252	path   [108]byte
253}
254