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