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