1// Copyright 2016 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 mips mipsle
6// +build linux
7
8package runtime
9
10const (
11	_EINTR  = 0x4
12	_EAGAIN = 0xb
13	_ENOMEM = 0xc
14	_ENOSYS = 0x59
15
16	_PROT_NONE  = 0x0
17	_PROT_READ  = 0x1
18	_PROT_WRITE = 0x2
19	_PROT_EXEC  = 0x4
20
21	_MAP_ANON    = 0x800
22	_MAP_PRIVATE = 0x2
23	_MAP_FIXED   = 0x10
24
25	_MADV_DONTNEED   = 0x4
26	_MADV_FREE       = 0x8
27	_MADV_HUGEPAGE   = 0xe
28	_MADV_NOHUGEPAGE = 0xf
29
30	_SA_RESTART = 0x10000000
31	_SA_ONSTACK = 0x8000000
32	_SA_SIGINFO = 0x8
33
34	_SIGHUP    = 0x1
35	_SIGINT    = 0x2
36	_SIGQUIT   = 0x3
37	_SIGILL    = 0x4
38	_SIGTRAP   = 0x5
39	_SIGABRT   = 0x6
40	_SIGEMT    = 0x7
41	_SIGFPE    = 0x8
42	_SIGKILL   = 0x9
43	_SIGBUS    = 0xa
44	_SIGSEGV   = 0xb
45	_SIGSYS    = 0xc
46	_SIGPIPE   = 0xd
47	_SIGALRM   = 0xe
48	_SIGUSR1   = 0x10
49	_SIGUSR2   = 0x11
50	_SIGCHLD   = 0x12
51	_SIGPWR    = 0x13
52	_SIGWINCH  = 0x14
53	_SIGURG    = 0x15
54	_SIGIO     = 0x16
55	_SIGSTOP   = 0x17
56	_SIGTSTP   = 0x18
57	_SIGCONT   = 0x19
58	_SIGTTIN   = 0x1a
59	_SIGTTOU   = 0x1b
60	_SIGVTALRM = 0x1c
61	_SIGPROF   = 0x1d
62	_SIGXCPU   = 0x1e
63	_SIGXFSZ   = 0x1f
64
65	_FPE_INTDIV = 0x1
66	_FPE_INTOVF = 0x2
67	_FPE_FLTDIV = 0x3
68	_FPE_FLTOVF = 0x4
69	_FPE_FLTUND = 0x5
70	_FPE_FLTRES = 0x6
71	_FPE_FLTINV = 0x7
72	_FPE_FLTSUB = 0x8
73
74	_BUS_ADRALN = 0x1
75	_BUS_ADRERR = 0x2
76	_BUS_OBJERR = 0x3
77
78	_SEGV_MAPERR = 0x1
79	_SEGV_ACCERR = 0x2
80
81	_ITIMER_REAL    = 0x0
82	_ITIMER_VIRTUAL = 0x1
83	_ITIMER_PROF    = 0x2
84
85	_EPOLLIN       = 0x1
86	_EPOLLOUT      = 0x4
87	_EPOLLERR      = 0x8
88	_EPOLLHUP      = 0x10
89	_EPOLLRDHUP    = 0x2000
90	_EPOLLET       = 0x80000000
91	_EPOLL_CLOEXEC = 0x80000
92	_EPOLL_CTL_ADD = 0x1
93	_EPOLL_CTL_DEL = 0x2
94	_EPOLL_CTL_MOD = 0x3
95)
96
97type timespec struct {
98	tv_sec  int32
99	tv_nsec int32
100}
101
102//go:nosplit
103func (ts *timespec) setNsec(ns int64) {
104	ts.tv_sec = timediv(ns, 1e9, &ts.tv_nsec)
105}
106
107type timeval struct {
108	tv_sec  int32
109	tv_usec int32
110}
111
112//go:nosplit
113func (tv *timeval) set_usec(x int32) {
114	tv.tv_usec = x
115}
116
117type sigactiont struct {
118	sa_flags   uint32
119	sa_handler uintptr
120	sa_mask    [4]uint32
121	// linux header does not have sa_restorer field,
122	// but it is used in setsig(). it is no harm to put it here
123	sa_restorer uintptr
124}
125
126type siginfo struct {
127	si_signo int32
128	si_code  int32
129	si_errno int32
130	// below here is a union; si_addr is the only field we use
131	si_addr uint32
132}
133
134type itimerval struct {
135	it_interval timeval
136	it_value    timeval
137}
138
139type epollevent struct {
140	events    uint32
141	pad_cgo_0 [4]byte
142	data      uint64
143}
144
145const (
146	_O_RDONLY    = 0x0
147	_O_NONBLOCK  = 0x80
148	_O_CLOEXEC   = 0x80000
149	_SA_RESTORER = 0
150)
151
152type stackt struct {
153	ss_sp    *byte
154	ss_size  uintptr
155	ss_flags int32
156}
157
158type sigcontext struct {
159	sc_regmask   uint32
160	sc_status    uint32
161	sc_pc        uint64
162	sc_regs      [32]uint64
163	sc_fpregs    [32]uint64
164	sc_acx       uint32
165	sc_fpc_csr   uint32
166	sc_fpc_eir   uint32
167	sc_used_math uint32
168	sc_dsp       uint32
169	sc_mdhi      uint64
170	sc_mdlo      uint64
171	sc_hi1       uint32
172	sc_lo1       uint32
173	sc_hi2       uint32
174	sc_lo2       uint32
175	sc_hi3       uint32
176	sc_lo3       uint32
177}
178
179type ucontext struct {
180	uc_flags    uint32
181	uc_link     *ucontext
182	uc_stack    stackt
183	Pad_cgo_0   [4]byte
184	uc_mcontext sigcontext
185	uc_sigmask  [4]uint32
186}
187