| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
package linux |
| 13 |
|
| 14 |
import ( |
| 15 |
"inet.af/netstack/gohacks" |
| 16 |
"inet.af/netstack/hostarch" |
| 17 |
"inet.af/netstack/marshal" |
| 18 |
"io" |
| 19 |
"reflect" |
| 20 |
"runtime" |
| 21 |
"unsafe" |
| 22 |
) |
| 23 |
|
| 24 |
|
| 25 |
var _ marshal.Marshallable = (*EpollEvent)(nil) |
| 26 |
var _ marshal.Marshallable = (*IPCPerm)(nil) |
| 27 |
var _ marshal.Marshallable = (*PtraceRegs)(nil) |
| 28 |
var _ marshal.Marshallable = (*SemidDS)(nil) |
| 29 |
var _ marshal.Marshallable = (*Stat)(nil) |
| 30 |
var _ marshal.Marshallable = (*TimeT)(nil) |
| 31 |
var _ marshal.Marshallable = (*Timespec)(nil) |
| 32 |
|
| 33 |
|
| 34 |
func (e *EpollEvent) SizeBytes() int { |
| 35 |
return 4 + |
| 36 |
4*2 |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
func (e *EpollEvent) MarshalBytes(dst []byte) []byte { |
| 41 |
hostarch.ByteOrder.PutUint32(dst[:4], uint32(e.Events)) |
| 42 |
dst = dst[4:] |
| 43 |
for idx := 0; idx < 2; idx++ { |
| 44 |
hostarch.ByteOrder.PutUint32(dst[:4], uint32(e.Data[idx])) |
| 45 |
dst = dst[4:] |
| 46 |
} |
| 47 |
return dst |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
func (e *EpollEvent) UnmarshalBytes(src []byte) []byte { |
| 52 |
e.Events = uint32(hostarch.ByteOrder.Uint32(src[:4])) |
| 53 |
src = src[4:] |
| 54 |
for idx := 0; idx < 2; idx++ { |
| 55 |
e.Data[idx] = int32(hostarch.ByteOrder.Uint32(src[:4])) |
| 56 |
src = src[4:] |
| 57 |
} |
| 58 |
return src |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
func (e *EpollEvent) Packed() bool { |
| 64 |
return true |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
func (e *EpollEvent) MarshalUnsafe(dst []byte) []byte { |
| 69 |
size := e.SizeBytes() |
| 70 |
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(e), uintptr(size)) |
| 71 |
return dst[size:] |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
func (e *EpollEvent) UnmarshalUnsafe(src []byte) []byte { |
| 76 |
size := e.SizeBytes() |
| 77 |
gohacks.Memmove(unsafe.Pointer(e), unsafe.Pointer(&src[0]), uintptr(size)) |
| 78 |
return src[size:] |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
func (e *EpollEvent) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { |
| 84 |
|
| 85 |
var buf []byte |
| 86 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 87 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(e))) |
| 88 |
hdr.Len = e.SizeBytes() |
| 89 |
hdr.Cap = e.SizeBytes() |
| 90 |
|
| 91 |
length, err := cc.CopyOutBytes(addr, buf[:limit]) |
| 92 |
|
| 93 |
|
| 94 |
runtime.KeepAlive(e) |
| 95 |
return length, err |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
func (e *EpollEvent) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 101 |
return e.CopyOutN(cc, addr, e.SizeBytes()) |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
func (e *EpollEvent) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 107 |
|
| 108 |
var buf []byte |
| 109 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 110 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(e))) |
| 111 |
hdr.Len = e.SizeBytes() |
| 112 |
hdr.Cap = e.SizeBytes() |
| 113 |
|
| 114 |
length, err := cc.CopyInBytes(addr, buf) |
| 115 |
|
| 116 |
|
| 117 |
runtime.KeepAlive(e) |
| 118 |
return length, err |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
func (e *EpollEvent) WriteTo(writer io.Writer) (int64, error) { |
| 123 |
|
| 124 |
var buf []byte |
| 125 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 126 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(e))) |
| 127 |
hdr.Len = e.SizeBytes() |
| 128 |
hdr.Cap = e.SizeBytes() |
| 129 |
|
| 130 |
length, err := writer.Write(buf) |
| 131 |
|
| 132 |
|
| 133 |
runtime.KeepAlive(e) |
| 134 |
return int64(length), err |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
func CopyEpollEventSliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []EpollEvent) (int, error) { |
| 139 |
count := len(dst) |
| 140 |
if count == 0 { |
| 141 |
return 0, nil |
| 142 |
} |
| 143 |
size := (*EpollEvent)(nil).SizeBytes() |
| 144 |
|
| 145 |
ptr := unsafe.Pointer(&dst) |
| 146 |
val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) |
| 147 |
|
| 148 |
|
| 149 |
var buf []byte |
| 150 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 151 |
hdr.Data = uintptr(val) |
| 152 |
hdr.Len = size * count |
| 153 |
hdr.Cap = size * count |
| 154 |
|
| 155 |
length, err := cc.CopyInBytes(addr, buf) |
| 156 |
|
| 157 |
|
| 158 |
runtime.KeepAlive(dst) |
| 159 |
return length, err |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
func CopyEpollEventSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []EpollEvent) (int, error) { |
| 164 |
count := len(src) |
| 165 |
if count == 0 { |
| 166 |
return 0, nil |
| 167 |
} |
| 168 |
size := (*EpollEvent)(nil).SizeBytes() |
| 169 |
|
| 170 |
ptr := unsafe.Pointer(&src) |
| 171 |
val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) |
| 172 |
|
| 173 |
|
| 174 |
var buf []byte |
| 175 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 176 |
hdr.Data = uintptr(val) |
| 177 |
hdr.Len = size * count |
| 178 |
hdr.Cap = size * count |
| 179 |
|
| 180 |
length, err := cc.CopyOutBytes(addr, buf) |
| 181 |
|
| 182 |
|
| 183 |
runtime.KeepAlive(src) |
| 184 |
return length, err |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
func MarshalUnsafeEpollEventSlice(src []EpollEvent, dst []byte) []byte { |
| 189 |
count := len(src) |
| 190 |
if count == 0 { |
| 191 |
return dst |
| 192 |
} |
| 193 |
|
| 194 |
size := (*EpollEvent)(nil).SizeBytes() |
| 195 |
buf := dst[:size*count] |
| 196 |
gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf))) |
| 197 |
return dst[size*count:] |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
func UnmarshalUnsafeEpollEventSlice(dst []EpollEvent, src []byte) []byte { |
| 202 |
count := len(dst) |
| 203 |
if count == 0 { |
| 204 |
return src |
| 205 |
} |
| 206 |
|
| 207 |
size := (*EpollEvent)(nil).SizeBytes() |
| 208 |
buf := src[:size*count] |
| 209 |
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf))) |
| 210 |
return src[size*count:] |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
func (s *Stat) SizeBytes() int { |
| 215 |
return 72 + |
| 216 |
(*Timespec)(nil).SizeBytes() + |
| 217 |
(*Timespec)(nil).SizeBytes() + |
| 218 |
(*Timespec)(nil).SizeBytes() + |
| 219 |
8*3 |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
func (s *Stat) MarshalBytes(dst []byte) []byte { |
| 224 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Dev)) |
| 225 |
dst = dst[8:] |
| 226 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Ino)) |
| 227 |
dst = dst[8:] |
| 228 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Nlink)) |
| 229 |
dst = dst[8:] |
| 230 |
hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.Mode)) |
| 231 |
dst = dst[4:] |
| 232 |
hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.UID)) |
| 233 |
dst = dst[4:] |
| 234 |
hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.GID)) |
| 235 |
dst = dst[4:] |
| 236 |
|
| 237 |
dst = dst[4:] |
| 238 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Rdev)) |
| 239 |
dst = dst[8:] |
| 240 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Size)) |
| 241 |
dst = dst[8:] |
| 242 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Blksize)) |
| 243 |
dst = dst[8:] |
| 244 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Blocks)) |
| 245 |
dst = dst[8:] |
| 246 |
dst = s.ATime.MarshalUnsafe(dst) |
| 247 |
dst = s.MTime.MarshalUnsafe(dst) |
| 248 |
dst = s.CTime.MarshalUnsafe(dst) |
| 249 |
|
| 250 |
dst = dst[8*(3):] |
| 251 |
return dst |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
func (s *Stat) UnmarshalBytes(src []byte) []byte { |
| 256 |
s.Dev = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 257 |
src = src[8:] |
| 258 |
s.Ino = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 259 |
src = src[8:] |
| 260 |
s.Nlink = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 261 |
src = src[8:] |
| 262 |
s.Mode = uint32(hostarch.ByteOrder.Uint32(src[:4])) |
| 263 |
src = src[4:] |
| 264 |
s.UID = uint32(hostarch.ByteOrder.Uint32(src[:4])) |
| 265 |
src = src[4:] |
| 266 |
s.GID = uint32(hostarch.ByteOrder.Uint32(src[:4])) |
| 267 |
src = src[4:] |
| 268 |
|
| 269 |
src = src[4:] |
| 270 |
s.Rdev = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 271 |
src = src[8:] |
| 272 |
s.Size = int64(hostarch.ByteOrder.Uint64(src[:8])) |
| 273 |
src = src[8:] |
| 274 |
s.Blksize = int64(hostarch.ByteOrder.Uint64(src[:8])) |
| 275 |
src = src[8:] |
| 276 |
s.Blocks = int64(hostarch.ByteOrder.Uint64(src[:8])) |
| 277 |
src = src[8:] |
| 278 |
src = s.ATime.UnmarshalUnsafe(src) |
| 279 |
src = s.MTime.UnmarshalUnsafe(src) |
| 280 |
src = s.CTime.UnmarshalUnsafe(src) |
| 281 |
|
| 282 |
src = src[8*(3):] |
| 283 |
return src |
| 284 |
} |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
func (s *Stat) Packed() bool { |
| 289 |
return s.ATime.Packed() && s.CTime.Packed() && s.MTime.Packed() |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
func (s *Stat) MarshalUnsafe(dst []byte) []byte { |
| 294 |
if s.ATime.Packed() && s.CTime.Packed() && s.MTime.Packed() { |
| 295 |
size := s.SizeBytes() |
| 296 |
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) |
| 297 |
return dst[size:] |
| 298 |
} |
| 299 |
|
| 300 |
return s.MarshalBytes(dst) |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
func (s *Stat) UnmarshalUnsafe(src []byte) []byte { |
| 305 |
if s.ATime.Packed() && s.CTime.Packed() && s.MTime.Packed() { |
| 306 |
size := s.SizeBytes() |
| 307 |
gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) |
| 308 |
return src[size:] |
| 309 |
} |
| 310 |
|
| 311 |
return s.UnmarshalBytes(src) |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
func (s *Stat) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { |
| 317 |
if !s.ATime.Packed() && s.CTime.Packed() && s.MTime.Packed() { |
| 318 |
|
| 319 |
buf := cc.CopyScratchBuffer(s.SizeBytes()) |
| 320 |
s.MarshalBytes(buf) |
| 321 |
return cc.CopyOutBytes(addr, buf[:limit]) |
| 322 |
} |
| 323 |
|
| 324 |
|
| 325 |
var buf []byte |
| 326 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 327 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) |
| 328 |
hdr.Len = s.SizeBytes() |
| 329 |
hdr.Cap = s.SizeBytes() |
| 330 |
|
| 331 |
length, err := cc.CopyOutBytes(addr, buf[:limit]) |
| 332 |
|
| 333 |
|
| 334 |
runtime.KeepAlive(s) |
| 335 |
return length, err |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
func (s *Stat) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 341 |
return s.CopyOutN(cc, addr, s.SizeBytes()) |
| 342 |
} |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
func (s *Stat) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 347 |
if !s.ATime.Packed() && s.CTime.Packed() && s.MTime.Packed() { |
| 348 |
|
| 349 |
buf := cc.CopyScratchBuffer(s.SizeBytes()) |
| 350 |
length, err := cc.CopyInBytes(addr, buf) |
| 351 |
|
| 352 |
|
| 353 |
s.UnmarshalBytes(buf) |
| 354 |
return length, err |
| 355 |
} |
| 356 |
|
| 357 |
|
| 358 |
var buf []byte |
| 359 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 360 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) |
| 361 |
hdr.Len = s.SizeBytes() |
| 362 |
hdr.Cap = s.SizeBytes() |
| 363 |
|
| 364 |
length, err := cc.CopyInBytes(addr, buf) |
| 365 |
|
| 366 |
|
| 367 |
runtime.KeepAlive(s) |
| 368 |
return length, err |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
func (s *Stat) WriteTo(writer io.Writer) (int64, error) { |
| 373 |
if !s.ATime.Packed() && s.CTime.Packed() && s.MTime.Packed() { |
| 374 |
|
| 375 |
buf := make([]byte, s.SizeBytes()) |
| 376 |
s.MarshalBytes(buf) |
| 377 |
length, err := writer.Write(buf) |
| 378 |
return int64(length), err |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
var buf []byte |
| 383 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 384 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) |
| 385 |
hdr.Len = s.SizeBytes() |
| 386 |
hdr.Cap = s.SizeBytes() |
| 387 |
|
| 388 |
length, err := writer.Write(buf) |
| 389 |
|
| 390 |
|
| 391 |
runtime.KeepAlive(s) |
| 392 |
return int64(length), err |
| 393 |
} |
| 394 |
|
| 395 |
|
| 396 |
func (p *PtraceRegs) SizeBytes() int { |
| 397 |
return 216 |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
func (p *PtraceRegs) MarshalBytes(dst []byte) []byte { |
| 402 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R15)) |
| 403 |
dst = dst[8:] |
| 404 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R14)) |
| 405 |
dst = dst[8:] |
| 406 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R13)) |
| 407 |
dst = dst[8:] |
| 408 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R12)) |
| 409 |
dst = dst[8:] |
| 410 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rbp)) |
| 411 |
dst = dst[8:] |
| 412 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rbx)) |
| 413 |
dst = dst[8:] |
| 414 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R11)) |
| 415 |
dst = dst[8:] |
| 416 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R10)) |
| 417 |
dst = dst[8:] |
| 418 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R9)) |
| 419 |
dst = dst[8:] |
| 420 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.R8)) |
| 421 |
dst = dst[8:] |
| 422 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rax)) |
| 423 |
dst = dst[8:] |
| 424 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rcx)) |
| 425 |
dst = dst[8:] |
| 426 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rdx)) |
| 427 |
dst = dst[8:] |
| 428 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rsi)) |
| 429 |
dst = dst[8:] |
| 430 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rdi)) |
| 431 |
dst = dst[8:] |
| 432 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Orig_rax)) |
| 433 |
dst = dst[8:] |
| 434 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rip)) |
| 435 |
dst = dst[8:] |
| 436 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Cs)) |
| 437 |
dst = dst[8:] |
| 438 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Eflags)) |
| 439 |
dst = dst[8:] |
| 440 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Rsp)) |
| 441 |
dst = dst[8:] |
| 442 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Ss)) |
| 443 |
dst = dst[8:] |
| 444 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Fs_base)) |
| 445 |
dst = dst[8:] |
| 446 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Gs_base)) |
| 447 |
dst = dst[8:] |
| 448 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Ds)) |
| 449 |
dst = dst[8:] |
| 450 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Es)) |
| 451 |
dst = dst[8:] |
| 452 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Fs)) |
| 453 |
dst = dst[8:] |
| 454 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(p.Gs)) |
| 455 |
dst = dst[8:] |
| 456 |
return dst |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
func (p *PtraceRegs) UnmarshalBytes(src []byte) []byte { |
| 461 |
p.R15 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 462 |
src = src[8:] |
| 463 |
p.R14 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 464 |
src = src[8:] |
| 465 |
p.R13 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 466 |
src = src[8:] |
| 467 |
p.R12 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 468 |
src = src[8:] |
| 469 |
p.Rbp = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 470 |
src = src[8:] |
| 471 |
p.Rbx = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 472 |
src = src[8:] |
| 473 |
p.R11 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 474 |
src = src[8:] |
| 475 |
p.R10 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 476 |
src = src[8:] |
| 477 |
p.R9 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 478 |
src = src[8:] |
| 479 |
p.R8 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 480 |
src = src[8:] |
| 481 |
p.Rax = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 482 |
src = src[8:] |
| 483 |
p.Rcx = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 484 |
src = src[8:] |
| 485 |
p.Rdx = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 486 |
src = src[8:] |
| 487 |
p.Rsi = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 488 |
src = src[8:] |
| 489 |
p.Rdi = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 490 |
src = src[8:] |
| 491 |
p.Orig_rax = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 492 |
src = src[8:] |
| 493 |
p.Rip = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 494 |
src = src[8:] |
| 495 |
p.Cs = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 496 |
src = src[8:] |
| 497 |
p.Eflags = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 498 |
src = src[8:] |
| 499 |
p.Rsp = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 500 |
src = src[8:] |
| 501 |
p.Ss = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 502 |
src = src[8:] |
| 503 |
p.Fs_base = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 504 |
src = src[8:] |
| 505 |
p.Gs_base = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 506 |
src = src[8:] |
| 507 |
p.Ds = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 508 |
src = src[8:] |
| 509 |
p.Es = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 510 |
src = src[8:] |
| 511 |
p.Fs = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 512 |
src = src[8:] |
| 513 |
p.Gs = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 514 |
src = src[8:] |
| 515 |
return src |
| 516 |
} |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
func (p *PtraceRegs) Packed() bool { |
| 521 |
return true |
| 522 |
} |
| 523 |
|
| 524 |
|
| 525 |
func (p *PtraceRegs) MarshalUnsafe(dst []byte) []byte { |
| 526 |
size := p.SizeBytes() |
| 527 |
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(p), uintptr(size)) |
| 528 |
return dst[size:] |
| 529 |
} |
| 530 |
|
| 531 |
|
| 532 |
func (p *PtraceRegs) UnmarshalUnsafe(src []byte) []byte { |
| 533 |
size := p.SizeBytes() |
| 534 |
gohacks.Memmove(unsafe.Pointer(p), unsafe.Pointer(&src[0]), uintptr(size)) |
| 535 |
return src[size:] |
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
func (p *PtraceRegs) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { |
| 541 |
|
| 542 |
var buf []byte |
| 543 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 544 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(p))) |
| 545 |
hdr.Len = p.SizeBytes() |
| 546 |
hdr.Cap = p.SizeBytes() |
| 547 |
|
| 548 |
length, err := cc.CopyOutBytes(addr, buf[:limit]) |
| 549 |
|
| 550 |
|
| 551 |
runtime.KeepAlive(p) |
| 552 |
return length, err |
| 553 |
} |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
func (p *PtraceRegs) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 558 |
return p.CopyOutN(cc, addr, p.SizeBytes()) |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
func (p *PtraceRegs) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 564 |
|
| 565 |
var buf []byte |
| 566 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 567 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(p))) |
| 568 |
hdr.Len = p.SizeBytes() |
| 569 |
hdr.Cap = p.SizeBytes() |
| 570 |
|
| 571 |
length, err := cc.CopyInBytes(addr, buf) |
| 572 |
|
| 573 |
|
| 574 |
runtime.KeepAlive(p) |
| 575 |
return length, err |
| 576 |
} |
| 577 |
|
| 578 |
|
| 579 |
func (p *PtraceRegs) WriteTo(writer io.Writer) (int64, error) { |
| 580 |
|
| 581 |
var buf []byte |
| 582 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 583 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(p))) |
| 584 |
hdr.Len = p.SizeBytes() |
| 585 |
hdr.Cap = p.SizeBytes() |
| 586 |
|
| 587 |
length, err := writer.Write(buf) |
| 588 |
|
| 589 |
|
| 590 |
runtime.KeepAlive(p) |
| 591 |
return int64(length), err |
| 592 |
} |
| 593 |
|
| 594 |
|
| 595 |
func (s *SemidDS) SizeBytes() int { |
| 596 |
return 40 + |
| 597 |
(*IPCPerm)(nil).SizeBytes() + |
| 598 |
(*TimeT)(nil).SizeBytes() + |
| 599 |
(*TimeT)(nil).SizeBytes() |
| 600 |
} |
| 601 |
|
| 602 |
|
| 603 |
func (s *SemidDS) MarshalBytes(dst []byte) []byte { |
| 604 |
dst = s.SemPerm.MarshalUnsafe(dst) |
| 605 |
dst = s.SemOTime.MarshalUnsafe(dst) |
| 606 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.unused1)) |
| 607 |
dst = dst[8:] |
| 608 |
dst = s.SemCTime.MarshalUnsafe(dst) |
| 609 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.unused2)) |
| 610 |
dst = dst[8:] |
| 611 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.SemNSems)) |
| 612 |
dst = dst[8:] |
| 613 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.unused3)) |
| 614 |
dst = dst[8:] |
| 615 |
hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.unused4)) |
| 616 |
dst = dst[8:] |
| 617 |
return dst |
| 618 |
} |
| 619 |
|
| 620 |
|
| 621 |
func (s *SemidDS) UnmarshalBytes(src []byte) []byte { |
| 622 |
src = s.SemPerm.UnmarshalUnsafe(src) |
| 623 |
src = s.SemOTime.UnmarshalUnsafe(src) |
| 624 |
s.unused1 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 625 |
src = src[8:] |
| 626 |
src = s.SemCTime.UnmarshalUnsafe(src) |
| 627 |
s.unused2 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 628 |
src = src[8:] |
| 629 |
s.SemNSems = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 630 |
src = src[8:] |
| 631 |
s.unused3 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 632 |
src = src[8:] |
| 633 |
s.unused4 = uint64(hostarch.ByteOrder.Uint64(src[:8])) |
| 634 |
src = src[8:] |
| 635 |
return src |
| 636 |
} |
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
func (s *SemidDS) Packed() bool { |
| 641 |
return s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() |
| 642 |
} |
| 643 |
|
| 644 |
|
| 645 |
func (s *SemidDS) MarshalUnsafe(dst []byte) []byte { |
| 646 |
if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { |
| 647 |
size := s.SizeBytes() |
| 648 |
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) |
| 649 |
return dst[size:] |
| 650 |
} |
| 651 |
|
| 652 |
return s.MarshalBytes(dst) |
| 653 |
} |
| 654 |
|
| 655 |
|
| 656 |
func (s *SemidDS) UnmarshalUnsafe(src []byte) []byte { |
| 657 |
if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { |
| 658 |
size := s.SizeBytes() |
| 659 |
gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) |
| 660 |
return src[size:] |
| 661 |
} |
| 662 |
|
| 663 |
return s.UnmarshalBytes(src) |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
func (s *SemidDS) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { |
| 669 |
if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { |
| 670 |
|
| 671 |
buf := cc.CopyScratchBuffer(s.SizeBytes()) |
| 672 |
s.MarshalBytes(buf) |
| 673 |
return cc.CopyOutBytes(addr, buf[:limit]) |
| 674 |
} |
| 675 |
|
| 676 |
|
| 677 |
var buf []byte |
| 678 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 679 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) |
| 680 |
hdr.Len = s.SizeBytes() |
| 681 |
hdr.Cap = s.SizeBytes() |
| 682 |
|
| 683 |
length, err := cc.CopyOutBytes(addr, buf[:limit]) |
| 684 |
|
| 685 |
|
| 686 |
runtime.KeepAlive(s) |
| 687 |
return length, err |
| 688 |
} |
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
func (s *SemidDS) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 693 |
return s.CopyOutN(cc, addr, s.SizeBytes()) |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
func (s *SemidDS) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { |
| 699 |
if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { |
| 700 |
|
| 701 |
buf := cc.CopyScratchBuffer(s.SizeBytes()) |
| 702 |
length, err := cc.CopyInBytes(addr, buf) |
| 703 |
|
| 704 |
|
| 705 |
s.UnmarshalBytes(buf) |
| 706 |
return length, err |
| 707 |
} |
| 708 |
|
| 709 |
|
| 710 |
var buf []byte |
| 711 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 712 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) |
| 713 |
hdr.Len = s.SizeBytes() |
| 714 |
hdr.Cap = s.SizeBytes() |
| 715 |
|
| 716 |
length, err := cc.CopyInBytes(addr, buf) |
| 717 |
|
| 718 |
|
| 719 |
runtime.KeepAlive(s) |
| 720 |
return length, err |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
func (s *SemidDS) WriteTo(writer io.Writer) (int64, error) { |
| 725 |
if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { |
| 726 |
|
| 727 |
buf := make([]byte, s.SizeBytes()) |
| 728 |
s.MarshalBytes(buf) |
| 729 |
length, err := writer.Write(buf) |
| 730 |
return int64(length), err |
| 731 |
} |
| 732 |
|
| 733 |
|
| 734 |
var buf []byte |
| 735 |
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) |
| 736 |
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) |
| 737 |
hdr.Len = s.SizeBytes() |
| 738 |
hdr.Cap = s.SizeBytes() |
| 739 |
|
| 740 |
length, err := writer.Write(buf) |
| 741 |
|
| 742 |
|
| 743 |
runtime.KeepAlive(s) |
| 744 |
return int64(length), err |
| 745 |
} |
| 746 |
|