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	_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	_O_RDONLY   = 0x0
92	_O_NONBLOCK = 0x800
93	_O_CLOEXEC  = 0x80000
94
95	_EPOLLIN       = 0x1
96	_EPOLLOUT      = 0x4
97	_EPOLLERR      = 0x8
98	_EPOLLHUP      = 0x10
99	_EPOLLRDHUP    = 0x2000
100	_EPOLLET       = 0x80000000
101	_EPOLL_CLOEXEC = 0x80000
102	_EPOLL_CTL_ADD = 0x1
103	_EPOLL_CTL_DEL = 0x2
104	_EPOLL_CTL_MOD = 0x3
105
106	_AF_UNIX    = 0x1
107	_SOCK_DGRAM = 0x2
108)
109
110type fpreg struct {
111	significand [4]uint16
112	exponent    uint16
113}
114
115type fpxreg struct {
116	significand [4]uint16
117	exponent    uint16
118	padding     [3]uint16
119}
120
121type xmmreg struct {
122	element [4]uint32
123}
124
125type fpstate struct {
126	cw        uint32
127	sw        uint32
128	tag       uint32
129	ipoff     uint32
130	cssel     uint32
131	dataoff   uint32
132	datasel   uint32
133	_st       [8]fpreg
134	status    uint16
135	magic     uint16
136	_fxsr_env [6]uint32
137	mxcsr     uint32
138	reserved  uint32
139	_fxsr_st  [8]fpxreg
140	_xmm      [8]xmmreg
141	padding1  [44]uint32
142	anon0     [48]byte
143}
144
145type timespec struct {
146	tv_sec  int32
147	tv_nsec int32
148}
149
150//go:nosplit
151func (ts *timespec) setNsec(ns int64) {
152	ts.tv_sec = timediv(ns, 1e9, &ts.tv_nsec)
153}
154
155type timeval struct {
156	tv_sec  int32
157	tv_usec int32
158}
159
160func (tv *timeval) set_usec(x int32) {
161	tv.tv_usec = x
162}
163
164type sigactiont struct {
165	sa_handler  uintptr
166	sa_flags    uint32
167	sa_restorer uintptr
168	sa_mask     uint64
169}
170
171type siginfoFields struct {
172	si_signo int32
173	si_errno int32
174	si_code  int32
175	// below here is a union; si_addr is the only field we use
176	si_addr uint32
177}
178
179type siginfo struct {
180	siginfoFields
181
182	// Pad struct to the max size in the kernel.
183	_ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
184}
185
186type stackt struct {
187	ss_sp    *byte
188	ss_flags int32
189	ss_size  uintptr
190}
191
192type sigcontext struct {
193	gs            uint16
194	__gsh         uint16
195	fs            uint16
196	__fsh         uint16
197	es            uint16
198	__esh         uint16
199	ds            uint16
200	__dsh         uint16
201	edi           uint32
202	esi           uint32
203	ebp           uint32
204	esp           uint32
205	ebx           uint32
206	edx           uint32
207	ecx           uint32
208	eax           uint32
209	trapno        uint32
210	err           uint32
211	eip           uint32
212	cs            uint16
213	__csh         uint16
214	eflags        uint32
215	esp_at_signal uint32
216	ss            uint16
217	__ssh         uint16
218	fpstate       *fpstate
219	oldmask       uint32
220	cr2           uint32
221}
222
223type ucontext struct {
224	uc_flags    uint32
225	uc_link     *ucontext
226	uc_stack    stackt
227	uc_mcontext sigcontext
228	uc_sigmask  uint32
229}
230
231type itimerspec struct {
232	it_interval timespec
233	it_value    timespec
234}
235
236type itimerval struct {
237	it_interval timeval
238	it_value    timeval
239}
240
241type sigeventFields struct {
242	value  uintptr
243	signo  int32
244	notify int32
245	// below here is a union; sigev_notify_thread_id is the only field we use
246	sigev_notify_thread_id int32
247}
248
249type sigevent struct {
250	sigeventFields
251
252	// Pad struct to the max size in the kernel.
253	_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
254}
255
256type epollevent struct {
257	events uint32
258	data   [8]byte // to match amd64
259}
260
261type sockaddr_un struct {
262	family uint16
263	path   [108]byte
264}
265