github.com/metacubex/gvisor@v0.0.0-20240320004321-933faba989ec/pkg/sentry/syscalls/linux/linux_abi_autogen_unsafe.go (about) 1 // Automatically generated marshal implementation. See tools/go_marshal. 2 3 package linux 4 5 import ( 6 "github.com/metacubex/gvisor/pkg/gohacks" 7 "github.com/metacubex/gvisor/pkg/hostarch" 8 "github.com/metacubex/gvisor/pkg/marshal" 9 "io" 10 "reflect" 11 "runtime" 12 "unsafe" 13 ) 14 15 // Marshallable types used by this file. 16 var _ marshal.Marshallable = (*MessageHeader64)(nil) 17 var _ marshal.Marshallable = (*SchedParam)(nil) 18 var _ marshal.Marshallable = (*multipleMessageHeader64)(nil) 19 var _ marshal.Marshallable = (*rlimit64)(nil) 20 var _ marshal.Marshallable = (*sigSetWithSize)(nil) 21 var _ marshal.Marshallable = (*userSockFprog)(nil) 22 23 // SizeBytes implements marshal.Marshallable.SizeBytes. 24 func (s *sigSetWithSize) SizeBytes() int { 25 return 16 26 } 27 28 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 29 func (s *sigSetWithSize) MarshalBytes(dst []byte) []byte { 30 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.sigsetAddr)) 31 dst = dst[8:] 32 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.sizeofSigset)) 33 dst = dst[8:] 34 return dst 35 } 36 37 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 38 func (s *sigSetWithSize) UnmarshalBytes(src []byte) []byte { 39 s.sigsetAddr = uint64(hostarch.ByteOrder.Uint64(src[:8])) 40 src = src[8:] 41 s.sizeofSigset = uint64(hostarch.ByteOrder.Uint64(src[:8])) 42 src = src[8:] 43 return src 44 } 45 46 // Packed implements marshal.Marshallable.Packed. 47 //go:nosplit 48 func (s *sigSetWithSize) Packed() bool { 49 return true 50 } 51 52 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 53 func (s *sigSetWithSize) MarshalUnsafe(dst []byte) []byte { 54 size := s.SizeBytes() 55 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 56 return dst[size:] 57 } 58 59 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 60 func (s *sigSetWithSize) UnmarshalUnsafe(src []byte) []byte { 61 size := s.SizeBytes() 62 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 63 return src[size:] 64 } 65 66 // CopyOutN implements marshal.Marshallable.CopyOutN. 67 func (s *sigSetWithSize) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 68 // Construct a slice backed by dst's underlying memory. 69 var buf []byte 70 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 71 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 72 hdr.Len = s.SizeBytes() 73 hdr.Cap = s.SizeBytes() 74 75 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 76 // Since we bypassed the compiler's escape analysis, indicate that s 77 // must live until the use above. 78 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 79 return length, err 80 } 81 82 // CopyOut implements marshal.Marshallable.CopyOut. 83 func (s *sigSetWithSize) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 84 return s.CopyOutN(cc, addr, s.SizeBytes()) 85 } 86 87 // CopyInN implements marshal.Marshallable.CopyInN. 88 func (s *sigSetWithSize) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 89 // Construct a slice backed by dst's underlying memory. 90 var buf []byte 91 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 92 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 93 hdr.Len = s.SizeBytes() 94 hdr.Cap = s.SizeBytes() 95 96 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 97 // Since we bypassed the compiler's escape analysis, indicate that s 98 // must live until the use above. 99 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 100 return length, err 101 } 102 103 // CopyIn implements marshal.Marshallable.CopyIn. 104 func (s *sigSetWithSize) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 105 return s.CopyInN(cc, addr, s.SizeBytes()) 106 } 107 108 // WriteTo implements io.WriterTo.WriteTo. 109 func (s *sigSetWithSize) WriteTo(writer io.Writer) (int64, error) { 110 // Construct a slice backed by dst's underlying memory. 111 var buf []byte 112 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 113 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 114 hdr.Len = s.SizeBytes() 115 hdr.Cap = s.SizeBytes() 116 117 length, err := writer.Write(buf) 118 // Since we bypassed the compiler's escape analysis, indicate that s 119 // must live until the use above. 120 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 121 return int64(length), err 122 } 123 124 // SizeBytes implements marshal.Marshallable.SizeBytes. 125 func (r *rlimit64) SizeBytes() int { 126 return 16 127 } 128 129 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 130 func (r *rlimit64) MarshalBytes(dst []byte) []byte { 131 hostarch.ByteOrder.PutUint64(dst[:8], uint64(r.Cur)) 132 dst = dst[8:] 133 hostarch.ByteOrder.PutUint64(dst[:8], uint64(r.Max)) 134 dst = dst[8:] 135 return dst 136 } 137 138 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 139 func (r *rlimit64) UnmarshalBytes(src []byte) []byte { 140 r.Cur = uint64(hostarch.ByteOrder.Uint64(src[:8])) 141 src = src[8:] 142 r.Max = uint64(hostarch.ByteOrder.Uint64(src[:8])) 143 src = src[8:] 144 return src 145 } 146 147 // Packed implements marshal.Marshallable.Packed. 148 //go:nosplit 149 func (r *rlimit64) Packed() bool { 150 return true 151 } 152 153 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 154 func (r *rlimit64) MarshalUnsafe(dst []byte) []byte { 155 size := r.SizeBytes() 156 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(r), uintptr(size)) 157 return dst[size:] 158 } 159 160 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 161 func (r *rlimit64) UnmarshalUnsafe(src []byte) []byte { 162 size := r.SizeBytes() 163 gohacks.Memmove(unsafe.Pointer(r), unsafe.Pointer(&src[0]), uintptr(size)) 164 return src[size:] 165 } 166 167 // CopyOutN implements marshal.Marshallable.CopyOutN. 168 func (r *rlimit64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 169 // Construct a slice backed by dst's underlying memory. 170 var buf []byte 171 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 172 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 173 hdr.Len = r.SizeBytes() 174 hdr.Cap = r.SizeBytes() 175 176 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 177 // Since we bypassed the compiler's escape analysis, indicate that r 178 // must live until the use above. 179 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 180 return length, err 181 } 182 183 // CopyOut implements marshal.Marshallable.CopyOut. 184 func (r *rlimit64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 185 return r.CopyOutN(cc, addr, r.SizeBytes()) 186 } 187 188 // CopyInN implements marshal.Marshallable.CopyInN. 189 func (r *rlimit64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 190 // Construct a slice backed by dst's underlying memory. 191 var buf []byte 192 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 193 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 194 hdr.Len = r.SizeBytes() 195 hdr.Cap = r.SizeBytes() 196 197 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 198 // Since we bypassed the compiler's escape analysis, indicate that r 199 // must live until the use above. 200 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 201 return length, err 202 } 203 204 // CopyIn implements marshal.Marshallable.CopyIn. 205 func (r *rlimit64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 206 return r.CopyInN(cc, addr, r.SizeBytes()) 207 } 208 209 // WriteTo implements io.WriterTo.WriteTo. 210 func (r *rlimit64) WriteTo(writer io.Writer) (int64, error) { 211 // Construct a slice backed by dst's underlying memory. 212 var buf []byte 213 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 214 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 215 hdr.Len = r.SizeBytes() 216 hdr.Cap = r.SizeBytes() 217 218 length, err := writer.Write(buf) 219 // Since we bypassed the compiler's escape analysis, indicate that r 220 // must live until the use above. 221 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 222 return int64(length), err 223 } 224 225 // SizeBytes implements marshal.Marshallable.SizeBytes. 226 func (s *SchedParam) SizeBytes() int { 227 return 4 228 } 229 230 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 231 func (s *SchedParam) MarshalBytes(dst []byte) []byte { 232 hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.schedPriority)) 233 dst = dst[4:] 234 return dst 235 } 236 237 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 238 func (s *SchedParam) UnmarshalBytes(src []byte) []byte { 239 s.schedPriority = int32(hostarch.ByteOrder.Uint32(src[:4])) 240 src = src[4:] 241 return src 242 } 243 244 // Packed implements marshal.Marshallable.Packed. 245 //go:nosplit 246 func (s *SchedParam) Packed() bool { 247 return true 248 } 249 250 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 251 func (s *SchedParam) MarshalUnsafe(dst []byte) []byte { 252 size := s.SizeBytes() 253 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 254 return dst[size:] 255 } 256 257 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 258 func (s *SchedParam) UnmarshalUnsafe(src []byte) []byte { 259 size := s.SizeBytes() 260 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 261 return src[size:] 262 } 263 264 // CopyOutN implements marshal.Marshallable.CopyOutN. 265 func (s *SchedParam) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 266 // Construct a slice backed by dst's underlying memory. 267 var buf []byte 268 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 269 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 270 hdr.Len = s.SizeBytes() 271 hdr.Cap = s.SizeBytes() 272 273 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 274 // Since we bypassed the compiler's escape analysis, indicate that s 275 // must live until the use above. 276 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 277 return length, err 278 } 279 280 // CopyOut implements marshal.Marshallable.CopyOut. 281 func (s *SchedParam) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 282 return s.CopyOutN(cc, addr, s.SizeBytes()) 283 } 284 285 // CopyInN implements marshal.Marshallable.CopyInN. 286 func (s *SchedParam) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 287 // Construct a slice backed by dst's underlying memory. 288 var buf []byte 289 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 290 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 291 hdr.Len = s.SizeBytes() 292 hdr.Cap = s.SizeBytes() 293 294 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 295 // Since we bypassed the compiler's escape analysis, indicate that s 296 // must live until the use above. 297 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 298 return length, err 299 } 300 301 // CopyIn implements marshal.Marshallable.CopyIn. 302 func (s *SchedParam) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 303 return s.CopyInN(cc, addr, s.SizeBytes()) 304 } 305 306 // WriteTo implements io.WriterTo.WriteTo. 307 func (s *SchedParam) WriteTo(writer io.Writer) (int64, error) { 308 // Construct a slice backed by dst's underlying memory. 309 var buf []byte 310 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 311 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 312 hdr.Len = s.SizeBytes() 313 hdr.Cap = s.SizeBytes() 314 315 length, err := writer.Write(buf) 316 // Since we bypassed the compiler's escape analysis, indicate that s 317 // must live until the use above. 318 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 319 return int64(length), err 320 } 321 322 // SizeBytes implements marshal.Marshallable.SizeBytes. 323 func (u *userSockFprog) SizeBytes() int { 324 return 10 + 325 1*6 326 } 327 328 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 329 func (u *userSockFprog) MarshalBytes(dst []byte) []byte { 330 hostarch.ByteOrder.PutUint16(dst[:2], uint16(u.Len)) 331 dst = dst[2:] 332 // Padding: dst[:sizeof(byte)*6] ~= [6]byte{0} 333 dst = dst[1*(6):] 334 hostarch.ByteOrder.PutUint64(dst[:8], uint64(u.Filter)) 335 dst = dst[8:] 336 return dst 337 } 338 339 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 340 func (u *userSockFprog) UnmarshalBytes(src []byte) []byte { 341 u.Len = uint16(hostarch.ByteOrder.Uint16(src[:2])) 342 src = src[2:] 343 // Padding: ~ copy([6]byte(u._), src[:sizeof(byte)*6]) 344 src = src[1*(6):] 345 u.Filter = uint64(hostarch.ByteOrder.Uint64(src[:8])) 346 src = src[8:] 347 return src 348 } 349 350 // Packed implements marshal.Marshallable.Packed. 351 //go:nosplit 352 func (u *userSockFprog) Packed() bool { 353 return true 354 } 355 356 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 357 func (u *userSockFprog) MarshalUnsafe(dst []byte) []byte { 358 size := u.SizeBytes() 359 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(u), uintptr(size)) 360 return dst[size:] 361 } 362 363 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 364 func (u *userSockFprog) UnmarshalUnsafe(src []byte) []byte { 365 size := u.SizeBytes() 366 gohacks.Memmove(unsafe.Pointer(u), unsafe.Pointer(&src[0]), uintptr(size)) 367 return src[size:] 368 } 369 370 // CopyOutN implements marshal.Marshallable.CopyOutN. 371 func (u *userSockFprog) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 372 // Construct a slice backed by dst's underlying memory. 373 var buf []byte 374 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 375 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u))) 376 hdr.Len = u.SizeBytes() 377 hdr.Cap = u.SizeBytes() 378 379 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 380 // Since we bypassed the compiler's escape analysis, indicate that u 381 // must live until the use above. 382 runtime.KeepAlive(u) // escapes: replaced by intrinsic. 383 return length, err 384 } 385 386 // CopyOut implements marshal.Marshallable.CopyOut. 387 func (u *userSockFprog) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 388 return u.CopyOutN(cc, addr, u.SizeBytes()) 389 } 390 391 // CopyInN implements marshal.Marshallable.CopyInN. 392 func (u *userSockFprog) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 393 // Construct a slice backed by dst's underlying memory. 394 var buf []byte 395 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 396 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u))) 397 hdr.Len = u.SizeBytes() 398 hdr.Cap = u.SizeBytes() 399 400 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 401 // Since we bypassed the compiler's escape analysis, indicate that u 402 // must live until the use above. 403 runtime.KeepAlive(u) // escapes: replaced by intrinsic. 404 return length, err 405 } 406 407 // CopyIn implements marshal.Marshallable.CopyIn. 408 func (u *userSockFprog) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 409 return u.CopyInN(cc, addr, u.SizeBytes()) 410 } 411 412 // WriteTo implements io.WriterTo.WriteTo. 413 func (u *userSockFprog) WriteTo(writer io.Writer) (int64, error) { 414 // Construct a slice backed by dst's underlying memory. 415 var buf []byte 416 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 417 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(u))) 418 hdr.Len = u.SizeBytes() 419 hdr.Cap = u.SizeBytes() 420 421 length, err := writer.Write(buf) 422 // Since we bypassed the compiler's escape analysis, indicate that u 423 // must live until the use above. 424 runtime.KeepAlive(u) // escapes: replaced by intrinsic. 425 return int64(length), err 426 } 427 428 // SizeBytes implements marshal.Marshallable.SizeBytes. 429 func (m *MessageHeader64) SizeBytes() int { 430 return 56 431 } 432 433 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 434 func (m *MessageHeader64) MarshalBytes(dst []byte) []byte { 435 hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.Name)) 436 dst = dst[8:] 437 hostarch.ByteOrder.PutUint32(dst[:4], uint32(m.NameLen)) 438 dst = dst[4:] 439 // Padding: dst[:sizeof(uint32)] ~= uint32(0) 440 dst = dst[4:] 441 hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.Iov)) 442 dst = dst[8:] 443 hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.IovLen)) 444 dst = dst[8:] 445 hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.Control)) 446 dst = dst[8:] 447 hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.ControlLen)) 448 dst = dst[8:] 449 hostarch.ByteOrder.PutUint32(dst[:4], uint32(m.Flags)) 450 dst = dst[4:] 451 // Padding: dst[:sizeof(int32)] ~= int32(0) 452 dst = dst[4:] 453 return dst 454 } 455 456 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 457 func (m *MessageHeader64) UnmarshalBytes(src []byte) []byte { 458 m.Name = uint64(hostarch.ByteOrder.Uint64(src[:8])) 459 src = src[8:] 460 m.NameLen = uint32(hostarch.ByteOrder.Uint32(src[:4])) 461 src = src[4:] 462 // Padding: var _ uint32 ~= src[:sizeof(uint32)] 463 src = src[4:] 464 m.Iov = uint64(hostarch.ByteOrder.Uint64(src[:8])) 465 src = src[8:] 466 m.IovLen = uint64(hostarch.ByteOrder.Uint64(src[:8])) 467 src = src[8:] 468 m.Control = uint64(hostarch.ByteOrder.Uint64(src[:8])) 469 src = src[8:] 470 m.ControlLen = uint64(hostarch.ByteOrder.Uint64(src[:8])) 471 src = src[8:] 472 m.Flags = int32(hostarch.ByteOrder.Uint32(src[:4])) 473 src = src[4:] 474 // Padding: var _ int32 ~= src[:sizeof(int32)] 475 src = src[4:] 476 return src 477 } 478 479 // Packed implements marshal.Marshallable.Packed. 480 //go:nosplit 481 func (m *MessageHeader64) Packed() bool { 482 return true 483 } 484 485 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 486 func (m *MessageHeader64) MarshalUnsafe(dst []byte) []byte { 487 size := m.SizeBytes() 488 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(size)) 489 return dst[size:] 490 } 491 492 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 493 func (m *MessageHeader64) UnmarshalUnsafe(src []byte) []byte { 494 size := m.SizeBytes() 495 gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(size)) 496 return src[size:] 497 } 498 499 // CopyOutN implements marshal.Marshallable.CopyOutN. 500 func (m *MessageHeader64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 501 // Construct a slice backed by dst's underlying memory. 502 var buf []byte 503 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 504 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 505 hdr.Len = m.SizeBytes() 506 hdr.Cap = m.SizeBytes() 507 508 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 509 // Since we bypassed the compiler's escape analysis, indicate that m 510 // must live until the use above. 511 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 512 return length, err 513 } 514 515 // CopyOut implements marshal.Marshallable.CopyOut. 516 func (m *MessageHeader64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 517 return m.CopyOutN(cc, addr, m.SizeBytes()) 518 } 519 520 // CopyInN implements marshal.Marshallable.CopyInN. 521 func (m *MessageHeader64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 522 // Construct a slice backed by dst's underlying memory. 523 var buf []byte 524 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 525 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 526 hdr.Len = m.SizeBytes() 527 hdr.Cap = m.SizeBytes() 528 529 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 530 // Since we bypassed the compiler's escape analysis, indicate that m 531 // must live until the use above. 532 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 533 return length, err 534 } 535 536 // CopyIn implements marshal.Marshallable.CopyIn. 537 func (m *MessageHeader64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 538 return m.CopyInN(cc, addr, m.SizeBytes()) 539 } 540 541 // WriteTo implements io.WriterTo.WriteTo. 542 func (m *MessageHeader64) WriteTo(writer io.Writer) (int64, error) { 543 // Construct a slice backed by dst's underlying memory. 544 var buf []byte 545 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 546 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 547 hdr.Len = m.SizeBytes() 548 hdr.Cap = m.SizeBytes() 549 550 length, err := writer.Write(buf) 551 // Since we bypassed the compiler's escape analysis, indicate that m 552 // must live until the use above. 553 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 554 return int64(length), err 555 } 556 557 // SizeBytes implements marshal.Marshallable.SizeBytes. 558 func (m *multipleMessageHeader64) SizeBytes() int { 559 return 8 + 560 (*MessageHeader64)(nil).SizeBytes() 561 } 562 563 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 564 func (m *multipleMessageHeader64) MarshalBytes(dst []byte) []byte { 565 dst = m.msgHdr.MarshalUnsafe(dst) 566 hostarch.ByteOrder.PutUint32(dst[:4], uint32(m.msgLen)) 567 dst = dst[4:] 568 // Padding: dst[:sizeof(int32)] ~= int32(0) 569 dst = dst[4:] 570 return dst 571 } 572 573 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 574 func (m *multipleMessageHeader64) UnmarshalBytes(src []byte) []byte { 575 src = m.msgHdr.UnmarshalUnsafe(src) 576 m.msgLen = uint32(hostarch.ByteOrder.Uint32(src[:4])) 577 src = src[4:] 578 // Padding: var _ int32 ~= src[:sizeof(int32)] 579 src = src[4:] 580 return src 581 } 582 583 // Packed implements marshal.Marshallable.Packed. 584 //go:nosplit 585 func (m *multipleMessageHeader64) Packed() bool { 586 return m.msgHdr.Packed() 587 } 588 589 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 590 func (m *multipleMessageHeader64) MarshalUnsafe(dst []byte) []byte { 591 if m.msgHdr.Packed() { 592 size := m.SizeBytes() 593 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(size)) 594 return dst[size:] 595 } 596 // Type multipleMessageHeader64 doesn't have a packed layout in memory, fallback to MarshalBytes. 597 return m.MarshalBytes(dst) 598 } 599 600 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 601 func (m *multipleMessageHeader64) UnmarshalUnsafe(src []byte) []byte { 602 if m.msgHdr.Packed() { 603 size := m.SizeBytes() 604 gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(size)) 605 return src[size:] 606 } 607 // Type multipleMessageHeader64 doesn't have a packed layout in memory, fallback to UnmarshalBytes. 608 return m.UnmarshalBytes(src) 609 } 610 611 // CopyOutN implements marshal.Marshallable.CopyOutN. 612 func (m *multipleMessageHeader64) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 613 if !m.msgHdr.Packed() { 614 // Type multipleMessageHeader64 doesn't have a packed layout in memory, fall back to MarshalBytes. 615 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 616 m.MarshalBytes(buf) // escapes: fallback. 617 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 618 } 619 620 // Construct a slice backed by dst's underlying memory. 621 var buf []byte 622 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 623 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 624 hdr.Len = m.SizeBytes() 625 hdr.Cap = m.SizeBytes() 626 627 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 628 // Since we bypassed the compiler's escape analysis, indicate that m 629 // must live until the use above. 630 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 631 return length, err 632 } 633 634 // CopyOut implements marshal.Marshallable.CopyOut. 635 func (m *multipleMessageHeader64) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 636 return m.CopyOutN(cc, addr, m.SizeBytes()) 637 } 638 639 // CopyInN implements marshal.Marshallable.CopyInN. 640 func (m *multipleMessageHeader64) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 641 if !m.msgHdr.Packed() { 642 // Type multipleMessageHeader64 doesn't have a packed layout in memory, fall back to UnmarshalBytes. 643 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 644 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 645 // Unmarshal unconditionally. If we had a short copy-in, this results in a 646 // partially unmarshalled struct. 647 m.UnmarshalBytes(buf) // escapes: fallback. 648 return length, err 649 } 650 651 // Construct a slice backed by dst's underlying memory. 652 var buf []byte 653 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 654 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 655 hdr.Len = m.SizeBytes() 656 hdr.Cap = m.SizeBytes() 657 658 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 659 // Since we bypassed the compiler's escape analysis, indicate that m 660 // must live until the use above. 661 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 662 return length, err 663 } 664 665 // CopyIn implements marshal.Marshallable.CopyIn. 666 func (m *multipleMessageHeader64) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 667 return m.CopyInN(cc, addr, m.SizeBytes()) 668 } 669 670 // WriteTo implements io.WriterTo.WriteTo. 671 func (m *multipleMessageHeader64) WriteTo(writer io.Writer) (int64, error) { 672 if !m.msgHdr.Packed() { 673 // Type multipleMessageHeader64 doesn't have a packed layout in memory, fall back to MarshalBytes. 674 buf := make([]byte, m.SizeBytes()) 675 m.MarshalBytes(buf) 676 length, err := writer.Write(buf) 677 return int64(length), err 678 } 679 680 // Construct a slice backed by dst's underlying memory. 681 var buf []byte 682 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 683 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 684 hdr.Len = m.SizeBytes() 685 hdr.Cap = m.SizeBytes() 686 687 length, err := writer.Write(buf) 688 // Since we bypassed the compiler's escape analysis, indicate that m 689 // must live until the use above. 690 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 691 return int64(length), err 692 } 693