Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 1 | // created by cgo -cdefs and then converted to Go |
| 2 | // cgo -cdefs defs_freebsd.go |
| 3 | |
| 4 | package runtime |
| 5 | |
| 6 | import "unsafe" |
| 7 | |
| 8 | const ( |
David NewHamlet | e19f184 | 2017-03-11 09:13:20 +1300 | [diff] [blame] | 9 | _NBBY = 0x8 |
| 10 | _CTL_MAXNAME = 0x18 |
| 11 | _CPU_LEVEL_WHICH = 0x3 |
| 12 | _CPU_WHICH_PID = 0x2 |
| 13 | ) |
| 14 | |
| 15 | const ( |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 16 | _EINTR = 0x4 |
| 17 | _EFAULT = 0xe |
Ian Lance Taylor | 50f4896 | 2019-04-05 15:53:12 -0700 | [diff] [blame] | 18 | _EAGAIN = 0x23 |
Ian Lance Taylor | 3b0aa54 | 2019-04-03 16:31:13 -0700 | [diff] [blame] | 19 | _ENOSYS = 0x4e |
| 20 | |
| 21 | _O_NONBLOCK = 0x4 |
| 22 | _O_CLOEXEC = 0x100000 |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 23 | |
| 24 | _PROT_NONE = 0x0 |
| 25 | _PROT_READ = 0x1 |
| 26 | _PROT_WRITE = 0x2 |
| 27 | _PROT_EXEC = 0x4 |
| 28 | |
| 29 | _MAP_ANON = 0x1000 |
Yuval Pavel Zholkover | 58c231f | 2018-04-19 17:52:14 +0300 | [diff] [blame] | 30 | _MAP_SHARED = 0x1 |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 31 | _MAP_PRIVATE = 0x2 |
| 32 | _MAP_FIXED = 0x10 |
| 33 | |
| 34 | _MADV_FREE = 0x5 |
| 35 | |
| 36 | _SA_SIGINFO = 0x40 |
| 37 | _SA_RESTART = 0x2 |
| 38 | _SA_ONSTACK = 0x1 |
| 39 | |
Mike Appleby | 360f2e4 | 2016-09-28 16:01:27 -0500 | [diff] [blame] | 40 | _CLOCK_MONOTONIC = 0x4 |
Yuval Pavel Zholkover | 744ccbb | 2018-02-05 17:11:27 +0200 | [diff] [blame] | 41 | _CLOCK_REALTIME = 0x0 |
Mike Appleby | 360f2e4 | 2016-09-28 16:01:27 -0500 | [diff] [blame] | 42 | |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 43 | _UMTX_OP_WAIT_UINT = 0xb |
| 44 | _UMTX_OP_WAIT_UINT_PRIVATE = 0xf |
| 45 | _UMTX_OP_WAKE = 0x3 |
| 46 | _UMTX_OP_WAKE_PRIVATE = 0x10 |
| 47 | |
| 48 | _SIGHUP = 0x1 |
| 49 | _SIGINT = 0x2 |
| 50 | _SIGQUIT = 0x3 |
| 51 | _SIGILL = 0x4 |
| 52 | _SIGTRAP = 0x5 |
| 53 | _SIGABRT = 0x6 |
| 54 | _SIGEMT = 0x7 |
| 55 | _SIGFPE = 0x8 |
| 56 | _SIGKILL = 0x9 |
| 57 | _SIGBUS = 0xa |
| 58 | _SIGSEGV = 0xb |
| 59 | _SIGSYS = 0xc |
| 60 | _SIGPIPE = 0xd |
| 61 | _SIGALRM = 0xe |
| 62 | _SIGTERM = 0xf |
| 63 | _SIGURG = 0x10 |
| 64 | _SIGSTOP = 0x11 |
| 65 | _SIGTSTP = 0x12 |
| 66 | _SIGCONT = 0x13 |
| 67 | _SIGCHLD = 0x14 |
| 68 | _SIGTTIN = 0x15 |
| 69 | _SIGTTOU = 0x16 |
| 70 | _SIGIO = 0x17 |
| 71 | _SIGXCPU = 0x18 |
| 72 | _SIGXFSZ = 0x19 |
| 73 | _SIGVTALRM = 0x1a |
| 74 | _SIGPROF = 0x1b |
| 75 | _SIGWINCH = 0x1c |
| 76 | _SIGINFO = 0x1d |
| 77 | _SIGUSR1 = 0x1e |
| 78 | _SIGUSR2 = 0x1f |
| 79 | |
| 80 | _FPE_INTDIV = 0x2 |
| 81 | _FPE_INTOVF = 0x1 |
| 82 | _FPE_FLTDIV = 0x3 |
| 83 | _FPE_FLTOVF = 0x4 |
| 84 | _FPE_FLTUND = 0x5 |
| 85 | _FPE_FLTRES = 0x6 |
| 86 | _FPE_FLTINV = 0x7 |
| 87 | _FPE_FLTSUB = 0x8 |
| 88 | |
| 89 | _BUS_ADRALN = 0x1 |
| 90 | _BUS_ADRERR = 0x2 |
| 91 | _BUS_OBJERR = 0x3 |
| 92 | |
| 93 | _SEGV_MAPERR = 0x1 |
| 94 | _SEGV_ACCERR = 0x2 |
| 95 | |
| 96 | _ITIMER_REAL = 0x0 |
| 97 | _ITIMER_VIRTUAL = 0x1 |
| 98 | _ITIMER_PROF = 0x2 |
| 99 | |
| 100 | _EV_ADD = 0x1 |
| 101 | _EV_DELETE = 0x2 |
| 102 | _EV_CLEAR = 0x20 |
| 103 | _EV_RECEIPT = 0x40 |
| 104 | _EV_ERROR = 0x4000 |
Ian Lance Taylor | 23aad44 | 2017-10-19 16:01:43 -0700 | [diff] [blame] | 105 | _EV_EOF = 0x8000 |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 106 | _EVFILT_READ = -0x1 |
| 107 | _EVFILT_WRITE = -0x2 |
| 108 | ) |
| 109 | |
| 110 | type rtprio struct { |
| 111 | _type uint16 |
| 112 | prio uint16 |
| 113 | } |
| 114 | |
| 115 | type thrparam struct { |
Russ Cox | aac17fd | 2014-11-11 23:00:29 -0500 | [diff] [blame] | 116 | start_func uintptr |
| 117 | arg unsafe.Pointer |
| 118 | stack_base uintptr |
| 119 | stack_size uintptr |
| 120 | tls_base unsafe.Pointer |
| 121 | tls_size uintptr |
| 122 | child_tid unsafe.Pointer // *int32 |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 123 | parent_tid *int32 |
| 124 | flags int32 |
| 125 | rtp *rtprio |
| 126 | spare [3]uintptr |
| 127 | } |
| 128 | |
Austin Clements | 8714e39 | 2019-10-14 17:05:56 -0400 | [diff] [blame] | 129 | type thread int32 // long |
| 130 | |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 131 | type sigset struct { |
| 132 | __bits [4]uint32 |
| 133 | } |
| 134 | |
| 135 | type stackt struct { |
Russ Cox | aac17fd | 2014-11-11 23:00:29 -0500 | [diff] [blame] | 136 | ss_sp uintptr |
| 137 | ss_size uintptr |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 138 | ss_flags int32 |
| 139 | } |
| 140 | |
| 141 | type siginfo struct { |
| 142 | si_signo int32 |
| 143 | si_errno int32 |
| 144 | si_code int32 |
| 145 | si_pid int32 |
| 146 | si_uid uint32 |
| 147 | si_status int32 |
Russ Cox | aac17fd | 2014-11-11 23:00:29 -0500 | [diff] [blame] | 148 | si_addr uintptr |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 149 | si_value [4]byte |
| 150 | _reason [32]byte |
| 151 | } |
| 152 | |
| 153 | type mcontext struct { |
| 154 | __gregs [17]uint32 |
| 155 | __fpu [140]byte |
| 156 | } |
| 157 | |
| 158 | type ucontext struct { |
| 159 | uc_sigmask sigset |
| 160 | uc_mcontext mcontext |
| 161 | uc_link *ucontext |
| 162 | uc_stack stackt |
| 163 | uc_flags int32 |
| 164 | __spare__ [4]int32 |
| 165 | } |
| 166 | |
| 167 | type timespec struct { |
| 168 | tv_sec int64 |
| 169 | tv_nsec int32 |
| 170 | pad_cgo_0 [4]byte |
| 171 | } |
| 172 | |
Ian Lance Taylor | 0a7bc8f | 2019-03-13 18:56:37 -0700 | [diff] [blame] | 173 | //go:nosplit |
| 174 | func (ts *timespec) setNsec(ns int64) { |
| 175 | ts.tv_sec = int64(timediv(ns, 1e9, &ts.tv_nsec)) |
Russ Cox | aac17fd | 2014-11-11 23:00:29 -0500 | [diff] [blame] | 176 | } |
| 177 | |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 178 | type timeval struct { |
| 179 | tv_sec int64 |
| 180 | tv_usec int32 |
| 181 | pad_cgo_0 [4]byte |
| 182 | } |
| 183 | |
Russ Cox | aac17fd | 2014-11-11 23:00:29 -0500 | [diff] [blame] | 184 | func (tv *timeval) set_usec(x int32) { |
| 185 | tv.tv_usec = x |
| 186 | } |
| 187 | |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 188 | type itimerval struct { |
| 189 | it_interval timeval |
| 190 | it_value timeval |
| 191 | } |
| 192 | |
Mike Appleby | 360f2e4 | 2016-09-28 16:01:27 -0500 | [diff] [blame] | 193 | type umtx_time struct { |
| 194 | _timeout timespec |
| 195 | _flags uint32 |
| 196 | _clockid uint32 |
| 197 | } |
| 198 | |
Russ Cox | 580ef3e | 2014-11-11 17:07:37 -0500 | [diff] [blame] | 199 | type keventt struct { |
| 200 | ident uint32 |
| 201 | filter int16 |
| 202 | flags uint16 |
| 203 | fflags uint32 |
| 204 | data int32 |
| 205 | udata *byte |
| 206 | } |
Yuval Pavel Zholkover | 744ccbb | 2018-02-05 17:11:27 +0200 | [diff] [blame] | 207 | |
| 208 | type bintime struct { |
| 209 | sec int64 |
| 210 | frac uint64 |
| 211 | } |
| 212 | |
| 213 | type vdsoTimehands struct { |
| 214 | algo uint32 |
| 215 | gen uint32 |
| 216 | scale uint64 |
| 217 | offset_count uint32 |
| 218 | counter_mask uint32 |
| 219 | offset bintime |
| 220 | boottime bintime |
| 221 | physical uint32 |
| 222 | res [7]uint32 |
| 223 | } |
| 224 | |
| 225 | type vdsoTimekeep struct { |
| 226 | ver uint32 |
| 227 | enabled uint32 |
| 228 | current uint32 |
| 229 | pad_cgo_0 [4]byte |
| 230 | } |
| 231 | |
| 232 | const ( |
| 233 | _VDSO_TK_VER_CURR = 0x1 |
| 234 | |
| 235 | vdsoTimehandsSize = 0x58 |
| 236 | vdsoTimekeepSize = 0x10 |
| 237 | ) |