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