1// created by cgo -cdefs and then converted to Go
2// cgo -cdefs defs_linux.go defs3_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_SIGINFO = 0x4
31
32	_SI_KERNEL = 0x80
33	_SI_TIMER  = -0x2
34
35	_SIGHUP    = 0x1
36	_SIGINT    = 0x2
37	_SIGQUIT   = 0x3
38	_SIGILL    = 0x4
39	_SIGTRAP   = 0x5
40	_SIGABRT   = 0x6
41	_SIGBUS    = 0x7
42	_SIGFPE    = 0x8
43	_SIGKILL   = 0x9
44	_SIGUSR1   = 0xa
45	_SIGSEGV   = 0xb
46	_SIGUSR2   = 0xc
47	_SIGPIPE   = 0xd
48	_SIGALRM   = 0xe
49	_SIGSTKFLT = 0x10
50	_SIGCHLD   = 0x11
51	_SIGCONT   = 0x12
52	_SIGSTOP   = 0x13
53	_SIGTSTP   = 0x14
54	_SIGTTIN   = 0x15
55	_SIGTTOU   = 0x16
56	_SIGURG    = 0x17
57	_SIGXCPU   = 0x18
58	_SIGXFSZ   = 0x19
59	_SIGVTALRM = 0x1a
60	_SIGPROF   = 0x1b
61	_SIGWINCH  = 0x1c
62	_SIGIO     = 0x1d
63	_SIGPWR    = 0x1e
64	_SIGSYS    = 0x1f
65
66	_SIGRTMIN = 0x20
67
68	_FPE_INTDIV = 0x1
69	_FPE_INTOVF = 0x2
70	_FPE_FLTDIV = 0x3
71	_FPE_FLTOVF = 0x4
72	_FPE_FLTUND = 0x5
73	_FPE_FLTRES = 0x6
74	_FPE_FLTINV = 0x7
75	_FPE_FLTSUB = 0x8
76
77	_BUS_ADRALN = 0x1
78	_BUS_ADRERR = 0x2
79	_BUS_OBJERR = 0x3
80
81	_SEGV_MAPERR = 0x1
82	_SEGV_ACCERR = 0x2
83
84	_ITIMER_REAL    = 0x0
85	_ITIMER_VIRTUAL = 0x1
86	_ITIMER_PROF    = 0x2
87
88	_CLOCK_THREAD_CPUTIME_ID = 0x3
89
90	_SIGEV_THREAD_ID = 0x4
91)
92
93//struct Sigset {
94//	uint64	sig[1];
95//};
96//typedef uint64 Sigset;
97
98type timespec struct {
99	tv_sec  int64
100	tv_nsec int64
101}
102
103//go:nosplit
104func (ts *timespec) setNsec(ns int64) {
105	ts.tv_sec = ns / 1e9
106	ts.tv_nsec = ns % 1e9
107}
108
109type timeval struct {
110	tv_sec  int64
111	tv_usec int64
112}
113
114func (tv *timeval) set_usec(x int32) {
115	tv.tv_usec = int64(x)
116}
117
118type sigactiont struct {
119	sa_handler  uintptr
120	sa_flags    uint64
121	sa_restorer uintptr
122	sa_mask     uint64
123}
124
125type siginfoFields struct {
126	si_signo int32
127	si_errno int32
128	si_code  int32
129	// below here is a union; si_addr is the only field we use
130	si_addr uint64
131}
132
133type siginfo struct {
134	siginfoFields
135
136	// Pad struct to the max size in the kernel.
137	_ [_si_max_size - unsafe.Sizeof(siginfoFields{})]byte
138}
139
140type itimerspec struct {
141	it_interval timespec
142	it_value    timespec
143}
144
145type itimerval struct {
146	it_interval timeval
147	it_value    timeval
148}
149
150type sigeventFields struct {
151	value  uintptr
152	signo  int32
153	notify int32
154	// below here is a union; sigev_notify_thread_id is the only field we use
155	sigev_notify_thread_id int32
156}
157
158type sigevent struct {
159	sigeventFields
160
161	// Pad struct to the max size in the kernel.
162	_ [_sigev_max_size - unsafe.Sizeof(sigeventFields{})]byte
163}
164
165// created by cgo -cdefs and then converted to Go
166// cgo -cdefs defs_linux.go defs3_linux.go
167
168const (
169	_O_RDONLY    = 0x0
170	_O_WRONLY    = 0x1
171	_O_CREAT     = 0x40
172	_O_TRUNC     = 0x200
173	_O_NONBLOCK  = 0x800
174	_O_CLOEXEC   = 0x80000
175	_SA_RESTORER = 0
176)
177
178type ptregs struct {
179	gpr       [32]uint64
180	nip       uint64
181	msr       uint64
182	orig_gpr3 uint64
183	ctr       uint64
184	link      uint64
185	xer       uint64
186	ccr       uint64
187	softe     uint64
188	trap      uint64
189	dar       uint64
190	dsisr     uint64
191	result    uint64
192}
193
194type vreg struct {
195	u [4]uint32
196}
197
198type stackt struct {
199	ss_sp     *byte
200	ss_flags  int32
201	pad_cgo_0 [4]byte
202	ss_size   uintptr
203}
204
205type sigcontext struct {
206	_unused     [4]uint64
207	signal      int32
208	_pad0       int32
209	handler     uint64
210	oldmask     uint64
211	regs        *ptregs
212	gp_regs     [48]uint64
213	fp_regs     [33]float64
214	v_regs      *vreg
215	vmx_reserve [101]int64
216}
217
218type ucontext struct {
219	uc_flags    uint64
220	uc_link     *ucontext
221	uc_stack    stackt
222	uc_sigmask  uint64
223	__unused    [15]uint64
224	uc_mcontext sigcontext
225}
226