github.com/sagernet/gvisor@v0.0.0-20240428053021-e691de28565f/pkg/lisafs/lisafs_abi_autogen_unsafe.go (about) 1 // Automatically generated marshal implementation. See tools/go_marshal. 2 3 package lisafs 4 5 import ( 6 "github.com/sagernet/gvisor/pkg/abi/linux" 7 "github.com/sagernet/gvisor/pkg/gohacks" 8 "github.com/sagernet/gvisor/pkg/hostarch" 9 "github.com/sagernet/gvisor/pkg/marshal" 10 "io" 11 "reflect" 12 "runtime" 13 "unsafe" 14 ) 15 16 // Marshallable types used by this file. 17 var _ marshal.Marshallable = (*AcceptReq)(nil) 18 var _ marshal.Marshallable = (*BindAtResp)(nil) 19 var _ marshal.Marshallable = (*ChannelResp)(nil) 20 var _ marshal.Marshallable = (*ConnectReq)(nil) 21 var _ marshal.Marshallable = (*ErrorResp)(nil) 22 var _ marshal.Marshallable = (*FAllocateReq)(nil) 23 var _ marshal.Marshallable = (*FDID)(nil) 24 var _ marshal.Marshallable = (*FListXattrReq)(nil) 25 var _ marshal.Marshallable = (*FStatFSReq)(nil) 26 var _ marshal.Marshallable = (*FlushReq)(nil) 27 var _ marshal.Marshallable = (*GID)(nil) 28 var _ marshal.Marshallable = (*Getdents64Req)(nil) 29 var _ marshal.Marshallable = (*Inode)(nil) 30 var _ marshal.Marshallable = (*LinkAtResp)(nil) 31 var _ marshal.Marshallable = (*ListenReq)(nil) 32 var _ marshal.Marshallable = (*MID)(nil) 33 var _ marshal.Marshallable = (*MkdirAtResp)(nil) 34 var _ marshal.Marshallable = (*MknodAtResp)(nil) 35 var _ marshal.Marshallable = (*MsgDynamic)(nil) 36 var _ marshal.Marshallable = (*MsgSimple)(nil) 37 var _ marshal.Marshallable = (*OpenAtReq)(nil) 38 var _ marshal.Marshallable = (*OpenAtResp)(nil) 39 var _ marshal.Marshallable = (*OpenCreateAtResp)(nil) 40 var _ marshal.Marshallable = (*PReadReq)(nil) 41 var _ marshal.Marshallable = (*PWriteResp)(nil) 42 var _ marshal.Marshallable = (*ReadLinkAtReq)(nil) 43 var _ marshal.Marshallable = (*SetStatReq)(nil) 44 var _ marshal.Marshallable = (*SetStatResp)(nil) 45 var _ marshal.Marshallable = (*StatFS)(nil) 46 var _ marshal.Marshallable = (*StatReq)(nil) 47 var _ marshal.Marshallable = (*SymlinkAtResp)(nil) 48 var _ marshal.Marshallable = (*UID)(nil) 49 var _ marshal.Marshallable = (*channelHeader)(nil) 50 var _ marshal.Marshallable = (*createCommon)(nil) 51 var _ marshal.Marshallable = (*linux.FileMode)(nil) 52 var _ marshal.Marshallable = (*linux.Statx)(nil) 53 var _ marshal.Marshallable = (*linux.Timespec)(nil) 54 var _ marshal.Marshallable = (*sockHeader)(nil) 55 56 // SizeBytes implements marshal.Marshallable.SizeBytes. 57 func (c *channelHeader) SizeBytes() int { 58 return 2 + 59 (*MID)(nil).SizeBytes() 60 } 61 62 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 63 func (c *channelHeader) MarshalBytes(dst []byte) []byte { 64 dst = c.message.MarshalUnsafe(dst) 65 dst[0] = byte(c.numFDs) 66 dst = dst[1:] 67 // Padding: dst[:sizeof(uint8)] ~= uint8(0) 68 dst = dst[1:] 69 return dst 70 } 71 72 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 73 func (c *channelHeader) UnmarshalBytes(src []byte) []byte { 74 src = c.message.UnmarshalUnsafe(src) 75 c.numFDs = uint8(src[0]) 76 src = src[1:] 77 // Padding: var _ uint8 ~= src[:sizeof(uint8)] 78 src = src[1:] 79 return src 80 } 81 82 // Packed implements marshal.Marshallable.Packed. 83 //go:nosplit 84 func (c *channelHeader) Packed() bool { 85 return c.message.Packed() 86 } 87 88 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 89 func (c *channelHeader) MarshalUnsafe(dst []byte) []byte { 90 if c.message.Packed() { 91 size := c.SizeBytes() 92 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(c), uintptr(size)) 93 return dst[size:] 94 } 95 // Type channelHeader doesn't have a packed layout in memory, fallback to MarshalBytes. 96 return c.MarshalBytes(dst) 97 } 98 99 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 100 func (c *channelHeader) UnmarshalUnsafe(src []byte) []byte { 101 if c.message.Packed() { 102 size := c.SizeBytes() 103 gohacks.Memmove(unsafe.Pointer(c), unsafe.Pointer(&src[0]), uintptr(size)) 104 return src[size:] 105 } 106 // Type channelHeader doesn't have a packed layout in memory, fallback to UnmarshalBytes. 107 return c.UnmarshalBytes(src) 108 } 109 110 // CopyOutN implements marshal.Marshallable.CopyOutN. 111 func (c *channelHeader) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 112 if !c.message.Packed() { 113 // Type channelHeader doesn't have a packed layout in memory, fall back to MarshalBytes. 114 buf := cc.CopyScratchBuffer(c.SizeBytes()) // escapes: okay. 115 c.MarshalBytes(buf) // escapes: fallback. 116 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 117 } 118 119 // Construct a slice backed by dst's underlying memory. 120 var buf []byte 121 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 122 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 123 hdr.Len = c.SizeBytes() 124 hdr.Cap = c.SizeBytes() 125 126 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 127 // Since we bypassed the compiler's escape analysis, indicate that c 128 // must live until the use above. 129 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 130 return length, err 131 } 132 133 // CopyOut implements marshal.Marshallable.CopyOut. 134 func (c *channelHeader) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 135 return c.CopyOutN(cc, addr, c.SizeBytes()) 136 } 137 138 // CopyInN implements marshal.Marshallable.CopyInN. 139 func (c *channelHeader) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 140 if !c.message.Packed() { 141 // Type channelHeader doesn't have a packed layout in memory, fall back to UnmarshalBytes. 142 buf := cc.CopyScratchBuffer(c.SizeBytes()) // escapes: okay. 143 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 144 // Unmarshal unconditionally. If we had a short copy-in, this results in a 145 // partially unmarshalled struct. 146 c.UnmarshalBytes(buf) // escapes: fallback. 147 return length, err 148 } 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(gohacks.Noescape(unsafe.Pointer(c))) 154 hdr.Len = c.SizeBytes() 155 hdr.Cap = c.SizeBytes() 156 157 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 158 // Since we bypassed the compiler's escape analysis, indicate that c 159 // must live until the use above. 160 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 161 return length, err 162 } 163 164 // CopyIn implements marshal.Marshallable.CopyIn. 165 func (c *channelHeader) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 166 return c.CopyInN(cc, addr, c.SizeBytes()) 167 } 168 169 // WriteTo implements io.WriterTo.WriteTo. 170 func (c *channelHeader) WriteTo(writer io.Writer) (int64, error) { 171 if !c.message.Packed() { 172 // Type channelHeader doesn't have a packed layout in memory, fall back to MarshalBytes. 173 buf := make([]byte, c.SizeBytes()) 174 c.MarshalBytes(buf) 175 length, err := writer.Write(buf) 176 return int64(length), err 177 } 178 179 // Construct a slice backed by dst's underlying memory. 180 var buf []byte 181 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 182 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 183 hdr.Len = c.SizeBytes() 184 hdr.Cap = c.SizeBytes() 185 186 length, err := writer.Write(buf) 187 // Since we bypassed the compiler's escape analysis, indicate that c 188 // must live until the use above. 189 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 190 return int64(length), err 191 } 192 193 // SizeBytes implements marshal.Marshallable.SizeBytes. 194 //go:nosplit 195 func (f *FDID) SizeBytes() int { 196 return 8 197 } 198 199 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 200 func (f *FDID) MarshalBytes(dst []byte) []byte { 201 hostarch.ByteOrder.PutUint64(dst[:8], uint64(*f)) 202 return dst[8:] 203 } 204 205 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 206 func (f *FDID) UnmarshalBytes(src []byte) []byte { 207 *f = FDID(uint64(hostarch.ByteOrder.Uint64(src[:8]))) 208 return src[8:] 209 } 210 211 // Packed implements marshal.Marshallable.Packed. 212 //go:nosplit 213 func (f *FDID) Packed() bool { 214 // Scalar newtypes are always packed. 215 return true 216 } 217 218 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 219 func (f *FDID) MarshalUnsafe(dst []byte) []byte { 220 size := f.SizeBytes() 221 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(f), uintptr(size)) 222 return dst[size:] 223 } 224 225 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 226 func (f *FDID) UnmarshalUnsafe(src []byte) []byte { 227 size := f.SizeBytes() 228 gohacks.Memmove(unsafe.Pointer(f), unsafe.Pointer(&src[0]), uintptr(size)) 229 return src[size:] 230 } 231 232 // CopyOutN implements marshal.Marshallable.CopyOutN. 233 func (f *FDID) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 234 // Construct a slice backed by dst's underlying memory. 235 var buf []byte 236 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 237 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f))) 238 hdr.Len = f.SizeBytes() 239 hdr.Cap = f.SizeBytes() 240 241 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 242 // Since we bypassed the compiler's escape analysis, indicate that f 243 // must live until the use above. 244 runtime.KeepAlive(f) // escapes: replaced by intrinsic. 245 return length, err 246 } 247 248 // CopyOut implements marshal.Marshallable.CopyOut. 249 func (f *FDID) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 250 return f.CopyOutN(cc, addr, f.SizeBytes()) 251 } 252 253 // CopyInN implements marshal.Marshallable.CopyInN. 254 func (f *FDID) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 255 // Construct a slice backed by dst's underlying memory. 256 var buf []byte 257 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 258 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f))) 259 hdr.Len = f.SizeBytes() 260 hdr.Cap = f.SizeBytes() 261 262 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 263 // Since we bypassed the compiler's escape analysis, indicate that f 264 // must live until the use above. 265 runtime.KeepAlive(f) // escapes: replaced by intrinsic. 266 return length, err 267 } 268 269 // CopyIn implements marshal.Marshallable.CopyIn. 270 func (f *FDID) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 271 return f.CopyInN(cc, addr, f.SizeBytes()) 272 } 273 274 // WriteTo implements io.WriterTo.WriteTo. 275 func (f *FDID) WriteTo(writer io.Writer) (int64, error) { 276 // Construct a slice backed by dst's underlying memory. 277 var buf []byte 278 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 279 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f))) 280 hdr.Len = f.SizeBytes() 281 hdr.Cap = f.SizeBytes() 282 283 length, err := writer.Write(buf) 284 // Since we bypassed the compiler's escape analysis, indicate that f 285 // must live until the use above. 286 runtime.KeepAlive(f) // escapes: replaced by intrinsic. 287 return int64(length), err 288 } 289 290 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 291 func (f *FDID) CheckedMarshal(dst []byte) ([]byte, bool) { 292 size := f.SizeBytes() 293 if size > len(dst) { 294 return dst, false 295 } 296 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(f), uintptr(size)) 297 return dst[size:], true 298 } 299 300 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 301 func (f *FDID) CheckedUnmarshal(src []byte) ([]byte, bool) { 302 size := f.SizeBytes() 303 if size > len(src) { 304 return src, false 305 } 306 gohacks.Memmove(unsafe.Pointer(f), unsafe.Pointer(&src[0]), uintptr(size)) 307 return src[size:], true 308 } 309 310 // CopyFDIDSliceIn copies in a slice of FDID objects from the task's memory. 311 func CopyFDIDSliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []FDID) (int, error) { 312 count := len(dst) 313 if count == 0 { 314 return 0, nil 315 } 316 size := (*FDID)(nil).SizeBytes() 317 318 ptr := unsafe.Pointer(&dst) 319 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 320 321 // Construct a slice backed by dst's underlying memory. 322 var buf []byte 323 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 324 hdr.Data = uintptr(val) 325 hdr.Len = size * count 326 hdr.Cap = size * count 327 328 length, err := cc.CopyInBytes(addr, buf) // escapes: okay. 329 // Since we bypassed the compiler's escape analysis, indicate that dst 330 // must live until the use above. 331 runtime.KeepAlive(dst) // escapes: replaced by intrinsic. 332 return length, err 333 } 334 335 // CopyFDIDSliceOut copies a slice of FDID objects to the task's memory. 336 func CopyFDIDSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []FDID) (int, error) { 337 count := len(src) 338 if count == 0 { 339 return 0, nil 340 } 341 size := (*FDID)(nil).SizeBytes() 342 343 ptr := unsafe.Pointer(&src) 344 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 345 346 // Construct a slice backed by dst's underlying memory. 347 var buf []byte 348 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 349 hdr.Data = uintptr(val) 350 hdr.Len = size * count 351 hdr.Cap = size * count 352 353 length, err := cc.CopyOutBytes(addr, buf) // escapes: okay. 354 // Since we bypassed the compiler's escape analysis, indicate that src 355 // must live until the use above. 356 runtime.KeepAlive(src) // escapes: replaced by intrinsic. 357 return length, err 358 } 359 360 // MarshalUnsafeFDIDSlice is like FDID.MarshalUnsafe, but for a []FDID. 361 func MarshalUnsafeFDIDSlice(src []FDID, dst []byte) []byte { 362 count := len(src) 363 if count == 0 { 364 return dst 365 } 366 size := (*FDID)(nil).SizeBytes() 367 368 buf := dst[:size*count] 369 gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf))) 370 return dst[size*count:] 371 } 372 373 // UnmarshalUnsafeFDIDSlice is like FDID.UnmarshalUnsafe, but for a []FDID. 374 func UnmarshalUnsafeFDIDSlice(dst []FDID, src []byte) []byte { 375 count := len(dst) 376 if count == 0 { 377 return src 378 } 379 size := (*FDID)(nil).SizeBytes() 380 381 buf := src[:size*count] 382 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf))) 383 return src[size*count:] 384 } 385 386 // SizeBytes implements marshal.Marshallable.SizeBytes. 387 func (a *AcceptReq) SizeBytes() int { 388 return 0 + 389 (*FDID)(nil).SizeBytes() 390 } 391 392 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 393 func (a *AcceptReq) MarshalBytes(dst []byte) []byte { 394 dst = a.FD.MarshalUnsafe(dst) 395 return dst 396 } 397 398 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 399 func (a *AcceptReq) UnmarshalBytes(src []byte) []byte { 400 src = a.FD.UnmarshalUnsafe(src) 401 return src 402 } 403 404 // Packed implements marshal.Marshallable.Packed. 405 //go:nosplit 406 func (a *AcceptReq) Packed() bool { 407 return a.FD.Packed() 408 } 409 410 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 411 func (a *AcceptReq) MarshalUnsafe(dst []byte) []byte { 412 if a.FD.Packed() { 413 size := a.SizeBytes() 414 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(a), uintptr(size)) 415 return dst[size:] 416 } 417 // Type AcceptReq doesn't have a packed layout in memory, fallback to MarshalBytes. 418 return a.MarshalBytes(dst) 419 } 420 421 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 422 func (a *AcceptReq) UnmarshalUnsafe(src []byte) []byte { 423 if a.FD.Packed() { 424 size := a.SizeBytes() 425 gohacks.Memmove(unsafe.Pointer(a), unsafe.Pointer(&src[0]), uintptr(size)) 426 return src[size:] 427 } 428 // Type AcceptReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 429 return a.UnmarshalBytes(src) 430 } 431 432 // CopyOutN implements marshal.Marshallable.CopyOutN. 433 func (a *AcceptReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 434 if !a.FD.Packed() { 435 // Type AcceptReq doesn't have a packed layout in memory, fall back to MarshalBytes. 436 buf := cc.CopyScratchBuffer(a.SizeBytes()) // escapes: okay. 437 a.MarshalBytes(buf) // escapes: fallback. 438 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 439 } 440 441 // Construct a slice backed by dst's underlying memory. 442 var buf []byte 443 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 444 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a))) 445 hdr.Len = a.SizeBytes() 446 hdr.Cap = a.SizeBytes() 447 448 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 449 // Since we bypassed the compiler's escape analysis, indicate that a 450 // must live until the use above. 451 runtime.KeepAlive(a) // escapes: replaced by intrinsic. 452 return length, err 453 } 454 455 // CopyOut implements marshal.Marshallable.CopyOut. 456 func (a *AcceptReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 457 return a.CopyOutN(cc, addr, a.SizeBytes()) 458 } 459 460 // CopyInN implements marshal.Marshallable.CopyInN. 461 func (a *AcceptReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 462 if !a.FD.Packed() { 463 // Type AcceptReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 464 buf := cc.CopyScratchBuffer(a.SizeBytes()) // escapes: okay. 465 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 466 // Unmarshal unconditionally. If we had a short copy-in, this results in a 467 // partially unmarshalled struct. 468 a.UnmarshalBytes(buf) // escapes: fallback. 469 return length, err 470 } 471 472 // Construct a slice backed by dst's underlying memory. 473 var buf []byte 474 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 475 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a))) 476 hdr.Len = a.SizeBytes() 477 hdr.Cap = a.SizeBytes() 478 479 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 480 // Since we bypassed the compiler's escape analysis, indicate that a 481 // must live until the use above. 482 runtime.KeepAlive(a) // escapes: replaced by intrinsic. 483 return length, err 484 } 485 486 // CopyIn implements marshal.Marshallable.CopyIn. 487 func (a *AcceptReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 488 return a.CopyInN(cc, addr, a.SizeBytes()) 489 } 490 491 // WriteTo implements io.WriterTo.WriteTo. 492 func (a *AcceptReq) WriteTo(writer io.Writer) (int64, error) { 493 if !a.FD.Packed() { 494 // Type AcceptReq doesn't have a packed layout in memory, fall back to MarshalBytes. 495 buf := make([]byte, a.SizeBytes()) 496 a.MarshalBytes(buf) 497 length, err := writer.Write(buf) 498 return int64(length), err 499 } 500 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(a))) 505 hdr.Len = a.SizeBytes() 506 hdr.Cap = a.SizeBytes() 507 508 length, err := writer.Write(buf) 509 // Since we bypassed the compiler's escape analysis, indicate that a 510 // must live until the use above. 511 runtime.KeepAlive(a) // escapes: replaced by intrinsic. 512 return int64(length), err 513 } 514 515 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 516 func (a *AcceptReq) CheckedMarshal(dst []byte) ([]byte, bool) { 517 if a.SizeBytes() > len(dst) { 518 return dst, false 519 } 520 return a.MarshalUnsafe(dst), true 521 } 522 523 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 524 func (a *AcceptReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 525 if a.SizeBytes() > len(src) { 526 return src, false 527 } 528 return a.UnmarshalUnsafe(src), true 529 } 530 531 // SizeBytes implements marshal.Marshallable.SizeBytes. 532 func (b *BindAtResp) SizeBytes() int { 533 return 0 + 534 (*Inode)(nil).SizeBytes() + 535 (*FDID)(nil).SizeBytes() 536 } 537 538 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 539 func (b *BindAtResp) MarshalBytes(dst []byte) []byte { 540 dst = b.Child.MarshalUnsafe(dst) 541 dst = b.BoundSocketFD.MarshalUnsafe(dst) 542 return dst 543 } 544 545 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 546 func (b *BindAtResp) UnmarshalBytes(src []byte) []byte { 547 src = b.Child.UnmarshalUnsafe(src) 548 src = b.BoundSocketFD.UnmarshalUnsafe(src) 549 return src 550 } 551 552 // Packed implements marshal.Marshallable.Packed. 553 //go:nosplit 554 func (b *BindAtResp) Packed() bool { 555 return b.BoundSocketFD.Packed() && b.Child.Packed() 556 } 557 558 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 559 func (b *BindAtResp) MarshalUnsafe(dst []byte) []byte { 560 if b.BoundSocketFD.Packed() && b.Child.Packed() { 561 size := b.SizeBytes() 562 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(b), uintptr(size)) 563 return dst[size:] 564 } 565 // Type BindAtResp doesn't have a packed layout in memory, fallback to MarshalBytes. 566 return b.MarshalBytes(dst) 567 } 568 569 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 570 func (b *BindAtResp) UnmarshalUnsafe(src []byte) []byte { 571 if b.BoundSocketFD.Packed() && b.Child.Packed() { 572 size := b.SizeBytes() 573 gohacks.Memmove(unsafe.Pointer(b), unsafe.Pointer(&src[0]), uintptr(size)) 574 return src[size:] 575 } 576 // Type BindAtResp doesn't have a packed layout in memory, fallback to UnmarshalBytes. 577 return b.UnmarshalBytes(src) 578 } 579 580 // CopyOutN implements marshal.Marshallable.CopyOutN. 581 func (b *BindAtResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 582 if !b.BoundSocketFD.Packed() && b.Child.Packed() { 583 // Type BindAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 584 buf := cc.CopyScratchBuffer(b.SizeBytes()) // escapes: okay. 585 b.MarshalBytes(buf) // escapes: fallback. 586 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 587 } 588 589 // Construct a slice backed by dst's underlying memory. 590 var buf []byte 591 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 592 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(b))) 593 hdr.Len = b.SizeBytes() 594 hdr.Cap = b.SizeBytes() 595 596 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 597 // Since we bypassed the compiler's escape analysis, indicate that b 598 // must live until the use above. 599 runtime.KeepAlive(b) // escapes: replaced by intrinsic. 600 return length, err 601 } 602 603 // CopyOut implements marshal.Marshallable.CopyOut. 604 func (b *BindAtResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 605 return b.CopyOutN(cc, addr, b.SizeBytes()) 606 } 607 608 // CopyInN implements marshal.Marshallable.CopyInN. 609 func (b *BindAtResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 610 if !b.BoundSocketFD.Packed() && b.Child.Packed() { 611 // Type BindAtResp doesn't have a packed layout in memory, fall back to UnmarshalBytes. 612 buf := cc.CopyScratchBuffer(b.SizeBytes()) // escapes: okay. 613 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 614 // Unmarshal unconditionally. If we had a short copy-in, this results in a 615 // partially unmarshalled struct. 616 b.UnmarshalBytes(buf) // escapes: fallback. 617 return length, err 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(b))) 624 hdr.Len = b.SizeBytes() 625 hdr.Cap = b.SizeBytes() 626 627 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 628 // Since we bypassed the compiler's escape analysis, indicate that b 629 // must live until the use above. 630 runtime.KeepAlive(b) // escapes: replaced by intrinsic. 631 return length, err 632 } 633 634 // CopyIn implements marshal.Marshallable.CopyIn. 635 func (b *BindAtResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 636 return b.CopyInN(cc, addr, b.SizeBytes()) 637 } 638 639 // WriteTo implements io.WriterTo.WriteTo. 640 func (b *BindAtResp) WriteTo(writer io.Writer) (int64, error) { 641 if !b.BoundSocketFD.Packed() && b.Child.Packed() { 642 // Type BindAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 643 buf := make([]byte, b.SizeBytes()) 644 b.MarshalBytes(buf) 645 length, err := writer.Write(buf) 646 return int64(length), err 647 } 648 649 // Construct a slice backed by dst's underlying memory. 650 var buf []byte 651 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 652 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(b))) 653 hdr.Len = b.SizeBytes() 654 hdr.Cap = b.SizeBytes() 655 656 length, err := writer.Write(buf) 657 // Since we bypassed the compiler's escape analysis, indicate that b 658 // must live until the use above. 659 runtime.KeepAlive(b) // escapes: replaced by intrinsic. 660 return int64(length), err 661 } 662 663 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 664 func (b *BindAtResp) CheckedMarshal(dst []byte) ([]byte, bool) { 665 if b.SizeBytes() > len(dst) { 666 return dst, false 667 } 668 return b.MarshalUnsafe(dst), true 669 } 670 671 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 672 func (b *BindAtResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 673 if b.SizeBytes() > len(src) { 674 return src, false 675 } 676 return b.UnmarshalUnsafe(src), true 677 } 678 679 // SizeBytes implements marshal.Marshallable.SizeBytes. 680 func (c *ChannelResp) SizeBytes() int { 681 return 16 682 } 683 684 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 685 func (c *ChannelResp) MarshalBytes(dst []byte) []byte { 686 hostarch.ByteOrder.PutUint64(dst[:8], uint64(c.dataOffset)) 687 dst = dst[8:] 688 hostarch.ByteOrder.PutUint64(dst[:8], uint64(c.dataLength)) 689 dst = dst[8:] 690 return dst 691 } 692 693 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 694 func (c *ChannelResp) UnmarshalBytes(src []byte) []byte { 695 c.dataOffset = int64(hostarch.ByteOrder.Uint64(src[:8])) 696 src = src[8:] 697 c.dataLength = uint64(hostarch.ByteOrder.Uint64(src[:8])) 698 src = src[8:] 699 return src 700 } 701 702 // Packed implements marshal.Marshallable.Packed. 703 //go:nosplit 704 func (c *ChannelResp) Packed() bool { 705 return true 706 } 707 708 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 709 func (c *ChannelResp) MarshalUnsafe(dst []byte) []byte { 710 size := c.SizeBytes() 711 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(c), uintptr(size)) 712 return dst[size:] 713 } 714 715 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 716 func (c *ChannelResp) UnmarshalUnsafe(src []byte) []byte { 717 size := c.SizeBytes() 718 gohacks.Memmove(unsafe.Pointer(c), unsafe.Pointer(&src[0]), uintptr(size)) 719 return src[size:] 720 } 721 722 // CopyOutN implements marshal.Marshallable.CopyOutN. 723 func (c *ChannelResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 724 // Construct a slice backed by dst's underlying memory. 725 var buf []byte 726 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 727 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 728 hdr.Len = c.SizeBytes() 729 hdr.Cap = c.SizeBytes() 730 731 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 732 // Since we bypassed the compiler's escape analysis, indicate that c 733 // must live until the use above. 734 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 735 return length, err 736 } 737 738 // CopyOut implements marshal.Marshallable.CopyOut. 739 func (c *ChannelResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 740 return c.CopyOutN(cc, addr, c.SizeBytes()) 741 } 742 743 // CopyInN implements marshal.Marshallable.CopyInN. 744 func (c *ChannelResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 745 // Construct a slice backed by dst's underlying memory. 746 var buf []byte 747 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 748 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 749 hdr.Len = c.SizeBytes() 750 hdr.Cap = c.SizeBytes() 751 752 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 753 // Since we bypassed the compiler's escape analysis, indicate that c 754 // must live until the use above. 755 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 756 return length, err 757 } 758 759 // CopyIn implements marshal.Marshallable.CopyIn. 760 func (c *ChannelResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 761 return c.CopyInN(cc, addr, c.SizeBytes()) 762 } 763 764 // WriteTo implements io.WriterTo.WriteTo. 765 func (c *ChannelResp) WriteTo(writer io.Writer) (int64, error) { 766 // Construct a slice backed by dst's underlying memory. 767 var buf []byte 768 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 769 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 770 hdr.Len = c.SizeBytes() 771 hdr.Cap = c.SizeBytes() 772 773 length, err := writer.Write(buf) 774 // Since we bypassed the compiler's escape analysis, indicate that c 775 // must live until the use above. 776 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 777 return int64(length), err 778 } 779 780 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 781 func (c *ChannelResp) CheckedMarshal(dst []byte) ([]byte, bool) { 782 if c.SizeBytes() > len(dst) { 783 return dst, false 784 } 785 return c.MarshalUnsafe(dst), true 786 } 787 788 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 789 func (c *ChannelResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 790 if c.SizeBytes() > len(src) { 791 return src, false 792 } 793 return c.UnmarshalUnsafe(src), true 794 } 795 796 // SizeBytes implements marshal.Marshallable.SizeBytes. 797 func (c *ConnectReq) SizeBytes() int { 798 return 8 + 799 (*FDID)(nil).SizeBytes() 800 } 801 802 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 803 func (c *ConnectReq) MarshalBytes(dst []byte) []byte { 804 dst = c.FD.MarshalUnsafe(dst) 805 hostarch.ByteOrder.PutUint32(dst[:4], uint32(c.SockType)) 806 dst = dst[4:] 807 // Padding: dst[:sizeof(uint32)] ~= uint32(0) 808 dst = dst[4:] 809 return dst 810 } 811 812 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 813 func (c *ConnectReq) UnmarshalBytes(src []byte) []byte { 814 src = c.FD.UnmarshalUnsafe(src) 815 c.SockType = uint32(hostarch.ByteOrder.Uint32(src[:4])) 816 src = src[4:] 817 // Padding: var _ uint32 ~= src[:sizeof(uint32)] 818 src = src[4:] 819 return src 820 } 821 822 // Packed implements marshal.Marshallable.Packed. 823 //go:nosplit 824 func (c *ConnectReq) Packed() bool { 825 return c.FD.Packed() 826 } 827 828 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 829 func (c *ConnectReq) MarshalUnsafe(dst []byte) []byte { 830 if c.FD.Packed() { 831 size := c.SizeBytes() 832 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(c), uintptr(size)) 833 return dst[size:] 834 } 835 // Type ConnectReq doesn't have a packed layout in memory, fallback to MarshalBytes. 836 return c.MarshalBytes(dst) 837 } 838 839 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 840 func (c *ConnectReq) UnmarshalUnsafe(src []byte) []byte { 841 if c.FD.Packed() { 842 size := c.SizeBytes() 843 gohacks.Memmove(unsafe.Pointer(c), unsafe.Pointer(&src[0]), uintptr(size)) 844 return src[size:] 845 } 846 // Type ConnectReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 847 return c.UnmarshalBytes(src) 848 } 849 850 // CopyOutN implements marshal.Marshallable.CopyOutN. 851 func (c *ConnectReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 852 if !c.FD.Packed() { 853 // Type ConnectReq doesn't have a packed layout in memory, fall back to MarshalBytes. 854 buf := cc.CopyScratchBuffer(c.SizeBytes()) // escapes: okay. 855 c.MarshalBytes(buf) // escapes: fallback. 856 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 857 } 858 859 // Construct a slice backed by dst's underlying memory. 860 var buf []byte 861 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 862 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 863 hdr.Len = c.SizeBytes() 864 hdr.Cap = c.SizeBytes() 865 866 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 867 // Since we bypassed the compiler's escape analysis, indicate that c 868 // must live until the use above. 869 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 870 return length, err 871 } 872 873 // CopyOut implements marshal.Marshallable.CopyOut. 874 func (c *ConnectReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 875 return c.CopyOutN(cc, addr, c.SizeBytes()) 876 } 877 878 // CopyInN implements marshal.Marshallable.CopyInN. 879 func (c *ConnectReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 880 if !c.FD.Packed() { 881 // Type ConnectReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 882 buf := cc.CopyScratchBuffer(c.SizeBytes()) // escapes: okay. 883 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 884 // Unmarshal unconditionally. If we had a short copy-in, this results in a 885 // partially unmarshalled struct. 886 c.UnmarshalBytes(buf) // escapes: fallback. 887 return length, err 888 } 889 890 // Construct a slice backed by dst's underlying memory. 891 var buf []byte 892 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 893 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 894 hdr.Len = c.SizeBytes() 895 hdr.Cap = c.SizeBytes() 896 897 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 898 // Since we bypassed the compiler's escape analysis, indicate that c 899 // must live until the use above. 900 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 901 return length, err 902 } 903 904 // CopyIn implements marshal.Marshallable.CopyIn. 905 func (c *ConnectReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 906 return c.CopyInN(cc, addr, c.SizeBytes()) 907 } 908 909 // WriteTo implements io.WriterTo.WriteTo. 910 func (c *ConnectReq) WriteTo(writer io.Writer) (int64, error) { 911 if !c.FD.Packed() { 912 // Type ConnectReq doesn't have a packed layout in memory, fall back to MarshalBytes. 913 buf := make([]byte, c.SizeBytes()) 914 c.MarshalBytes(buf) 915 length, err := writer.Write(buf) 916 return int64(length), err 917 } 918 919 // Construct a slice backed by dst's underlying memory. 920 var buf []byte 921 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 922 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 923 hdr.Len = c.SizeBytes() 924 hdr.Cap = c.SizeBytes() 925 926 length, err := writer.Write(buf) 927 // Since we bypassed the compiler's escape analysis, indicate that c 928 // must live until the use above. 929 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 930 return int64(length), err 931 } 932 933 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 934 func (c *ConnectReq) CheckedMarshal(dst []byte) ([]byte, bool) { 935 if c.SizeBytes() > len(dst) { 936 return dst, false 937 } 938 return c.MarshalUnsafe(dst), true 939 } 940 941 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 942 func (c *ConnectReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 943 if c.SizeBytes() > len(src) { 944 return src, false 945 } 946 return c.UnmarshalUnsafe(src), true 947 } 948 949 // SizeBytes implements marshal.Marshallable.SizeBytes. 950 func (e *ErrorResp) SizeBytes() int { 951 return 4 952 } 953 954 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 955 func (e *ErrorResp) MarshalBytes(dst []byte) []byte { 956 hostarch.ByteOrder.PutUint32(dst[:4], uint32(e.errno)) 957 dst = dst[4:] 958 return dst 959 } 960 961 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 962 func (e *ErrorResp) UnmarshalBytes(src []byte) []byte { 963 e.errno = uint32(hostarch.ByteOrder.Uint32(src[:4])) 964 src = src[4:] 965 return src 966 } 967 968 // Packed implements marshal.Marshallable.Packed. 969 //go:nosplit 970 func (e *ErrorResp) Packed() bool { 971 return true 972 } 973 974 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 975 func (e *ErrorResp) MarshalUnsafe(dst []byte) []byte { 976 size := e.SizeBytes() 977 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(e), uintptr(size)) 978 return dst[size:] 979 } 980 981 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 982 func (e *ErrorResp) UnmarshalUnsafe(src []byte) []byte { 983 size := e.SizeBytes() 984 gohacks.Memmove(unsafe.Pointer(e), unsafe.Pointer(&src[0]), uintptr(size)) 985 return src[size:] 986 } 987 988 // CopyOutN implements marshal.Marshallable.CopyOutN. 989 func (e *ErrorResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 990 // Construct a slice backed by dst's underlying memory. 991 var buf []byte 992 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 993 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(e))) 994 hdr.Len = e.SizeBytes() 995 hdr.Cap = e.SizeBytes() 996 997 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 998 // Since we bypassed the compiler's escape analysis, indicate that e 999 // must live until the use above. 1000 runtime.KeepAlive(e) // escapes: replaced by intrinsic. 1001 return length, err 1002 } 1003 1004 // CopyOut implements marshal.Marshallable.CopyOut. 1005 func (e *ErrorResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1006 return e.CopyOutN(cc, addr, e.SizeBytes()) 1007 } 1008 1009 // CopyInN implements marshal.Marshallable.CopyInN. 1010 func (e *ErrorResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1011 // Construct a slice backed by dst's underlying memory. 1012 var buf []byte 1013 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1014 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(e))) 1015 hdr.Len = e.SizeBytes() 1016 hdr.Cap = e.SizeBytes() 1017 1018 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1019 // Since we bypassed the compiler's escape analysis, indicate that e 1020 // must live until the use above. 1021 runtime.KeepAlive(e) // escapes: replaced by intrinsic. 1022 return length, err 1023 } 1024 1025 // CopyIn implements marshal.Marshallable.CopyIn. 1026 func (e *ErrorResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1027 return e.CopyInN(cc, addr, e.SizeBytes()) 1028 } 1029 1030 // WriteTo implements io.WriterTo.WriteTo. 1031 func (e *ErrorResp) WriteTo(writer io.Writer) (int64, error) { 1032 // Construct a slice backed by dst's underlying memory. 1033 var buf []byte 1034 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1035 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(e))) 1036 hdr.Len = e.SizeBytes() 1037 hdr.Cap = e.SizeBytes() 1038 1039 length, err := writer.Write(buf) 1040 // Since we bypassed the compiler's escape analysis, indicate that e 1041 // must live until the use above. 1042 runtime.KeepAlive(e) // escapes: replaced by intrinsic. 1043 return int64(length), err 1044 } 1045 1046 // SizeBytes implements marshal.Marshallable.SizeBytes. 1047 func (a *FAllocateReq) SizeBytes() int { 1048 return 24 + 1049 (*FDID)(nil).SizeBytes() 1050 } 1051 1052 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 1053 func (a *FAllocateReq) MarshalBytes(dst []byte) []byte { 1054 dst = a.FD.MarshalUnsafe(dst) 1055 hostarch.ByteOrder.PutUint64(dst[:8], uint64(a.Mode)) 1056 dst = dst[8:] 1057 hostarch.ByteOrder.PutUint64(dst[:8], uint64(a.Offset)) 1058 dst = dst[8:] 1059 hostarch.ByteOrder.PutUint64(dst[:8], uint64(a.Length)) 1060 dst = dst[8:] 1061 return dst 1062 } 1063 1064 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 1065 func (a *FAllocateReq) UnmarshalBytes(src []byte) []byte { 1066 src = a.FD.UnmarshalUnsafe(src) 1067 a.Mode = uint64(hostarch.ByteOrder.Uint64(src[:8])) 1068 src = src[8:] 1069 a.Offset = uint64(hostarch.ByteOrder.Uint64(src[:8])) 1070 src = src[8:] 1071 a.Length = uint64(hostarch.ByteOrder.Uint64(src[:8])) 1072 src = src[8:] 1073 return src 1074 } 1075 1076 // Packed implements marshal.Marshallable.Packed. 1077 //go:nosplit 1078 func (a *FAllocateReq) Packed() bool { 1079 return a.FD.Packed() 1080 } 1081 1082 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 1083 func (a *FAllocateReq) MarshalUnsafe(dst []byte) []byte { 1084 if a.FD.Packed() { 1085 size := a.SizeBytes() 1086 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(a), uintptr(size)) 1087 return dst[size:] 1088 } 1089 // Type FAllocateReq doesn't have a packed layout in memory, fallback to MarshalBytes. 1090 return a.MarshalBytes(dst) 1091 } 1092 1093 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 1094 func (a *FAllocateReq) UnmarshalUnsafe(src []byte) []byte { 1095 if a.FD.Packed() { 1096 size := a.SizeBytes() 1097 gohacks.Memmove(unsafe.Pointer(a), unsafe.Pointer(&src[0]), uintptr(size)) 1098 return src[size:] 1099 } 1100 // Type FAllocateReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 1101 return a.UnmarshalBytes(src) 1102 } 1103 1104 // CopyOutN implements marshal.Marshallable.CopyOutN. 1105 func (a *FAllocateReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1106 if !a.FD.Packed() { 1107 // Type FAllocateReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1108 buf := cc.CopyScratchBuffer(a.SizeBytes()) // escapes: okay. 1109 a.MarshalBytes(buf) // escapes: fallback. 1110 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1111 } 1112 1113 // Construct a slice backed by dst's underlying memory. 1114 var buf []byte 1115 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1116 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a))) 1117 hdr.Len = a.SizeBytes() 1118 hdr.Cap = a.SizeBytes() 1119 1120 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1121 // Since we bypassed the compiler's escape analysis, indicate that a 1122 // must live until the use above. 1123 runtime.KeepAlive(a) // escapes: replaced by intrinsic. 1124 return length, err 1125 } 1126 1127 // CopyOut implements marshal.Marshallable.CopyOut. 1128 func (a *FAllocateReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1129 return a.CopyOutN(cc, addr, a.SizeBytes()) 1130 } 1131 1132 // CopyInN implements marshal.Marshallable.CopyInN. 1133 func (a *FAllocateReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1134 if !a.FD.Packed() { 1135 // Type FAllocateReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 1136 buf := cc.CopyScratchBuffer(a.SizeBytes()) // escapes: okay. 1137 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1138 // Unmarshal unconditionally. If we had a short copy-in, this results in a 1139 // partially unmarshalled struct. 1140 a.UnmarshalBytes(buf) // escapes: fallback. 1141 return length, err 1142 } 1143 1144 // Construct a slice backed by dst's underlying memory. 1145 var buf []byte 1146 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1147 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a))) 1148 hdr.Len = a.SizeBytes() 1149 hdr.Cap = a.SizeBytes() 1150 1151 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1152 // Since we bypassed the compiler's escape analysis, indicate that a 1153 // must live until the use above. 1154 runtime.KeepAlive(a) // escapes: replaced by intrinsic. 1155 return length, err 1156 } 1157 1158 // CopyIn implements marshal.Marshallable.CopyIn. 1159 func (a *FAllocateReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1160 return a.CopyInN(cc, addr, a.SizeBytes()) 1161 } 1162 1163 // WriteTo implements io.WriterTo.WriteTo. 1164 func (a *FAllocateReq) WriteTo(writer io.Writer) (int64, error) { 1165 if !a.FD.Packed() { 1166 // Type FAllocateReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1167 buf := make([]byte, a.SizeBytes()) 1168 a.MarshalBytes(buf) 1169 length, err := writer.Write(buf) 1170 return int64(length), err 1171 } 1172 1173 // Construct a slice backed by dst's underlying memory. 1174 var buf []byte 1175 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1176 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(a))) 1177 hdr.Len = a.SizeBytes() 1178 hdr.Cap = a.SizeBytes() 1179 1180 length, err := writer.Write(buf) 1181 // Since we bypassed the compiler's escape analysis, indicate that a 1182 // must live until the use above. 1183 runtime.KeepAlive(a) // escapes: replaced by intrinsic. 1184 return int64(length), err 1185 } 1186 1187 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 1188 func (a *FAllocateReq) CheckedMarshal(dst []byte) ([]byte, bool) { 1189 if a.SizeBytes() > len(dst) { 1190 return dst, false 1191 } 1192 return a.MarshalUnsafe(dst), true 1193 } 1194 1195 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 1196 func (a *FAllocateReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 1197 if a.SizeBytes() > len(src) { 1198 return src, false 1199 } 1200 return a.UnmarshalUnsafe(src), true 1201 } 1202 1203 // SizeBytes implements marshal.Marshallable.SizeBytes. 1204 func (l *FListXattrReq) SizeBytes() int { 1205 return 8 + 1206 (*FDID)(nil).SizeBytes() 1207 } 1208 1209 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 1210 func (l *FListXattrReq) MarshalBytes(dst []byte) []byte { 1211 dst = l.FD.MarshalUnsafe(dst) 1212 hostarch.ByteOrder.PutUint64(dst[:8], uint64(l.Size)) 1213 dst = dst[8:] 1214 return dst 1215 } 1216 1217 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 1218 func (l *FListXattrReq) UnmarshalBytes(src []byte) []byte { 1219 src = l.FD.UnmarshalUnsafe(src) 1220 l.Size = uint64(hostarch.ByteOrder.Uint64(src[:8])) 1221 src = src[8:] 1222 return src 1223 } 1224 1225 // Packed implements marshal.Marshallable.Packed. 1226 //go:nosplit 1227 func (l *FListXattrReq) Packed() bool { 1228 return l.FD.Packed() 1229 } 1230 1231 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 1232 func (l *FListXattrReq) MarshalUnsafe(dst []byte) []byte { 1233 if l.FD.Packed() { 1234 size := l.SizeBytes() 1235 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(l), uintptr(size)) 1236 return dst[size:] 1237 } 1238 // Type FListXattrReq doesn't have a packed layout in memory, fallback to MarshalBytes. 1239 return l.MarshalBytes(dst) 1240 } 1241 1242 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 1243 func (l *FListXattrReq) UnmarshalUnsafe(src []byte) []byte { 1244 if l.FD.Packed() { 1245 size := l.SizeBytes() 1246 gohacks.Memmove(unsafe.Pointer(l), unsafe.Pointer(&src[0]), uintptr(size)) 1247 return src[size:] 1248 } 1249 // Type FListXattrReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 1250 return l.UnmarshalBytes(src) 1251 } 1252 1253 // CopyOutN implements marshal.Marshallable.CopyOutN. 1254 func (l *FListXattrReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1255 if !l.FD.Packed() { 1256 // Type FListXattrReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1257 buf := cc.CopyScratchBuffer(l.SizeBytes()) // escapes: okay. 1258 l.MarshalBytes(buf) // escapes: fallback. 1259 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1260 } 1261 1262 // Construct a slice backed by dst's underlying memory. 1263 var buf []byte 1264 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1265 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 1266 hdr.Len = l.SizeBytes() 1267 hdr.Cap = l.SizeBytes() 1268 1269 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1270 // Since we bypassed the compiler's escape analysis, indicate that l 1271 // must live until the use above. 1272 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 1273 return length, err 1274 } 1275 1276 // CopyOut implements marshal.Marshallable.CopyOut. 1277 func (l *FListXattrReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1278 return l.CopyOutN(cc, addr, l.SizeBytes()) 1279 } 1280 1281 // CopyInN implements marshal.Marshallable.CopyInN. 1282 func (l *FListXattrReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1283 if !l.FD.Packed() { 1284 // Type FListXattrReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 1285 buf := cc.CopyScratchBuffer(l.SizeBytes()) // escapes: okay. 1286 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1287 // Unmarshal unconditionally. If we had a short copy-in, this results in a 1288 // partially unmarshalled struct. 1289 l.UnmarshalBytes(buf) // escapes: fallback. 1290 return length, err 1291 } 1292 1293 // Construct a slice backed by dst's underlying memory. 1294 var buf []byte 1295 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1296 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 1297 hdr.Len = l.SizeBytes() 1298 hdr.Cap = l.SizeBytes() 1299 1300 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1301 // Since we bypassed the compiler's escape analysis, indicate that l 1302 // must live until the use above. 1303 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 1304 return length, err 1305 } 1306 1307 // CopyIn implements marshal.Marshallable.CopyIn. 1308 func (l *FListXattrReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1309 return l.CopyInN(cc, addr, l.SizeBytes()) 1310 } 1311 1312 // WriteTo implements io.WriterTo.WriteTo. 1313 func (l *FListXattrReq) WriteTo(writer io.Writer) (int64, error) { 1314 if !l.FD.Packed() { 1315 // Type FListXattrReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1316 buf := make([]byte, l.SizeBytes()) 1317 l.MarshalBytes(buf) 1318 length, err := writer.Write(buf) 1319 return int64(length), err 1320 } 1321 1322 // Construct a slice backed by dst's underlying memory. 1323 var buf []byte 1324 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1325 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 1326 hdr.Len = l.SizeBytes() 1327 hdr.Cap = l.SizeBytes() 1328 1329 length, err := writer.Write(buf) 1330 // Since we bypassed the compiler's escape analysis, indicate that l 1331 // must live until the use above. 1332 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 1333 return int64(length), err 1334 } 1335 1336 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 1337 func (l *FListXattrReq) CheckedMarshal(dst []byte) ([]byte, bool) { 1338 if l.SizeBytes() > len(dst) { 1339 return dst, false 1340 } 1341 return l.MarshalUnsafe(dst), true 1342 } 1343 1344 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 1345 func (l *FListXattrReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 1346 if l.SizeBytes() > len(src) { 1347 return src, false 1348 } 1349 return l.UnmarshalUnsafe(src), true 1350 } 1351 1352 // SizeBytes implements marshal.Marshallable.SizeBytes. 1353 func (s *FStatFSReq) SizeBytes() int { 1354 return 0 + 1355 (*FDID)(nil).SizeBytes() 1356 } 1357 1358 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 1359 func (s *FStatFSReq) MarshalBytes(dst []byte) []byte { 1360 dst = s.FD.MarshalUnsafe(dst) 1361 return dst 1362 } 1363 1364 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 1365 func (s *FStatFSReq) UnmarshalBytes(src []byte) []byte { 1366 src = s.FD.UnmarshalUnsafe(src) 1367 return src 1368 } 1369 1370 // Packed implements marshal.Marshallable.Packed. 1371 //go:nosplit 1372 func (s *FStatFSReq) Packed() bool { 1373 return s.FD.Packed() 1374 } 1375 1376 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 1377 func (s *FStatFSReq) MarshalUnsafe(dst []byte) []byte { 1378 if s.FD.Packed() { 1379 size := s.SizeBytes() 1380 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 1381 return dst[size:] 1382 } 1383 // Type FStatFSReq doesn't have a packed layout in memory, fallback to MarshalBytes. 1384 return s.MarshalBytes(dst) 1385 } 1386 1387 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 1388 func (s *FStatFSReq) UnmarshalUnsafe(src []byte) []byte { 1389 if s.FD.Packed() { 1390 size := s.SizeBytes() 1391 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 1392 return src[size:] 1393 } 1394 // Type FStatFSReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 1395 return s.UnmarshalBytes(src) 1396 } 1397 1398 // CopyOutN implements marshal.Marshallable.CopyOutN. 1399 func (s *FStatFSReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1400 if !s.FD.Packed() { 1401 // Type FStatFSReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1402 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 1403 s.MarshalBytes(buf) // escapes: fallback. 1404 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1405 } 1406 1407 // Construct a slice backed by dst's underlying memory. 1408 var buf []byte 1409 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1410 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 1411 hdr.Len = s.SizeBytes() 1412 hdr.Cap = s.SizeBytes() 1413 1414 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1415 // Since we bypassed the compiler's escape analysis, indicate that s 1416 // must live until the use above. 1417 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 1418 return length, err 1419 } 1420 1421 // CopyOut implements marshal.Marshallable.CopyOut. 1422 func (s *FStatFSReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1423 return s.CopyOutN(cc, addr, s.SizeBytes()) 1424 } 1425 1426 // CopyInN implements marshal.Marshallable.CopyInN. 1427 func (s *FStatFSReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1428 if !s.FD.Packed() { 1429 // Type FStatFSReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 1430 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 1431 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1432 // Unmarshal unconditionally. If we had a short copy-in, this results in a 1433 // partially unmarshalled struct. 1434 s.UnmarshalBytes(buf) // escapes: fallback. 1435 return length, err 1436 } 1437 1438 // Construct a slice backed by dst's underlying memory. 1439 var buf []byte 1440 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1441 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 1442 hdr.Len = s.SizeBytes() 1443 hdr.Cap = s.SizeBytes() 1444 1445 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1446 // Since we bypassed the compiler's escape analysis, indicate that s 1447 // must live until the use above. 1448 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 1449 return length, err 1450 } 1451 1452 // CopyIn implements marshal.Marshallable.CopyIn. 1453 func (s *FStatFSReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1454 return s.CopyInN(cc, addr, s.SizeBytes()) 1455 } 1456 1457 // WriteTo implements io.WriterTo.WriteTo. 1458 func (s *FStatFSReq) WriteTo(writer io.Writer) (int64, error) { 1459 if !s.FD.Packed() { 1460 // Type FStatFSReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1461 buf := make([]byte, s.SizeBytes()) 1462 s.MarshalBytes(buf) 1463 length, err := writer.Write(buf) 1464 return int64(length), err 1465 } 1466 1467 // Construct a slice backed by dst's underlying memory. 1468 var buf []byte 1469 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1470 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 1471 hdr.Len = s.SizeBytes() 1472 hdr.Cap = s.SizeBytes() 1473 1474 length, err := writer.Write(buf) 1475 // Since we bypassed the compiler's escape analysis, indicate that s 1476 // must live until the use above. 1477 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 1478 return int64(length), err 1479 } 1480 1481 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 1482 func (s *FStatFSReq) CheckedMarshal(dst []byte) ([]byte, bool) { 1483 if s.SizeBytes() > len(dst) { 1484 return dst, false 1485 } 1486 return s.MarshalUnsafe(dst), true 1487 } 1488 1489 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 1490 func (s *FStatFSReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 1491 if s.SizeBytes() > len(src) { 1492 return src, false 1493 } 1494 return s.UnmarshalUnsafe(src), true 1495 } 1496 1497 // SizeBytes implements marshal.Marshallable.SizeBytes. 1498 func (f *FlushReq) SizeBytes() int { 1499 return 0 + 1500 (*FDID)(nil).SizeBytes() 1501 } 1502 1503 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 1504 func (f *FlushReq) MarshalBytes(dst []byte) []byte { 1505 dst = f.FD.MarshalUnsafe(dst) 1506 return dst 1507 } 1508 1509 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 1510 func (f *FlushReq) UnmarshalBytes(src []byte) []byte { 1511 src = f.FD.UnmarshalUnsafe(src) 1512 return src 1513 } 1514 1515 // Packed implements marshal.Marshallable.Packed. 1516 //go:nosplit 1517 func (f *FlushReq) Packed() bool { 1518 return f.FD.Packed() 1519 } 1520 1521 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 1522 func (f *FlushReq) MarshalUnsafe(dst []byte) []byte { 1523 if f.FD.Packed() { 1524 size := f.SizeBytes() 1525 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(f), uintptr(size)) 1526 return dst[size:] 1527 } 1528 // Type FlushReq doesn't have a packed layout in memory, fallback to MarshalBytes. 1529 return f.MarshalBytes(dst) 1530 } 1531 1532 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 1533 func (f *FlushReq) UnmarshalUnsafe(src []byte) []byte { 1534 if f.FD.Packed() { 1535 size := f.SizeBytes() 1536 gohacks.Memmove(unsafe.Pointer(f), unsafe.Pointer(&src[0]), uintptr(size)) 1537 return src[size:] 1538 } 1539 // Type FlushReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 1540 return f.UnmarshalBytes(src) 1541 } 1542 1543 // CopyOutN implements marshal.Marshallable.CopyOutN. 1544 func (f *FlushReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1545 if !f.FD.Packed() { 1546 // Type FlushReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1547 buf := cc.CopyScratchBuffer(f.SizeBytes()) // escapes: okay. 1548 f.MarshalBytes(buf) // escapes: fallback. 1549 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1550 } 1551 1552 // Construct a slice backed by dst's underlying memory. 1553 var buf []byte 1554 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1555 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f))) 1556 hdr.Len = f.SizeBytes() 1557 hdr.Cap = f.SizeBytes() 1558 1559 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1560 // Since we bypassed the compiler's escape analysis, indicate that f 1561 // must live until the use above. 1562 runtime.KeepAlive(f) // escapes: replaced by intrinsic. 1563 return length, err 1564 } 1565 1566 // CopyOut implements marshal.Marshallable.CopyOut. 1567 func (f *FlushReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1568 return f.CopyOutN(cc, addr, f.SizeBytes()) 1569 } 1570 1571 // CopyInN implements marshal.Marshallable.CopyInN. 1572 func (f *FlushReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1573 if !f.FD.Packed() { 1574 // Type FlushReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 1575 buf := cc.CopyScratchBuffer(f.SizeBytes()) // escapes: okay. 1576 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1577 // Unmarshal unconditionally. If we had a short copy-in, this results in a 1578 // partially unmarshalled struct. 1579 f.UnmarshalBytes(buf) // escapes: fallback. 1580 return length, err 1581 } 1582 1583 // Construct a slice backed by dst's underlying memory. 1584 var buf []byte 1585 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1586 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f))) 1587 hdr.Len = f.SizeBytes() 1588 hdr.Cap = f.SizeBytes() 1589 1590 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1591 // Since we bypassed the compiler's escape analysis, indicate that f 1592 // must live until the use above. 1593 runtime.KeepAlive(f) // escapes: replaced by intrinsic. 1594 return length, err 1595 } 1596 1597 // CopyIn implements marshal.Marshallable.CopyIn. 1598 func (f *FlushReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1599 return f.CopyInN(cc, addr, f.SizeBytes()) 1600 } 1601 1602 // WriteTo implements io.WriterTo.WriteTo. 1603 func (f *FlushReq) WriteTo(writer io.Writer) (int64, error) { 1604 if !f.FD.Packed() { 1605 // Type FlushReq doesn't have a packed layout in memory, fall back to MarshalBytes. 1606 buf := make([]byte, f.SizeBytes()) 1607 f.MarshalBytes(buf) 1608 length, err := writer.Write(buf) 1609 return int64(length), err 1610 } 1611 1612 // Construct a slice backed by dst's underlying memory. 1613 var buf []byte 1614 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1615 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(f))) 1616 hdr.Len = f.SizeBytes() 1617 hdr.Cap = f.SizeBytes() 1618 1619 length, err := writer.Write(buf) 1620 // Since we bypassed the compiler's escape analysis, indicate that f 1621 // must live until the use above. 1622 runtime.KeepAlive(f) // escapes: replaced by intrinsic. 1623 return int64(length), err 1624 } 1625 1626 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 1627 func (f *FlushReq) CheckedMarshal(dst []byte) ([]byte, bool) { 1628 if f.SizeBytes() > len(dst) { 1629 return dst, false 1630 } 1631 return f.MarshalUnsafe(dst), true 1632 } 1633 1634 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 1635 func (f *FlushReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 1636 if f.SizeBytes() > len(src) { 1637 return src, false 1638 } 1639 return f.UnmarshalUnsafe(src), true 1640 } 1641 1642 // SizeBytes implements marshal.Marshallable.SizeBytes. 1643 //go:nosplit 1644 func (gid *GID) SizeBytes() int { 1645 return 4 1646 } 1647 1648 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 1649 func (gid *GID) MarshalBytes(dst []byte) []byte { 1650 hostarch.ByteOrder.PutUint32(dst[:4], uint32(*gid)) 1651 return dst[4:] 1652 } 1653 1654 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 1655 func (gid *GID) UnmarshalBytes(src []byte) []byte { 1656 *gid = GID(uint32(hostarch.ByteOrder.Uint32(src[:4]))) 1657 return src[4:] 1658 } 1659 1660 // Packed implements marshal.Marshallable.Packed. 1661 //go:nosplit 1662 func (gid *GID) Packed() bool { 1663 // Scalar newtypes are always packed. 1664 return true 1665 } 1666 1667 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 1668 func (gid *GID) MarshalUnsafe(dst []byte) []byte { 1669 size := gid.SizeBytes() 1670 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(gid), uintptr(size)) 1671 return dst[size:] 1672 } 1673 1674 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 1675 func (gid *GID) UnmarshalUnsafe(src []byte) []byte { 1676 size := gid.SizeBytes() 1677 gohacks.Memmove(unsafe.Pointer(gid), unsafe.Pointer(&src[0]), uintptr(size)) 1678 return src[size:] 1679 } 1680 1681 // CopyOutN implements marshal.Marshallable.CopyOutN. 1682 func (gid *GID) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1683 // Construct a slice backed by dst's underlying memory. 1684 var buf []byte 1685 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1686 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(gid))) 1687 hdr.Len = gid.SizeBytes() 1688 hdr.Cap = gid.SizeBytes() 1689 1690 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1691 // Since we bypassed the compiler's escape analysis, indicate that gid 1692 // must live until the use above. 1693 runtime.KeepAlive(gid) // escapes: replaced by intrinsic. 1694 return length, err 1695 } 1696 1697 // CopyOut implements marshal.Marshallable.CopyOut. 1698 func (gid *GID) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1699 return gid.CopyOutN(cc, addr, gid.SizeBytes()) 1700 } 1701 1702 // CopyInN implements marshal.Marshallable.CopyInN. 1703 func (gid *GID) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1704 // Construct a slice backed by dst's underlying memory. 1705 var buf []byte 1706 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1707 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(gid))) 1708 hdr.Len = gid.SizeBytes() 1709 hdr.Cap = gid.SizeBytes() 1710 1711 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1712 // Since we bypassed the compiler's escape analysis, indicate that gid 1713 // must live until the use above. 1714 runtime.KeepAlive(gid) // escapes: replaced by intrinsic. 1715 return length, err 1716 } 1717 1718 // CopyIn implements marshal.Marshallable.CopyIn. 1719 func (gid *GID) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1720 return gid.CopyInN(cc, addr, gid.SizeBytes()) 1721 } 1722 1723 // WriteTo implements io.WriterTo.WriteTo. 1724 func (gid *GID) WriteTo(writer io.Writer) (int64, error) { 1725 // Construct a slice backed by dst's underlying memory. 1726 var buf []byte 1727 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1728 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(gid))) 1729 hdr.Len = gid.SizeBytes() 1730 hdr.Cap = gid.SizeBytes() 1731 1732 length, err := writer.Write(buf) 1733 // Since we bypassed the compiler's escape analysis, indicate that gid 1734 // must live until the use above. 1735 runtime.KeepAlive(gid) // escapes: replaced by intrinsic. 1736 return int64(length), err 1737 } 1738 1739 // SizeBytes implements marshal.Marshallable.SizeBytes. 1740 func (g *Getdents64Req) SizeBytes() int { 1741 return 8 + 1742 (*FDID)(nil).SizeBytes() 1743 } 1744 1745 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 1746 func (g *Getdents64Req) MarshalBytes(dst []byte) []byte { 1747 dst = g.DirFD.MarshalUnsafe(dst) 1748 hostarch.ByteOrder.PutUint32(dst[:4], uint32(g.Count)) 1749 dst = dst[4:] 1750 // Padding: dst[:sizeof(uint32)] ~= uint32(0) 1751 dst = dst[4:] 1752 return dst 1753 } 1754 1755 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 1756 func (g *Getdents64Req) UnmarshalBytes(src []byte) []byte { 1757 src = g.DirFD.UnmarshalUnsafe(src) 1758 g.Count = int32(hostarch.ByteOrder.Uint32(src[:4])) 1759 src = src[4:] 1760 // Padding: var _ uint32 ~= src[:sizeof(uint32)] 1761 src = src[4:] 1762 return src 1763 } 1764 1765 // Packed implements marshal.Marshallable.Packed. 1766 //go:nosplit 1767 func (g *Getdents64Req) Packed() bool { 1768 return g.DirFD.Packed() 1769 } 1770 1771 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 1772 func (g *Getdents64Req) MarshalUnsafe(dst []byte) []byte { 1773 if g.DirFD.Packed() { 1774 size := g.SizeBytes() 1775 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size)) 1776 return dst[size:] 1777 } 1778 // Type Getdents64Req doesn't have a packed layout in memory, fallback to MarshalBytes. 1779 return g.MarshalBytes(dst) 1780 } 1781 1782 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 1783 func (g *Getdents64Req) UnmarshalUnsafe(src []byte) []byte { 1784 if g.DirFD.Packed() { 1785 size := g.SizeBytes() 1786 gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size)) 1787 return src[size:] 1788 } 1789 // Type Getdents64Req doesn't have a packed layout in memory, fallback to UnmarshalBytes. 1790 return g.UnmarshalBytes(src) 1791 } 1792 1793 // CopyOutN implements marshal.Marshallable.CopyOutN. 1794 func (g *Getdents64Req) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1795 if !g.DirFD.Packed() { 1796 // Type Getdents64Req doesn't have a packed layout in memory, fall back to MarshalBytes. 1797 buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay. 1798 g.MarshalBytes(buf) // escapes: fallback. 1799 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1800 } 1801 1802 // Construct a slice backed by dst's underlying memory. 1803 var buf []byte 1804 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1805 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g))) 1806 hdr.Len = g.SizeBytes() 1807 hdr.Cap = g.SizeBytes() 1808 1809 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1810 // Since we bypassed the compiler's escape analysis, indicate that g 1811 // must live until the use above. 1812 runtime.KeepAlive(g) // escapes: replaced by intrinsic. 1813 return length, err 1814 } 1815 1816 // CopyOut implements marshal.Marshallable.CopyOut. 1817 func (g *Getdents64Req) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1818 return g.CopyOutN(cc, addr, g.SizeBytes()) 1819 } 1820 1821 // CopyInN implements marshal.Marshallable.CopyInN. 1822 func (g *Getdents64Req) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1823 if !g.DirFD.Packed() { 1824 // Type Getdents64Req doesn't have a packed layout in memory, fall back to UnmarshalBytes. 1825 buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay. 1826 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1827 // Unmarshal unconditionally. If we had a short copy-in, this results in a 1828 // partially unmarshalled struct. 1829 g.UnmarshalBytes(buf) // escapes: fallback. 1830 return length, err 1831 } 1832 1833 // Construct a slice backed by dst's underlying memory. 1834 var buf []byte 1835 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1836 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g))) 1837 hdr.Len = g.SizeBytes() 1838 hdr.Cap = g.SizeBytes() 1839 1840 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1841 // Since we bypassed the compiler's escape analysis, indicate that g 1842 // must live until the use above. 1843 runtime.KeepAlive(g) // escapes: replaced by intrinsic. 1844 return length, err 1845 } 1846 1847 // CopyIn implements marshal.Marshallable.CopyIn. 1848 func (g *Getdents64Req) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1849 return g.CopyInN(cc, addr, g.SizeBytes()) 1850 } 1851 1852 // WriteTo implements io.WriterTo.WriteTo. 1853 func (g *Getdents64Req) WriteTo(writer io.Writer) (int64, error) { 1854 if !g.DirFD.Packed() { 1855 // Type Getdents64Req doesn't have a packed layout in memory, fall back to MarshalBytes. 1856 buf := make([]byte, g.SizeBytes()) 1857 g.MarshalBytes(buf) 1858 length, err := writer.Write(buf) 1859 return int64(length), err 1860 } 1861 1862 // Construct a slice backed by dst's underlying memory. 1863 var buf []byte 1864 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1865 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g))) 1866 hdr.Len = g.SizeBytes() 1867 hdr.Cap = g.SizeBytes() 1868 1869 length, err := writer.Write(buf) 1870 // Since we bypassed the compiler's escape analysis, indicate that g 1871 // must live until the use above. 1872 runtime.KeepAlive(g) // escapes: replaced by intrinsic. 1873 return int64(length), err 1874 } 1875 1876 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 1877 func (g *Getdents64Req) CheckedMarshal(dst []byte) ([]byte, bool) { 1878 if g.SizeBytes() > len(dst) { 1879 return dst, false 1880 } 1881 return g.MarshalUnsafe(dst), true 1882 } 1883 1884 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 1885 func (g *Getdents64Req) CheckedUnmarshal(src []byte) ([]byte, bool) { 1886 if g.SizeBytes() > len(src) { 1887 return src, false 1888 } 1889 return g.UnmarshalUnsafe(src), true 1890 } 1891 1892 // SizeBytes implements marshal.Marshallable.SizeBytes. 1893 func (i *Inode) SizeBytes() int { 1894 return 0 + 1895 (*FDID)(nil).SizeBytes() + 1896 (*linux.Statx)(nil).SizeBytes() 1897 } 1898 1899 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 1900 func (i *Inode) MarshalBytes(dst []byte) []byte { 1901 dst = i.ControlFD.MarshalUnsafe(dst) 1902 dst = i.Stat.MarshalUnsafe(dst) 1903 return dst 1904 } 1905 1906 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 1907 func (i *Inode) UnmarshalBytes(src []byte) []byte { 1908 src = i.ControlFD.UnmarshalUnsafe(src) 1909 src = i.Stat.UnmarshalUnsafe(src) 1910 return src 1911 } 1912 1913 // Packed implements marshal.Marshallable.Packed. 1914 //go:nosplit 1915 func (i *Inode) Packed() bool { 1916 return i.ControlFD.Packed() && i.Stat.Packed() 1917 } 1918 1919 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 1920 func (i *Inode) MarshalUnsafe(dst []byte) []byte { 1921 if i.ControlFD.Packed() && i.Stat.Packed() { 1922 size := i.SizeBytes() 1923 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(i), uintptr(size)) 1924 return dst[size:] 1925 } 1926 // Type Inode doesn't have a packed layout in memory, fallback to MarshalBytes. 1927 return i.MarshalBytes(dst) 1928 } 1929 1930 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 1931 func (i *Inode) UnmarshalUnsafe(src []byte) []byte { 1932 if i.ControlFD.Packed() && i.Stat.Packed() { 1933 size := i.SizeBytes() 1934 gohacks.Memmove(unsafe.Pointer(i), unsafe.Pointer(&src[0]), uintptr(size)) 1935 return src[size:] 1936 } 1937 // Type Inode doesn't have a packed layout in memory, fallback to UnmarshalBytes. 1938 return i.UnmarshalBytes(src) 1939 } 1940 1941 // CopyOutN implements marshal.Marshallable.CopyOutN. 1942 func (i *Inode) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1943 if !i.ControlFD.Packed() && i.Stat.Packed() { 1944 // Type Inode doesn't have a packed layout in memory, fall back to MarshalBytes. 1945 buf := cc.CopyScratchBuffer(i.SizeBytes()) // escapes: okay. 1946 i.MarshalBytes(buf) // escapes: fallback. 1947 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1948 } 1949 1950 // Construct a slice backed by dst's underlying memory. 1951 var buf []byte 1952 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1953 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 1954 hdr.Len = i.SizeBytes() 1955 hdr.Cap = i.SizeBytes() 1956 1957 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 1958 // Since we bypassed the compiler's escape analysis, indicate that i 1959 // must live until the use above. 1960 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 1961 return length, err 1962 } 1963 1964 // CopyOut implements marshal.Marshallable.CopyOut. 1965 func (i *Inode) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1966 return i.CopyOutN(cc, addr, i.SizeBytes()) 1967 } 1968 1969 // CopyInN implements marshal.Marshallable.CopyInN. 1970 func (i *Inode) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 1971 if !i.ControlFD.Packed() && i.Stat.Packed() { 1972 // Type Inode doesn't have a packed layout in memory, fall back to UnmarshalBytes. 1973 buf := cc.CopyScratchBuffer(i.SizeBytes()) // escapes: okay. 1974 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1975 // Unmarshal unconditionally. If we had a short copy-in, this results in a 1976 // partially unmarshalled struct. 1977 i.UnmarshalBytes(buf) // escapes: fallback. 1978 return length, err 1979 } 1980 1981 // Construct a slice backed by dst's underlying memory. 1982 var buf []byte 1983 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 1984 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 1985 hdr.Len = i.SizeBytes() 1986 hdr.Cap = i.SizeBytes() 1987 1988 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 1989 // Since we bypassed the compiler's escape analysis, indicate that i 1990 // must live until the use above. 1991 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 1992 return length, err 1993 } 1994 1995 // CopyIn implements marshal.Marshallable.CopyIn. 1996 func (i *Inode) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 1997 return i.CopyInN(cc, addr, i.SizeBytes()) 1998 } 1999 2000 // WriteTo implements io.WriterTo.WriteTo. 2001 func (i *Inode) WriteTo(writer io.Writer) (int64, error) { 2002 if !i.ControlFD.Packed() && i.Stat.Packed() { 2003 // Type Inode doesn't have a packed layout in memory, fall back to MarshalBytes. 2004 buf := make([]byte, i.SizeBytes()) 2005 i.MarshalBytes(buf) 2006 length, err := writer.Write(buf) 2007 return int64(length), err 2008 } 2009 2010 // Construct a slice backed by dst's underlying memory. 2011 var buf []byte 2012 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2013 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(i))) 2014 hdr.Len = i.SizeBytes() 2015 hdr.Cap = i.SizeBytes() 2016 2017 length, err := writer.Write(buf) 2018 // Since we bypassed the compiler's escape analysis, indicate that i 2019 // must live until the use above. 2020 runtime.KeepAlive(i) // escapes: replaced by intrinsic. 2021 return int64(length), err 2022 } 2023 2024 // CopyInodeSliceIn copies in a slice of Inode objects from the task's memory. 2025 func CopyInodeSliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []Inode) (int, error) { 2026 count := len(dst) 2027 if count == 0 { 2028 return 0, nil 2029 } 2030 size := (*Inode)(nil).SizeBytes() 2031 2032 if !dst[0].Packed() { 2033 // Type Inode doesn't have a packed layout in memory, fall back to UnmarshalBytes. 2034 buf := cc.CopyScratchBuffer(size * count) 2035 length, err := cc.CopyInBytes(addr, buf) 2036 2037 // Unmarshal as much as possible, even on error. First handle full objects. 2038 limit := length/size 2039 for idx := 0; idx < limit; idx++ { 2040 buf = dst[idx].UnmarshalBytes(buf) 2041 } 2042 2043 // Handle any final partial object. buf is guaranteed to be long enough for the 2044 // final element, but may not contain valid data for the entire range. This may 2045 // result in unmarshalling zero values for some parts of the object. 2046 if length%size != 0 { 2047 dst[limit].UnmarshalBytes(buf) 2048 } 2049 2050 return length, err 2051 } 2052 2053 ptr := unsafe.Pointer(&dst) 2054 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 2055 2056 // Construct a slice backed by dst's underlying memory. 2057 var buf []byte 2058 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2059 hdr.Data = uintptr(val) 2060 hdr.Len = size * count 2061 hdr.Cap = size * count 2062 2063 length, err := cc.CopyInBytes(addr, buf) 2064 // Since we bypassed the compiler's escape analysis, indicate that dst 2065 // must live until the use above. 2066 runtime.KeepAlive(dst) // escapes: replaced by intrinsic. 2067 return length, err 2068 } 2069 2070 // CopyInodeSliceOut copies a slice of Inode objects to the task's memory. 2071 func CopyInodeSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []Inode) (int, error) { 2072 count := len(src) 2073 if count == 0 { 2074 return 0, nil 2075 } 2076 size := (*Inode)(nil).SizeBytes() 2077 2078 if !src[0].Packed() { 2079 // Type Inode doesn't have a packed layout in memory, fall back to MarshalBytes. 2080 buf := cc.CopyScratchBuffer(size * count) 2081 curBuf := buf 2082 for idx := 0; idx < count; idx++ { 2083 curBuf = src[idx].MarshalBytes(curBuf) 2084 } 2085 return cc.CopyOutBytes(addr, buf) 2086 } 2087 2088 ptr := unsafe.Pointer(&src) 2089 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 2090 2091 // Construct a slice backed by dst's underlying memory. 2092 var buf []byte 2093 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2094 hdr.Data = uintptr(val) 2095 hdr.Len = size * count 2096 hdr.Cap = size * count 2097 2098 length, err := cc.CopyOutBytes(addr, buf) 2099 // Since we bypassed the compiler's escape analysis, indicate that src 2100 // must live until the use above. 2101 runtime.KeepAlive(src) // escapes: replaced by intrinsic. 2102 return length, err 2103 } 2104 2105 // MarshalUnsafeInodeSlice is like Inode.MarshalUnsafe, but for a []Inode. 2106 func MarshalUnsafeInodeSlice(src []Inode, dst []byte) []byte { 2107 count := len(src) 2108 if count == 0 { 2109 return dst 2110 } 2111 2112 if !src[0].Packed() { 2113 // Type Inode doesn't have a packed layout in memory, fall back to MarshalBytes. 2114 for idx := 0; idx < count; idx++ { 2115 dst = src[idx].MarshalBytes(dst) 2116 } 2117 return dst 2118 } 2119 2120 size := (*Inode)(nil).SizeBytes() 2121 buf := dst[:size*count] 2122 gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf))) 2123 return dst[size*count:] 2124 } 2125 2126 // UnmarshalUnsafeInodeSlice is like Inode.UnmarshalUnsafe, but for a []Inode. 2127 func UnmarshalUnsafeInodeSlice(dst []Inode, src []byte) []byte { 2128 count := len(dst) 2129 if count == 0 { 2130 return src 2131 } 2132 2133 if !dst[0].Packed() { 2134 // Type Inode doesn't have a packed layout in memory, fall back to UnmarshalBytes. 2135 for idx := 0; idx < count; idx++ { 2136 src = dst[idx].UnmarshalBytes(src) 2137 } 2138 return src 2139 } 2140 2141 size := (*Inode)(nil).SizeBytes() 2142 buf := src[:size*count] 2143 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf))) 2144 return src[size*count:] 2145 } 2146 2147 // SizeBytes implements marshal.Marshallable.SizeBytes. 2148 func (l *LinkAtResp) SizeBytes() int { 2149 return 0 + 2150 (*Inode)(nil).SizeBytes() 2151 } 2152 2153 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 2154 func (l *LinkAtResp) MarshalBytes(dst []byte) []byte { 2155 dst = l.Link.MarshalUnsafe(dst) 2156 return dst 2157 } 2158 2159 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 2160 func (l *LinkAtResp) UnmarshalBytes(src []byte) []byte { 2161 src = l.Link.UnmarshalUnsafe(src) 2162 return src 2163 } 2164 2165 // Packed implements marshal.Marshallable.Packed. 2166 //go:nosplit 2167 func (l *LinkAtResp) Packed() bool { 2168 return l.Link.Packed() 2169 } 2170 2171 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 2172 func (l *LinkAtResp) MarshalUnsafe(dst []byte) []byte { 2173 if l.Link.Packed() { 2174 size := l.SizeBytes() 2175 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(l), uintptr(size)) 2176 return dst[size:] 2177 } 2178 // Type LinkAtResp doesn't have a packed layout in memory, fallback to MarshalBytes. 2179 return l.MarshalBytes(dst) 2180 } 2181 2182 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 2183 func (l *LinkAtResp) UnmarshalUnsafe(src []byte) []byte { 2184 if l.Link.Packed() { 2185 size := l.SizeBytes() 2186 gohacks.Memmove(unsafe.Pointer(l), unsafe.Pointer(&src[0]), uintptr(size)) 2187 return src[size:] 2188 } 2189 // Type LinkAtResp doesn't have a packed layout in memory, fallback to UnmarshalBytes. 2190 return l.UnmarshalBytes(src) 2191 } 2192 2193 // CopyOutN implements marshal.Marshallable.CopyOutN. 2194 func (l *LinkAtResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2195 if !l.Link.Packed() { 2196 // Type LinkAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 2197 buf := cc.CopyScratchBuffer(l.SizeBytes()) // escapes: okay. 2198 l.MarshalBytes(buf) // escapes: fallback. 2199 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2200 } 2201 2202 // Construct a slice backed by dst's underlying memory. 2203 var buf []byte 2204 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2205 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 2206 hdr.Len = l.SizeBytes() 2207 hdr.Cap = l.SizeBytes() 2208 2209 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2210 // Since we bypassed the compiler's escape analysis, indicate that l 2211 // must live until the use above. 2212 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 2213 return length, err 2214 } 2215 2216 // CopyOut implements marshal.Marshallable.CopyOut. 2217 func (l *LinkAtResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2218 return l.CopyOutN(cc, addr, l.SizeBytes()) 2219 } 2220 2221 // CopyInN implements marshal.Marshallable.CopyInN. 2222 func (l *LinkAtResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2223 if !l.Link.Packed() { 2224 // Type LinkAtResp doesn't have a packed layout in memory, fall back to UnmarshalBytes. 2225 buf := cc.CopyScratchBuffer(l.SizeBytes()) // escapes: okay. 2226 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2227 // Unmarshal unconditionally. If we had a short copy-in, this results in a 2228 // partially unmarshalled struct. 2229 l.UnmarshalBytes(buf) // escapes: fallback. 2230 return length, err 2231 } 2232 2233 // Construct a slice backed by dst's underlying memory. 2234 var buf []byte 2235 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2236 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 2237 hdr.Len = l.SizeBytes() 2238 hdr.Cap = l.SizeBytes() 2239 2240 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2241 // Since we bypassed the compiler's escape analysis, indicate that l 2242 // must live until the use above. 2243 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 2244 return length, err 2245 } 2246 2247 // CopyIn implements marshal.Marshallable.CopyIn. 2248 func (l *LinkAtResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2249 return l.CopyInN(cc, addr, l.SizeBytes()) 2250 } 2251 2252 // WriteTo implements io.WriterTo.WriteTo. 2253 func (l *LinkAtResp) WriteTo(writer io.Writer) (int64, error) { 2254 if !l.Link.Packed() { 2255 // Type LinkAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 2256 buf := make([]byte, l.SizeBytes()) 2257 l.MarshalBytes(buf) 2258 length, err := writer.Write(buf) 2259 return int64(length), err 2260 } 2261 2262 // Construct a slice backed by dst's underlying memory. 2263 var buf []byte 2264 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2265 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 2266 hdr.Len = l.SizeBytes() 2267 hdr.Cap = l.SizeBytes() 2268 2269 length, err := writer.Write(buf) 2270 // Since we bypassed the compiler's escape analysis, indicate that l 2271 // must live until the use above. 2272 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 2273 return int64(length), err 2274 } 2275 2276 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 2277 func (l *LinkAtResp) CheckedMarshal(dst []byte) ([]byte, bool) { 2278 if l.SizeBytes() > len(dst) { 2279 return dst, false 2280 } 2281 return l.MarshalUnsafe(dst), true 2282 } 2283 2284 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 2285 func (l *LinkAtResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 2286 if l.SizeBytes() > len(src) { 2287 return src, false 2288 } 2289 return l.UnmarshalUnsafe(src), true 2290 } 2291 2292 // SizeBytes implements marshal.Marshallable.SizeBytes. 2293 func (l *ListenReq) SizeBytes() int { 2294 return 8 + 2295 (*FDID)(nil).SizeBytes() 2296 } 2297 2298 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 2299 func (l *ListenReq) MarshalBytes(dst []byte) []byte { 2300 dst = l.FD.MarshalUnsafe(dst) 2301 hostarch.ByteOrder.PutUint32(dst[:4], uint32(l.Backlog)) 2302 dst = dst[4:] 2303 // Padding: dst[:sizeof(uint32)] ~= uint32(0) 2304 dst = dst[4:] 2305 return dst 2306 } 2307 2308 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 2309 func (l *ListenReq) UnmarshalBytes(src []byte) []byte { 2310 src = l.FD.UnmarshalUnsafe(src) 2311 l.Backlog = int32(hostarch.ByteOrder.Uint32(src[:4])) 2312 src = src[4:] 2313 // Padding: var _ uint32 ~= src[:sizeof(uint32)] 2314 src = src[4:] 2315 return src 2316 } 2317 2318 // Packed implements marshal.Marshallable.Packed. 2319 //go:nosplit 2320 func (l *ListenReq) Packed() bool { 2321 return l.FD.Packed() 2322 } 2323 2324 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 2325 func (l *ListenReq) MarshalUnsafe(dst []byte) []byte { 2326 if l.FD.Packed() { 2327 size := l.SizeBytes() 2328 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(l), uintptr(size)) 2329 return dst[size:] 2330 } 2331 // Type ListenReq doesn't have a packed layout in memory, fallback to MarshalBytes. 2332 return l.MarshalBytes(dst) 2333 } 2334 2335 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 2336 func (l *ListenReq) UnmarshalUnsafe(src []byte) []byte { 2337 if l.FD.Packed() { 2338 size := l.SizeBytes() 2339 gohacks.Memmove(unsafe.Pointer(l), unsafe.Pointer(&src[0]), uintptr(size)) 2340 return src[size:] 2341 } 2342 // Type ListenReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 2343 return l.UnmarshalBytes(src) 2344 } 2345 2346 // CopyOutN implements marshal.Marshallable.CopyOutN. 2347 func (l *ListenReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2348 if !l.FD.Packed() { 2349 // Type ListenReq doesn't have a packed layout in memory, fall back to MarshalBytes. 2350 buf := cc.CopyScratchBuffer(l.SizeBytes()) // escapes: okay. 2351 l.MarshalBytes(buf) // escapes: fallback. 2352 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2353 } 2354 2355 // Construct a slice backed by dst's underlying memory. 2356 var buf []byte 2357 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2358 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 2359 hdr.Len = l.SizeBytes() 2360 hdr.Cap = l.SizeBytes() 2361 2362 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2363 // Since we bypassed the compiler's escape analysis, indicate that l 2364 // must live until the use above. 2365 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 2366 return length, err 2367 } 2368 2369 // CopyOut implements marshal.Marshallable.CopyOut. 2370 func (l *ListenReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2371 return l.CopyOutN(cc, addr, l.SizeBytes()) 2372 } 2373 2374 // CopyInN implements marshal.Marshallable.CopyInN. 2375 func (l *ListenReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2376 if !l.FD.Packed() { 2377 // Type ListenReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 2378 buf := cc.CopyScratchBuffer(l.SizeBytes()) // escapes: okay. 2379 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2380 // Unmarshal unconditionally. If we had a short copy-in, this results in a 2381 // partially unmarshalled struct. 2382 l.UnmarshalBytes(buf) // escapes: fallback. 2383 return length, err 2384 } 2385 2386 // Construct a slice backed by dst's underlying memory. 2387 var buf []byte 2388 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2389 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 2390 hdr.Len = l.SizeBytes() 2391 hdr.Cap = l.SizeBytes() 2392 2393 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2394 // Since we bypassed the compiler's escape analysis, indicate that l 2395 // must live until the use above. 2396 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 2397 return length, err 2398 } 2399 2400 // CopyIn implements marshal.Marshallable.CopyIn. 2401 func (l *ListenReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2402 return l.CopyInN(cc, addr, l.SizeBytes()) 2403 } 2404 2405 // WriteTo implements io.WriterTo.WriteTo. 2406 func (l *ListenReq) WriteTo(writer io.Writer) (int64, error) { 2407 if !l.FD.Packed() { 2408 // Type ListenReq doesn't have a packed layout in memory, fall back to MarshalBytes. 2409 buf := make([]byte, l.SizeBytes()) 2410 l.MarshalBytes(buf) 2411 length, err := writer.Write(buf) 2412 return int64(length), err 2413 } 2414 2415 // Construct a slice backed by dst's underlying memory. 2416 var buf []byte 2417 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2418 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(l))) 2419 hdr.Len = l.SizeBytes() 2420 hdr.Cap = l.SizeBytes() 2421 2422 length, err := writer.Write(buf) 2423 // Since we bypassed the compiler's escape analysis, indicate that l 2424 // must live until the use above. 2425 runtime.KeepAlive(l) // escapes: replaced by intrinsic. 2426 return int64(length), err 2427 } 2428 2429 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 2430 func (l *ListenReq) CheckedMarshal(dst []byte) ([]byte, bool) { 2431 if l.SizeBytes() > len(dst) { 2432 return dst, false 2433 } 2434 return l.MarshalUnsafe(dst), true 2435 } 2436 2437 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 2438 func (l *ListenReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 2439 if l.SizeBytes() > len(src) { 2440 return src, false 2441 } 2442 return l.UnmarshalUnsafe(src), true 2443 } 2444 2445 // SizeBytes implements marshal.Marshallable.SizeBytes. 2446 //go:nosplit 2447 func (m *MID) SizeBytes() int { 2448 return 2 2449 } 2450 2451 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 2452 func (m *MID) MarshalBytes(dst []byte) []byte { 2453 hostarch.ByteOrder.PutUint16(dst[:2], uint16(*m)) 2454 return dst[2:] 2455 } 2456 2457 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 2458 func (m *MID) UnmarshalBytes(src []byte) []byte { 2459 *m = MID(uint16(hostarch.ByteOrder.Uint16(src[:2]))) 2460 return src[2:] 2461 } 2462 2463 // Packed implements marshal.Marshallable.Packed. 2464 //go:nosplit 2465 func (m *MID) Packed() bool { 2466 // Scalar newtypes are always packed. 2467 return true 2468 } 2469 2470 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 2471 func (m *MID) MarshalUnsafe(dst []byte) []byte { 2472 size := m.SizeBytes() 2473 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(size)) 2474 return dst[size:] 2475 } 2476 2477 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 2478 func (m *MID) UnmarshalUnsafe(src []byte) []byte { 2479 size := m.SizeBytes() 2480 gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(size)) 2481 return src[size:] 2482 } 2483 2484 // CopyOutN implements marshal.Marshallable.CopyOutN. 2485 func (m *MID) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2486 // Construct a slice backed by dst's underlying memory. 2487 var buf []byte 2488 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2489 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2490 hdr.Len = m.SizeBytes() 2491 hdr.Cap = m.SizeBytes() 2492 2493 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2494 // Since we bypassed the compiler's escape analysis, indicate that m 2495 // must live until the use above. 2496 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2497 return length, err 2498 } 2499 2500 // CopyOut implements marshal.Marshallable.CopyOut. 2501 func (m *MID) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2502 return m.CopyOutN(cc, addr, m.SizeBytes()) 2503 } 2504 2505 // CopyInN implements marshal.Marshallable.CopyInN. 2506 func (m *MID) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2507 // Construct a slice backed by dst's underlying memory. 2508 var buf []byte 2509 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2510 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2511 hdr.Len = m.SizeBytes() 2512 hdr.Cap = m.SizeBytes() 2513 2514 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2515 // Since we bypassed the compiler's escape analysis, indicate that m 2516 // must live until the use above. 2517 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2518 return length, err 2519 } 2520 2521 // CopyIn implements marshal.Marshallable.CopyIn. 2522 func (m *MID) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2523 return m.CopyInN(cc, addr, m.SizeBytes()) 2524 } 2525 2526 // WriteTo implements io.WriterTo.WriteTo. 2527 func (m *MID) WriteTo(writer io.Writer) (int64, error) { 2528 // Construct a slice backed by dst's underlying memory. 2529 var buf []byte 2530 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2531 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2532 hdr.Len = m.SizeBytes() 2533 hdr.Cap = m.SizeBytes() 2534 2535 length, err := writer.Write(buf) 2536 // Since we bypassed the compiler's escape analysis, indicate that m 2537 // must live until the use above. 2538 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2539 return int64(length), err 2540 } 2541 2542 // CopyMIDSliceIn copies in a slice of MID objects from the task's memory. 2543 func CopyMIDSliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []MID) (int, error) { 2544 count := len(dst) 2545 if count == 0 { 2546 return 0, nil 2547 } 2548 size := (*MID)(nil).SizeBytes() 2549 2550 ptr := unsafe.Pointer(&dst) 2551 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 2552 2553 // Construct a slice backed by dst's underlying memory. 2554 var buf []byte 2555 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2556 hdr.Data = uintptr(val) 2557 hdr.Len = size * count 2558 hdr.Cap = size * count 2559 2560 length, err := cc.CopyInBytes(addr, buf) // escapes: okay. 2561 // Since we bypassed the compiler's escape analysis, indicate that dst 2562 // must live until the use above. 2563 runtime.KeepAlive(dst) // escapes: replaced by intrinsic. 2564 return length, err 2565 } 2566 2567 // CopyMIDSliceOut copies a slice of MID objects to the task's memory. 2568 func CopyMIDSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []MID) (int, error) { 2569 count := len(src) 2570 if count == 0 { 2571 return 0, nil 2572 } 2573 size := (*MID)(nil).SizeBytes() 2574 2575 ptr := unsafe.Pointer(&src) 2576 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 2577 2578 // Construct a slice backed by dst's underlying memory. 2579 var buf []byte 2580 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2581 hdr.Data = uintptr(val) 2582 hdr.Len = size * count 2583 hdr.Cap = size * count 2584 2585 length, err := cc.CopyOutBytes(addr, buf) // escapes: okay. 2586 // Since we bypassed the compiler's escape analysis, indicate that src 2587 // must live until the use above. 2588 runtime.KeepAlive(src) // escapes: replaced by intrinsic. 2589 return length, err 2590 } 2591 2592 // MarshalUnsafeMIDSlice is like MID.MarshalUnsafe, but for a []MID. 2593 func MarshalUnsafeMIDSlice(src []MID, dst []byte) []byte { 2594 count := len(src) 2595 if count == 0 { 2596 return dst 2597 } 2598 size := (*MID)(nil).SizeBytes() 2599 2600 buf := dst[:size*count] 2601 gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf))) 2602 return dst[size*count:] 2603 } 2604 2605 // UnmarshalUnsafeMIDSlice is like MID.UnmarshalUnsafe, but for a []MID. 2606 func UnmarshalUnsafeMIDSlice(dst []MID, src []byte) []byte { 2607 count := len(dst) 2608 if count == 0 { 2609 return src 2610 } 2611 size := (*MID)(nil).SizeBytes() 2612 2613 buf := src[:size*count] 2614 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf))) 2615 return src[size*count:] 2616 } 2617 2618 // SizeBytes implements marshal.Marshallable.SizeBytes. 2619 func (m *MkdirAtResp) SizeBytes() int { 2620 return 0 + 2621 (*Inode)(nil).SizeBytes() 2622 } 2623 2624 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 2625 func (m *MkdirAtResp) MarshalBytes(dst []byte) []byte { 2626 dst = m.ChildDir.MarshalUnsafe(dst) 2627 return dst 2628 } 2629 2630 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 2631 func (m *MkdirAtResp) UnmarshalBytes(src []byte) []byte { 2632 src = m.ChildDir.UnmarshalUnsafe(src) 2633 return src 2634 } 2635 2636 // Packed implements marshal.Marshallable.Packed. 2637 //go:nosplit 2638 func (m *MkdirAtResp) Packed() bool { 2639 return m.ChildDir.Packed() 2640 } 2641 2642 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 2643 func (m *MkdirAtResp) MarshalUnsafe(dst []byte) []byte { 2644 if m.ChildDir.Packed() { 2645 size := m.SizeBytes() 2646 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(size)) 2647 return dst[size:] 2648 } 2649 // Type MkdirAtResp doesn't have a packed layout in memory, fallback to MarshalBytes. 2650 return m.MarshalBytes(dst) 2651 } 2652 2653 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 2654 func (m *MkdirAtResp) UnmarshalUnsafe(src []byte) []byte { 2655 if m.ChildDir.Packed() { 2656 size := m.SizeBytes() 2657 gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(size)) 2658 return src[size:] 2659 } 2660 // Type MkdirAtResp doesn't have a packed layout in memory, fallback to UnmarshalBytes. 2661 return m.UnmarshalBytes(src) 2662 } 2663 2664 // CopyOutN implements marshal.Marshallable.CopyOutN. 2665 func (m *MkdirAtResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2666 if !m.ChildDir.Packed() { 2667 // Type MkdirAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 2668 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 2669 m.MarshalBytes(buf) // escapes: fallback. 2670 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2671 } 2672 2673 // Construct a slice backed by dst's underlying memory. 2674 var buf []byte 2675 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2676 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2677 hdr.Len = m.SizeBytes() 2678 hdr.Cap = m.SizeBytes() 2679 2680 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2681 // Since we bypassed the compiler's escape analysis, indicate that m 2682 // must live until the use above. 2683 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2684 return length, err 2685 } 2686 2687 // CopyOut implements marshal.Marshallable.CopyOut. 2688 func (m *MkdirAtResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2689 return m.CopyOutN(cc, addr, m.SizeBytes()) 2690 } 2691 2692 // CopyInN implements marshal.Marshallable.CopyInN. 2693 func (m *MkdirAtResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2694 if !m.ChildDir.Packed() { 2695 // Type MkdirAtResp doesn't have a packed layout in memory, fall back to UnmarshalBytes. 2696 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 2697 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2698 // Unmarshal unconditionally. If we had a short copy-in, this results in a 2699 // partially unmarshalled struct. 2700 m.UnmarshalBytes(buf) // escapes: fallback. 2701 return length, err 2702 } 2703 2704 // Construct a slice backed by dst's underlying memory. 2705 var buf []byte 2706 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2707 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2708 hdr.Len = m.SizeBytes() 2709 hdr.Cap = m.SizeBytes() 2710 2711 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2712 // Since we bypassed the compiler's escape analysis, indicate that m 2713 // must live until the use above. 2714 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2715 return length, err 2716 } 2717 2718 // CopyIn implements marshal.Marshallable.CopyIn. 2719 func (m *MkdirAtResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2720 return m.CopyInN(cc, addr, m.SizeBytes()) 2721 } 2722 2723 // WriteTo implements io.WriterTo.WriteTo. 2724 func (m *MkdirAtResp) WriteTo(writer io.Writer) (int64, error) { 2725 if !m.ChildDir.Packed() { 2726 // Type MkdirAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 2727 buf := make([]byte, m.SizeBytes()) 2728 m.MarshalBytes(buf) 2729 length, err := writer.Write(buf) 2730 return int64(length), err 2731 } 2732 2733 // Construct a slice backed by dst's underlying memory. 2734 var buf []byte 2735 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2736 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2737 hdr.Len = m.SizeBytes() 2738 hdr.Cap = m.SizeBytes() 2739 2740 length, err := writer.Write(buf) 2741 // Since we bypassed the compiler's escape analysis, indicate that m 2742 // must live until the use above. 2743 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2744 return int64(length), err 2745 } 2746 2747 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 2748 func (m *MkdirAtResp) CheckedMarshal(dst []byte) ([]byte, bool) { 2749 if m.SizeBytes() > len(dst) { 2750 return dst, false 2751 } 2752 return m.MarshalUnsafe(dst), true 2753 } 2754 2755 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 2756 func (m *MkdirAtResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 2757 if m.SizeBytes() > len(src) { 2758 return src, false 2759 } 2760 return m.UnmarshalUnsafe(src), true 2761 } 2762 2763 // SizeBytes implements marshal.Marshallable.SizeBytes. 2764 func (m *MknodAtResp) SizeBytes() int { 2765 return 0 + 2766 (*Inode)(nil).SizeBytes() 2767 } 2768 2769 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 2770 func (m *MknodAtResp) MarshalBytes(dst []byte) []byte { 2771 dst = m.Child.MarshalUnsafe(dst) 2772 return dst 2773 } 2774 2775 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 2776 func (m *MknodAtResp) UnmarshalBytes(src []byte) []byte { 2777 src = m.Child.UnmarshalUnsafe(src) 2778 return src 2779 } 2780 2781 // Packed implements marshal.Marshallable.Packed. 2782 //go:nosplit 2783 func (m *MknodAtResp) Packed() bool { 2784 return m.Child.Packed() 2785 } 2786 2787 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 2788 func (m *MknodAtResp) MarshalUnsafe(dst []byte) []byte { 2789 if m.Child.Packed() { 2790 size := m.SizeBytes() 2791 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(size)) 2792 return dst[size:] 2793 } 2794 // Type MknodAtResp doesn't have a packed layout in memory, fallback to MarshalBytes. 2795 return m.MarshalBytes(dst) 2796 } 2797 2798 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 2799 func (m *MknodAtResp) UnmarshalUnsafe(src []byte) []byte { 2800 if m.Child.Packed() { 2801 size := m.SizeBytes() 2802 gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(size)) 2803 return src[size:] 2804 } 2805 // Type MknodAtResp doesn't have a packed layout in memory, fallback to UnmarshalBytes. 2806 return m.UnmarshalBytes(src) 2807 } 2808 2809 // CopyOutN implements marshal.Marshallable.CopyOutN. 2810 func (m *MknodAtResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2811 if !m.Child.Packed() { 2812 // Type MknodAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 2813 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 2814 m.MarshalBytes(buf) // escapes: fallback. 2815 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2816 } 2817 2818 // Construct a slice backed by dst's underlying memory. 2819 var buf []byte 2820 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2821 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2822 hdr.Len = m.SizeBytes() 2823 hdr.Cap = m.SizeBytes() 2824 2825 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2826 // Since we bypassed the compiler's escape analysis, indicate that m 2827 // must live until the use above. 2828 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2829 return length, err 2830 } 2831 2832 // CopyOut implements marshal.Marshallable.CopyOut. 2833 func (m *MknodAtResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2834 return m.CopyOutN(cc, addr, m.SizeBytes()) 2835 } 2836 2837 // CopyInN implements marshal.Marshallable.CopyInN. 2838 func (m *MknodAtResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2839 if !m.Child.Packed() { 2840 // Type MknodAtResp doesn't have a packed layout in memory, fall back to UnmarshalBytes. 2841 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 2842 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2843 // Unmarshal unconditionally. If we had a short copy-in, this results in a 2844 // partially unmarshalled struct. 2845 m.UnmarshalBytes(buf) // escapes: fallback. 2846 return length, err 2847 } 2848 2849 // Construct a slice backed by dst's underlying memory. 2850 var buf []byte 2851 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2852 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2853 hdr.Len = m.SizeBytes() 2854 hdr.Cap = m.SizeBytes() 2855 2856 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2857 // Since we bypassed the compiler's escape analysis, indicate that m 2858 // must live until the use above. 2859 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2860 return length, err 2861 } 2862 2863 // CopyIn implements marshal.Marshallable.CopyIn. 2864 func (m *MknodAtResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2865 return m.CopyInN(cc, addr, m.SizeBytes()) 2866 } 2867 2868 // WriteTo implements io.WriterTo.WriteTo. 2869 func (m *MknodAtResp) WriteTo(writer io.Writer) (int64, error) { 2870 if !m.Child.Packed() { 2871 // Type MknodAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 2872 buf := make([]byte, m.SizeBytes()) 2873 m.MarshalBytes(buf) 2874 length, err := writer.Write(buf) 2875 return int64(length), err 2876 } 2877 2878 // Construct a slice backed by dst's underlying memory. 2879 var buf []byte 2880 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2881 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 2882 hdr.Len = m.SizeBytes() 2883 hdr.Cap = m.SizeBytes() 2884 2885 length, err := writer.Write(buf) 2886 // Since we bypassed the compiler's escape analysis, indicate that m 2887 // must live until the use above. 2888 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 2889 return int64(length), err 2890 } 2891 2892 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 2893 func (m *MknodAtResp) CheckedMarshal(dst []byte) ([]byte, bool) { 2894 if m.SizeBytes() > len(dst) { 2895 return dst, false 2896 } 2897 return m.MarshalUnsafe(dst), true 2898 } 2899 2900 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 2901 func (m *MknodAtResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 2902 if m.SizeBytes() > len(src) { 2903 return src, false 2904 } 2905 return m.UnmarshalUnsafe(src), true 2906 } 2907 2908 // SizeBytes implements marshal.Marshallable.SizeBytes. 2909 func (o *OpenAtReq) SizeBytes() int { 2910 return 8 + 2911 (*FDID)(nil).SizeBytes() 2912 } 2913 2914 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 2915 func (o *OpenAtReq) MarshalBytes(dst []byte) []byte { 2916 dst = o.FD.MarshalUnsafe(dst) 2917 hostarch.ByteOrder.PutUint32(dst[:4], uint32(o.Flags)) 2918 dst = dst[4:] 2919 // Padding: dst[:sizeof(uint32)] ~= uint32(0) 2920 dst = dst[4:] 2921 return dst 2922 } 2923 2924 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 2925 func (o *OpenAtReq) UnmarshalBytes(src []byte) []byte { 2926 src = o.FD.UnmarshalUnsafe(src) 2927 o.Flags = uint32(hostarch.ByteOrder.Uint32(src[:4])) 2928 src = src[4:] 2929 // Padding: var _ uint32 ~= src[:sizeof(uint32)] 2930 src = src[4:] 2931 return src 2932 } 2933 2934 // Packed implements marshal.Marshallable.Packed. 2935 //go:nosplit 2936 func (o *OpenAtReq) Packed() bool { 2937 return o.FD.Packed() 2938 } 2939 2940 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 2941 func (o *OpenAtReq) MarshalUnsafe(dst []byte) []byte { 2942 if o.FD.Packed() { 2943 size := o.SizeBytes() 2944 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(o), uintptr(size)) 2945 return dst[size:] 2946 } 2947 // Type OpenAtReq doesn't have a packed layout in memory, fallback to MarshalBytes. 2948 return o.MarshalBytes(dst) 2949 } 2950 2951 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 2952 func (o *OpenAtReq) UnmarshalUnsafe(src []byte) []byte { 2953 if o.FD.Packed() { 2954 size := o.SizeBytes() 2955 gohacks.Memmove(unsafe.Pointer(o), unsafe.Pointer(&src[0]), uintptr(size)) 2956 return src[size:] 2957 } 2958 // Type OpenAtReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 2959 return o.UnmarshalBytes(src) 2960 } 2961 2962 // CopyOutN implements marshal.Marshallable.CopyOutN. 2963 func (o *OpenAtReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2964 if !o.FD.Packed() { 2965 // Type OpenAtReq doesn't have a packed layout in memory, fall back to MarshalBytes. 2966 buf := cc.CopyScratchBuffer(o.SizeBytes()) // escapes: okay. 2967 o.MarshalBytes(buf) // escapes: fallback. 2968 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2969 } 2970 2971 // Construct a slice backed by dst's underlying memory. 2972 var buf []byte 2973 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 2974 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 2975 hdr.Len = o.SizeBytes() 2976 hdr.Cap = o.SizeBytes() 2977 2978 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 2979 // Since we bypassed the compiler's escape analysis, indicate that o 2980 // must live until the use above. 2981 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 2982 return length, err 2983 } 2984 2985 // CopyOut implements marshal.Marshallable.CopyOut. 2986 func (o *OpenAtReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 2987 return o.CopyOutN(cc, addr, o.SizeBytes()) 2988 } 2989 2990 // CopyInN implements marshal.Marshallable.CopyInN. 2991 func (o *OpenAtReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 2992 if !o.FD.Packed() { 2993 // Type OpenAtReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 2994 buf := cc.CopyScratchBuffer(o.SizeBytes()) // escapes: okay. 2995 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 2996 // Unmarshal unconditionally. If we had a short copy-in, this results in a 2997 // partially unmarshalled struct. 2998 o.UnmarshalBytes(buf) // escapes: fallback. 2999 return length, err 3000 } 3001 3002 // Construct a slice backed by dst's underlying memory. 3003 var buf []byte 3004 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3005 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3006 hdr.Len = o.SizeBytes() 3007 hdr.Cap = o.SizeBytes() 3008 3009 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3010 // Since we bypassed the compiler's escape analysis, indicate that o 3011 // must live until the use above. 3012 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3013 return length, err 3014 } 3015 3016 // CopyIn implements marshal.Marshallable.CopyIn. 3017 func (o *OpenAtReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3018 return o.CopyInN(cc, addr, o.SizeBytes()) 3019 } 3020 3021 // WriteTo implements io.WriterTo.WriteTo. 3022 func (o *OpenAtReq) WriteTo(writer io.Writer) (int64, error) { 3023 if !o.FD.Packed() { 3024 // Type OpenAtReq doesn't have a packed layout in memory, fall back to MarshalBytes. 3025 buf := make([]byte, o.SizeBytes()) 3026 o.MarshalBytes(buf) 3027 length, err := writer.Write(buf) 3028 return int64(length), err 3029 } 3030 3031 // Construct a slice backed by dst's underlying memory. 3032 var buf []byte 3033 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3034 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3035 hdr.Len = o.SizeBytes() 3036 hdr.Cap = o.SizeBytes() 3037 3038 length, err := writer.Write(buf) 3039 // Since we bypassed the compiler's escape analysis, indicate that o 3040 // must live until the use above. 3041 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3042 return int64(length), err 3043 } 3044 3045 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 3046 func (o *OpenAtReq) CheckedMarshal(dst []byte) ([]byte, bool) { 3047 if o.SizeBytes() > len(dst) { 3048 return dst, false 3049 } 3050 return o.MarshalUnsafe(dst), true 3051 } 3052 3053 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 3054 func (o *OpenAtReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 3055 if o.SizeBytes() > len(src) { 3056 return src, false 3057 } 3058 return o.UnmarshalUnsafe(src), true 3059 } 3060 3061 // SizeBytes implements marshal.Marshallable.SizeBytes. 3062 func (o *OpenAtResp) SizeBytes() int { 3063 return 0 + 3064 (*FDID)(nil).SizeBytes() 3065 } 3066 3067 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 3068 func (o *OpenAtResp) MarshalBytes(dst []byte) []byte { 3069 dst = o.OpenFD.MarshalUnsafe(dst) 3070 return dst 3071 } 3072 3073 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 3074 func (o *OpenAtResp) UnmarshalBytes(src []byte) []byte { 3075 src = o.OpenFD.UnmarshalUnsafe(src) 3076 return src 3077 } 3078 3079 // Packed implements marshal.Marshallable.Packed. 3080 //go:nosplit 3081 func (o *OpenAtResp) Packed() bool { 3082 return o.OpenFD.Packed() 3083 } 3084 3085 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 3086 func (o *OpenAtResp) MarshalUnsafe(dst []byte) []byte { 3087 if o.OpenFD.Packed() { 3088 size := o.SizeBytes() 3089 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(o), uintptr(size)) 3090 return dst[size:] 3091 } 3092 // Type OpenAtResp doesn't have a packed layout in memory, fallback to MarshalBytes. 3093 return o.MarshalBytes(dst) 3094 } 3095 3096 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 3097 func (o *OpenAtResp) UnmarshalUnsafe(src []byte) []byte { 3098 if o.OpenFD.Packed() { 3099 size := o.SizeBytes() 3100 gohacks.Memmove(unsafe.Pointer(o), unsafe.Pointer(&src[0]), uintptr(size)) 3101 return src[size:] 3102 } 3103 // Type OpenAtResp doesn't have a packed layout in memory, fallback to UnmarshalBytes. 3104 return o.UnmarshalBytes(src) 3105 } 3106 3107 // CopyOutN implements marshal.Marshallable.CopyOutN. 3108 func (o *OpenAtResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3109 if !o.OpenFD.Packed() { 3110 // Type OpenAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 3111 buf := cc.CopyScratchBuffer(o.SizeBytes()) // escapes: okay. 3112 o.MarshalBytes(buf) // escapes: fallback. 3113 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3114 } 3115 3116 // Construct a slice backed by dst's underlying memory. 3117 var buf []byte 3118 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3119 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3120 hdr.Len = o.SizeBytes() 3121 hdr.Cap = o.SizeBytes() 3122 3123 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3124 // Since we bypassed the compiler's escape analysis, indicate that o 3125 // must live until the use above. 3126 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3127 return length, err 3128 } 3129 3130 // CopyOut implements marshal.Marshallable.CopyOut. 3131 func (o *OpenAtResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3132 return o.CopyOutN(cc, addr, o.SizeBytes()) 3133 } 3134 3135 // CopyInN implements marshal.Marshallable.CopyInN. 3136 func (o *OpenAtResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3137 if !o.OpenFD.Packed() { 3138 // Type OpenAtResp doesn't have a packed layout in memory, fall back to UnmarshalBytes. 3139 buf := cc.CopyScratchBuffer(o.SizeBytes()) // escapes: okay. 3140 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3141 // Unmarshal unconditionally. If we had a short copy-in, this results in a 3142 // partially unmarshalled struct. 3143 o.UnmarshalBytes(buf) // escapes: fallback. 3144 return length, err 3145 } 3146 3147 // Construct a slice backed by dst's underlying memory. 3148 var buf []byte 3149 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3150 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3151 hdr.Len = o.SizeBytes() 3152 hdr.Cap = o.SizeBytes() 3153 3154 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3155 // Since we bypassed the compiler's escape analysis, indicate that o 3156 // must live until the use above. 3157 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3158 return length, err 3159 } 3160 3161 // CopyIn implements marshal.Marshallable.CopyIn. 3162 func (o *OpenAtResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3163 return o.CopyInN(cc, addr, o.SizeBytes()) 3164 } 3165 3166 // WriteTo implements io.WriterTo.WriteTo. 3167 func (o *OpenAtResp) WriteTo(writer io.Writer) (int64, error) { 3168 if !o.OpenFD.Packed() { 3169 // Type OpenAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 3170 buf := make([]byte, o.SizeBytes()) 3171 o.MarshalBytes(buf) 3172 length, err := writer.Write(buf) 3173 return int64(length), err 3174 } 3175 3176 // Construct a slice backed by dst's underlying memory. 3177 var buf []byte 3178 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3179 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3180 hdr.Len = o.SizeBytes() 3181 hdr.Cap = o.SizeBytes() 3182 3183 length, err := writer.Write(buf) 3184 // Since we bypassed the compiler's escape analysis, indicate that o 3185 // must live until the use above. 3186 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3187 return int64(length), err 3188 } 3189 3190 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 3191 func (o *OpenAtResp) CheckedMarshal(dst []byte) ([]byte, bool) { 3192 if o.SizeBytes() > len(dst) { 3193 return dst, false 3194 } 3195 return o.MarshalUnsafe(dst), true 3196 } 3197 3198 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 3199 func (o *OpenAtResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 3200 if o.SizeBytes() > len(src) { 3201 return src, false 3202 } 3203 return o.UnmarshalUnsafe(src), true 3204 } 3205 3206 // SizeBytes implements marshal.Marshallable.SizeBytes. 3207 func (o *OpenCreateAtResp) SizeBytes() int { 3208 return 0 + 3209 (*Inode)(nil).SizeBytes() + 3210 (*FDID)(nil).SizeBytes() 3211 } 3212 3213 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 3214 func (o *OpenCreateAtResp) MarshalBytes(dst []byte) []byte { 3215 dst = o.Child.MarshalUnsafe(dst) 3216 dst = o.NewFD.MarshalUnsafe(dst) 3217 return dst 3218 } 3219 3220 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 3221 func (o *OpenCreateAtResp) UnmarshalBytes(src []byte) []byte { 3222 src = o.Child.UnmarshalUnsafe(src) 3223 src = o.NewFD.UnmarshalUnsafe(src) 3224 return src 3225 } 3226 3227 // Packed implements marshal.Marshallable.Packed. 3228 //go:nosplit 3229 func (o *OpenCreateAtResp) Packed() bool { 3230 return o.Child.Packed() && o.NewFD.Packed() 3231 } 3232 3233 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 3234 func (o *OpenCreateAtResp) MarshalUnsafe(dst []byte) []byte { 3235 if o.Child.Packed() && o.NewFD.Packed() { 3236 size := o.SizeBytes() 3237 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(o), uintptr(size)) 3238 return dst[size:] 3239 } 3240 // Type OpenCreateAtResp doesn't have a packed layout in memory, fallback to MarshalBytes. 3241 return o.MarshalBytes(dst) 3242 } 3243 3244 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 3245 func (o *OpenCreateAtResp) UnmarshalUnsafe(src []byte) []byte { 3246 if o.Child.Packed() && o.NewFD.Packed() { 3247 size := o.SizeBytes() 3248 gohacks.Memmove(unsafe.Pointer(o), unsafe.Pointer(&src[0]), uintptr(size)) 3249 return src[size:] 3250 } 3251 // Type OpenCreateAtResp doesn't have a packed layout in memory, fallback to UnmarshalBytes. 3252 return o.UnmarshalBytes(src) 3253 } 3254 3255 // CopyOutN implements marshal.Marshallable.CopyOutN. 3256 func (o *OpenCreateAtResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3257 if !o.Child.Packed() && o.NewFD.Packed() { 3258 // Type OpenCreateAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 3259 buf := cc.CopyScratchBuffer(o.SizeBytes()) // escapes: okay. 3260 o.MarshalBytes(buf) // escapes: fallback. 3261 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3262 } 3263 3264 // Construct a slice backed by dst's underlying memory. 3265 var buf []byte 3266 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3267 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3268 hdr.Len = o.SizeBytes() 3269 hdr.Cap = o.SizeBytes() 3270 3271 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3272 // Since we bypassed the compiler's escape analysis, indicate that o 3273 // must live until the use above. 3274 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3275 return length, err 3276 } 3277 3278 // CopyOut implements marshal.Marshallable.CopyOut. 3279 func (o *OpenCreateAtResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3280 return o.CopyOutN(cc, addr, o.SizeBytes()) 3281 } 3282 3283 // CopyInN implements marshal.Marshallable.CopyInN. 3284 func (o *OpenCreateAtResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3285 if !o.Child.Packed() && o.NewFD.Packed() { 3286 // Type OpenCreateAtResp doesn't have a packed layout in memory, fall back to UnmarshalBytes. 3287 buf := cc.CopyScratchBuffer(o.SizeBytes()) // escapes: okay. 3288 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3289 // Unmarshal unconditionally. If we had a short copy-in, this results in a 3290 // partially unmarshalled struct. 3291 o.UnmarshalBytes(buf) // escapes: fallback. 3292 return length, err 3293 } 3294 3295 // Construct a slice backed by dst's underlying memory. 3296 var buf []byte 3297 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3298 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3299 hdr.Len = o.SizeBytes() 3300 hdr.Cap = o.SizeBytes() 3301 3302 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3303 // Since we bypassed the compiler's escape analysis, indicate that o 3304 // must live until the use above. 3305 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3306 return length, err 3307 } 3308 3309 // CopyIn implements marshal.Marshallable.CopyIn. 3310 func (o *OpenCreateAtResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3311 return o.CopyInN(cc, addr, o.SizeBytes()) 3312 } 3313 3314 // WriteTo implements io.WriterTo.WriteTo. 3315 func (o *OpenCreateAtResp) WriteTo(writer io.Writer) (int64, error) { 3316 if !o.Child.Packed() && o.NewFD.Packed() { 3317 // Type OpenCreateAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 3318 buf := make([]byte, o.SizeBytes()) 3319 o.MarshalBytes(buf) 3320 length, err := writer.Write(buf) 3321 return int64(length), err 3322 } 3323 3324 // Construct a slice backed by dst's underlying memory. 3325 var buf []byte 3326 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3327 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(o))) 3328 hdr.Len = o.SizeBytes() 3329 hdr.Cap = o.SizeBytes() 3330 3331 length, err := writer.Write(buf) 3332 // Since we bypassed the compiler's escape analysis, indicate that o 3333 // must live until the use above. 3334 runtime.KeepAlive(o) // escapes: replaced by intrinsic. 3335 return int64(length), err 3336 } 3337 3338 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 3339 func (o *OpenCreateAtResp) CheckedMarshal(dst []byte) ([]byte, bool) { 3340 if o.SizeBytes() > len(dst) { 3341 return dst, false 3342 } 3343 return o.MarshalUnsafe(dst), true 3344 } 3345 3346 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 3347 func (o *OpenCreateAtResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 3348 if o.SizeBytes() > len(src) { 3349 return src, false 3350 } 3351 return o.UnmarshalUnsafe(src), true 3352 } 3353 3354 // SizeBytes implements marshal.Marshallable.SizeBytes. 3355 func (r *PReadReq) SizeBytes() int { 3356 return 16 + 3357 (*FDID)(nil).SizeBytes() 3358 } 3359 3360 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 3361 func (r *PReadReq) MarshalBytes(dst []byte) []byte { 3362 hostarch.ByteOrder.PutUint64(dst[:8], uint64(r.Offset)) 3363 dst = dst[8:] 3364 dst = r.FD.MarshalUnsafe(dst) 3365 hostarch.ByteOrder.PutUint32(dst[:4], uint32(r.Count)) 3366 dst = dst[4:] 3367 // Padding: dst[:sizeof(uint32)] ~= uint32(0) 3368 dst = dst[4:] 3369 return dst 3370 } 3371 3372 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 3373 func (r *PReadReq) UnmarshalBytes(src []byte) []byte { 3374 r.Offset = uint64(hostarch.ByteOrder.Uint64(src[:8])) 3375 src = src[8:] 3376 src = r.FD.UnmarshalUnsafe(src) 3377 r.Count = uint32(hostarch.ByteOrder.Uint32(src[:4])) 3378 src = src[4:] 3379 // Padding: var _ uint32 ~= src[:sizeof(uint32)] 3380 src = src[4:] 3381 return src 3382 } 3383 3384 // Packed implements marshal.Marshallable.Packed. 3385 //go:nosplit 3386 func (r *PReadReq) Packed() bool { 3387 return r.FD.Packed() 3388 } 3389 3390 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 3391 func (r *PReadReq) MarshalUnsafe(dst []byte) []byte { 3392 if r.FD.Packed() { 3393 size := r.SizeBytes() 3394 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(r), uintptr(size)) 3395 return dst[size:] 3396 } 3397 // Type PReadReq doesn't have a packed layout in memory, fallback to MarshalBytes. 3398 return r.MarshalBytes(dst) 3399 } 3400 3401 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 3402 func (r *PReadReq) UnmarshalUnsafe(src []byte) []byte { 3403 if r.FD.Packed() { 3404 size := r.SizeBytes() 3405 gohacks.Memmove(unsafe.Pointer(r), unsafe.Pointer(&src[0]), uintptr(size)) 3406 return src[size:] 3407 } 3408 // Type PReadReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 3409 return r.UnmarshalBytes(src) 3410 } 3411 3412 // CopyOutN implements marshal.Marshallable.CopyOutN. 3413 func (r *PReadReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3414 if !r.FD.Packed() { 3415 // Type PReadReq doesn't have a packed layout in memory, fall back to MarshalBytes. 3416 buf := cc.CopyScratchBuffer(r.SizeBytes()) // escapes: okay. 3417 r.MarshalBytes(buf) // escapes: fallback. 3418 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3419 } 3420 3421 // Construct a slice backed by dst's underlying memory. 3422 var buf []byte 3423 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3424 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 3425 hdr.Len = r.SizeBytes() 3426 hdr.Cap = r.SizeBytes() 3427 3428 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3429 // Since we bypassed the compiler's escape analysis, indicate that r 3430 // must live until the use above. 3431 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 3432 return length, err 3433 } 3434 3435 // CopyOut implements marshal.Marshallable.CopyOut. 3436 func (r *PReadReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3437 return r.CopyOutN(cc, addr, r.SizeBytes()) 3438 } 3439 3440 // CopyInN implements marshal.Marshallable.CopyInN. 3441 func (r *PReadReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3442 if !r.FD.Packed() { 3443 // Type PReadReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 3444 buf := cc.CopyScratchBuffer(r.SizeBytes()) // escapes: okay. 3445 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3446 // Unmarshal unconditionally. If we had a short copy-in, this results in a 3447 // partially unmarshalled struct. 3448 r.UnmarshalBytes(buf) // escapes: fallback. 3449 return length, err 3450 } 3451 3452 // Construct a slice backed by dst's underlying memory. 3453 var buf []byte 3454 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3455 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 3456 hdr.Len = r.SizeBytes() 3457 hdr.Cap = r.SizeBytes() 3458 3459 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3460 // Since we bypassed the compiler's escape analysis, indicate that r 3461 // must live until the use above. 3462 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 3463 return length, err 3464 } 3465 3466 // CopyIn implements marshal.Marshallable.CopyIn. 3467 func (r *PReadReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3468 return r.CopyInN(cc, addr, r.SizeBytes()) 3469 } 3470 3471 // WriteTo implements io.WriterTo.WriteTo. 3472 func (r *PReadReq) WriteTo(writer io.Writer) (int64, error) { 3473 if !r.FD.Packed() { 3474 // Type PReadReq doesn't have a packed layout in memory, fall back to MarshalBytes. 3475 buf := make([]byte, r.SizeBytes()) 3476 r.MarshalBytes(buf) 3477 length, err := writer.Write(buf) 3478 return int64(length), err 3479 } 3480 3481 // Construct a slice backed by dst's underlying memory. 3482 var buf []byte 3483 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3484 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 3485 hdr.Len = r.SizeBytes() 3486 hdr.Cap = r.SizeBytes() 3487 3488 length, err := writer.Write(buf) 3489 // Since we bypassed the compiler's escape analysis, indicate that r 3490 // must live until the use above. 3491 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 3492 return int64(length), err 3493 } 3494 3495 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 3496 func (r *PReadReq) CheckedMarshal(dst []byte) ([]byte, bool) { 3497 if r.SizeBytes() > len(dst) { 3498 return dst, false 3499 } 3500 return r.MarshalUnsafe(dst), true 3501 } 3502 3503 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 3504 func (r *PReadReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 3505 if r.SizeBytes() > len(src) { 3506 return src, false 3507 } 3508 return r.UnmarshalUnsafe(src), true 3509 } 3510 3511 // SizeBytes implements marshal.Marshallable.SizeBytes. 3512 func (w *PWriteResp) SizeBytes() int { 3513 return 8 3514 } 3515 3516 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 3517 func (w *PWriteResp) MarshalBytes(dst []byte) []byte { 3518 hostarch.ByteOrder.PutUint64(dst[:8], uint64(w.Count)) 3519 dst = dst[8:] 3520 return dst 3521 } 3522 3523 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 3524 func (w *PWriteResp) UnmarshalBytes(src []byte) []byte { 3525 w.Count = uint64(hostarch.ByteOrder.Uint64(src[:8])) 3526 src = src[8:] 3527 return src 3528 } 3529 3530 // Packed implements marshal.Marshallable.Packed. 3531 //go:nosplit 3532 func (w *PWriteResp) Packed() bool { 3533 return true 3534 } 3535 3536 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 3537 func (w *PWriteResp) MarshalUnsafe(dst []byte) []byte { 3538 size := w.SizeBytes() 3539 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(w), uintptr(size)) 3540 return dst[size:] 3541 } 3542 3543 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 3544 func (w *PWriteResp) UnmarshalUnsafe(src []byte) []byte { 3545 size := w.SizeBytes() 3546 gohacks.Memmove(unsafe.Pointer(w), unsafe.Pointer(&src[0]), uintptr(size)) 3547 return src[size:] 3548 } 3549 3550 // CopyOutN implements marshal.Marshallable.CopyOutN. 3551 func (w *PWriteResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3552 // Construct a slice backed by dst's underlying memory. 3553 var buf []byte 3554 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3555 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(w))) 3556 hdr.Len = w.SizeBytes() 3557 hdr.Cap = w.SizeBytes() 3558 3559 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3560 // Since we bypassed the compiler's escape analysis, indicate that w 3561 // must live until the use above. 3562 runtime.KeepAlive(w) // escapes: replaced by intrinsic. 3563 return length, err 3564 } 3565 3566 // CopyOut implements marshal.Marshallable.CopyOut. 3567 func (w *PWriteResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3568 return w.CopyOutN(cc, addr, w.SizeBytes()) 3569 } 3570 3571 // CopyInN implements marshal.Marshallable.CopyInN. 3572 func (w *PWriteResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3573 // Construct a slice backed by dst's underlying memory. 3574 var buf []byte 3575 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3576 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(w))) 3577 hdr.Len = w.SizeBytes() 3578 hdr.Cap = w.SizeBytes() 3579 3580 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3581 // Since we bypassed the compiler's escape analysis, indicate that w 3582 // must live until the use above. 3583 runtime.KeepAlive(w) // escapes: replaced by intrinsic. 3584 return length, err 3585 } 3586 3587 // CopyIn implements marshal.Marshallable.CopyIn. 3588 func (w *PWriteResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3589 return w.CopyInN(cc, addr, w.SizeBytes()) 3590 } 3591 3592 // WriteTo implements io.WriterTo.WriteTo. 3593 func (w *PWriteResp) WriteTo(writer io.Writer) (int64, error) { 3594 // Construct a slice backed by dst's underlying memory. 3595 var buf []byte 3596 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3597 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(w))) 3598 hdr.Len = w.SizeBytes() 3599 hdr.Cap = w.SizeBytes() 3600 3601 length, err := writer.Write(buf) 3602 // Since we bypassed the compiler's escape analysis, indicate that w 3603 // must live until the use above. 3604 runtime.KeepAlive(w) // escapes: replaced by intrinsic. 3605 return int64(length), err 3606 } 3607 3608 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 3609 func (w *PWriteResp) CheckedMarshal(dst []byte) ([]byte, bool) { 3610 if w.SizeBytes() > len(dst) { 3611 return dst, false 3612 } 3613 return w.MarshalUnsafe(dst), true 3614 } 3615 3616 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 3617 func (w *PWriteResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 3618 if w.SizeBytes() > len(src) { 3619 return src, false 3620 } 3621 return w.UnmarshalUnsafe(src), true 3622 } 3623 3624 // SizeBytes implements marshal.Marshallable.SizeBytes. 3625 func (r *ReadLinkAtReq) SizeBytes() int { 3626 return 0 + 3627 (*FDID)(nil).SizeBytes() 3628 } 3629 3630 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 3631 func (r *ReadLinkAtReq) MarshalBytes(dst []byte) []byte { 3632 dst = r.FD.MarshalUnsafe(dst) 3633 return dst 3634 } 3635 3636 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 3637 func (r *ReadLinkAtReq) UnmarshalBytes(src []byte) []byte { 3638 src = r.FD.UnmarshalUnsafe(src) 3639 return src 3640 } 3641 3642 // Packed implements marshal.Marshallable.Packed. 3643 //go:nosplit 3644 func (r *ReadLinkAtReq) Packed() bool { 3645 return r.FD.Packed() 3646 } 3647 3648 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 3649 func (r *ReadLinkAtReq) MarshalUnsafe(dst []byte) []byte { 3650 if r.FD.Packed() { 3651 size := r.SizeBytes() 3652 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(r), uintptr(size)) 3653 return dst[size:] 3654 } 3655 // Type ReadLinkAtReq doesn't have a packed layout in memory, fallback to MarshalBytes. 3656 return r.MarshalBytes(dst) 3657 } 3658 3659 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 3660 func (r *ReadLinkAtReq) UnmarshalUnsafe(src []byte) []byte { 3661 if r.FD.Packed() { 3662 size := r.SizeBytes() 3663 gohacks.Memmove(unsafe.Pointer(r), unsafe.Pointer(&src[0]), uintptr(size)) 3664 return src[size:] 3665 } 3666 // Type ReadLinkAtReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 3667 return r.UnmarshalBytes(src) 3668 } 3669 3670 // CopyOutN implements marshal.Marshallable.CopyOutN. 3671 func (r *ReadLinkAtReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3672 if !r.FD.Packed() { 3673 // Type ReadLinkAtReq doesn't have a packed layout in memory, fall back to MarshalBytes. 3674 buf := cc.CopyScratchBuffer(r.SizeBytes()) // escapes: okay. 3675 r.MarshalBytes(buf) // escapes: fallback. 3676 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3677 } 3678 3679 // Construct a slice backed by dst's underlying memory. 3680 var buf []byte 3681 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3682 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 3683 hdr.Len = r.SizeBytes() 3684 hdr.Cap = r.SizeBytes() 3685 3686 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3687 // Since we bypassed the compiler's escape analysis, indicate that r 3688 // must live until the use above. 3689 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 3690 return length, err 3691 } 3692 3693 // CopyOut implements marshal.Marshallable.CopyOut. 3694 func (r *ReadLinkAtReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3695 return r.CopyOutN(cc, addr, r.SizeBytes()) 3696 } 3697 3698 // CopyInN implements marshal.Marshallable.CopyInN. 3699 func (r *ReadLinkAtReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3700 if !r.FD.Packed() { 3701 // Type ReadLinkAtReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 3702 buf := cc.CopyScratchBuffer(r.SizeBytes()) // escapes: okay. 3703 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3704 // Unmarshal unconditionally. If we had a short copy-in, this results in a 3705 // partially unmarshalled struct. 3706 r.UnmarshalBytes(buf) // escapes: fallback. 3707 return length, err 3708 } 3709 3710 // Construct a slice backed by dst's underlying memory. 3711 var buf []byte 3712 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3713 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 3714 hdr.Len = r.SizeBytes() 3715 hdr.Cap = r.SizeBytes() 3716 3717 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3718 // Since we bypassed the compiler's escape analysis, indicate that r 3719 // must live until the use above. 3720 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 3721 return length, err 3722 } 3723 3724 // CopyIn implements marshal.Marshallable.CopyIn. 3725 func (r *ReadLinkAtReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3726 return r.CopyInN(cc, addr, r.SizeBytes()) 3727 } 3728 3729 // WriteTo implements io.WriterTo.WriteTo. 3730 func (r *ReadLinkAtReq) WriteTo(writer io.Writer) (int64, error) { 3731 if !r.FD.Packed() { 3732 // Type ReadLinkAtReq doesn't have a packed layout in memory, fall back to MarshalBytes. 3733 buf := make([]byte, r.SizeBytes()) 3734 r.MarshalBytes(buf) 3735 length, err := writer.Write(buf) 3736 return int64(length), err 3737 } 3738 3739 // Construct a slice backed by dst's underlying memory. 3740 var buf []byte 3741 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3742 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(r))) 3743 hdr.Len = r.SizeBytes() 3744 hdr.Cap = r.SizeBytes() 3745 3746 length, err := writer.Write(buf) 3747 // Since we bypassed the compiler's escape analysis, indicate that r 3748 // must live until the use above. 3749 runtime.KeepAlive(r) // escapes: replaced by intrinsic. 3750 return int64(length), err 3751 } 3752 3753 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 3754 func (r *ReadLinkAtReq) CheckedMarshal(dst []byte) ([]byte, bool) { 3755 if r.SizeBytes() > len(dst) { 3756 return dst, false 3757 } 3758 return r.MarshalUnsafe(dst), true 3759 } 3760 3761 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 3762 func (r *ReadLinkAtReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 3763 if r.SizeBytes() > len(src) { 3764 return src, false 3765 } 3766 return r.UnmarshalUnsafe(src), true 3767 } 3768 3769 // SizeBytes implements marshal.Marshallable.SizeBytes. 3770 func (s *SetStatReq) SizeBytes() int { 3771 return 16 + 3772 (*FDID)(nil).SizeBytes() + 3773 (*UID)(nil).SizeBytes() + 3774 (*GID)(nil).SizeBytes() + 3775 (*linux.Timespec)(nil).SizeBytes() + 3776 (*linux.Timespec)(nil).SizeBytes() 3777 } 3778 3779 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 3780 func (s *SetStatReq) MarshalBytes(dst []byte) []byte { 3781 dst = s.FD.MarshalUnsafe(dst) 3782 hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.Mask)) 3783 dst = dst[4:] 3784 hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.Mode)) 3785 dst = dst[4:] 3786 dst = s.UID.MarshalUnsafe(dst) 3787 dst = s.GID.MarshalUnsafe(dst) 3788 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Size)) 3789 dst = dst[8:] 3790 dst = s.Atime.MarshalUnsafe(dst) 3791 dst = s.Mtime.MarshalUnsafe(dst) 3792 return dst 3793 } 3794 3795 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 3796 func (s *SetStatReq) UnmarshalBytes(src []byte) []byte { 3797 src = s.FD.UnmarshalUnsafe(src) 3798 s.Mask = uint32(hostarch.ByteOrder.Uint32(src[:4])) 3799 src = src[4:] 3800 s.Mode = uint32(hostarch.ByteOrder.Uint32(src[:4])) 3801 src = src[4:] 3802 src = s.UID.UnmarshalUnsafe(src) 3803 src = s.GID.UnmarshalUnsafe(src) 3804 s.Size = uint64(hostarch.ByteOrder.Uint64(src[:8])) 3805 src = src[8:] 3806 src = s.Atime.UnmarshalUnsafe(src) 3807 src = s.Mtime.UnmarshalUnsafe(src) 3808 return src 3809 } 3810 3811 // Packed implements marshal.Marshallable.Packed. 3812 //go:nosplit 3813 func (s *SetStatReq) Packed() bool { 3814 return s.Atime.Packed() && s.FD.Packed() && s.GID.Packed() && s.Mtime.Packed() && s.UID.Packed() 3815 } 3816 3817 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 3818 func (s *SetStatReq) MarshalUnsafe(dst []byte) []byte { 3819 if s.Atime.Packed() && s.FD.Packed() && s.GID.Packed() && s.Mtime.Packed() && s.UID.Packed() { 3820 size := s.SizeBytes() 3821 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 3822 return dst[size:] 3823 } 3824 // Type SetStatReq doesn't have a packed layout in memory, fallback to MarshalBytes. 3825 return s.MarshalBytes(dst) 3826 } 3827 3828 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 3829 func (s *SetStatReq) UnmarshalUnsafe(src []byte) []byte { 3830 if s.Atime.Packed() && s.FD.Packed() && s.GID.Packed() && s.Mtime.Packed() && s.UID.Packed() { 3831 size := s.SizeBytes() 3832 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 3833 return src[size:] 3834 } 3835 // Type SetStatReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 3836 return s.UnmarshalBytes(src) 3837 } 3838 3839 // CopyOutN implements marshal.Marshallable.CopyOutN. 3840 func (s *SetStatReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3841 if !s.Atime.Packed() && s.FD.Packed() && s.GID.Packed() && s.Mtime.Packed() && s.UID.Packed() { 3842 // Type SetStatReq doesn't have a packed layout in memory, fall back to MarshalBytes. 3843 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 3844 s.MarshalBytes(buf) // escapes: fallback. 3845 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3846 } 3847 3848 // Construct a slice backed by dst's underlying memory. 3849 var buf []byte 3850 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3851 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 3852 hdr.Len = s.SizeBytes() 3853 hdr.Cap = s.SizeBytes() 3854 3855 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3856 // Since we bypassed the compiler's escape analysis, indicate that s 3857 // must live until the use above. 3858 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 3859 return length, err 3860 } 3861 3862 // CopyOut implements marshal.Marshallable.CopyOut. 3863 func (s *SetStatReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3864 return s.CopyOutN(cc, addr, s.SizeBytes()) 3865 } 3866 3867 // CopyInN implements marshal.Marshallable.CopyInN. 3868 func (s *SetStatReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3869 if !s.Atime.Packed() && s.FD.Packed() && s.GID.Packed() && s.Mtime.Packed() && s.UID.Packed() { 3870 // Type SetStatReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 3871 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 3872 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3873 // Unmarshal unconditionally. If we had a short copy-in, this results in a 3874 // partially unmarshalled struct. 3875 s.UnmarshalBytes(buf) // escapes: fallback. 3876 return length, err 3877 } 3878 3879 // Construct a slice backed by dst's underlying memory. 3880 var buf []byte 3881 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3882 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 3883 hdr.Len = s.SizeBytes() 3884 hdr.Cap = s.SizeBytes() 3885 3886 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 3887 // Since we bypassed the compiler's escape analysis, indicate that s 3888 // must live until the use above. 3889 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 3890 return length, err 3891 } 3892 3893 // CopyIn implements marshal.Marshallable.CopyIn. 3894 func (s *SetStatReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3895 return s.CopyInN(cc, addr, s.SizeBytes()) 3896 } 3897 3898 // WriteTo implements io.WriterTo.WriteTo. 3899 func (s *SetStatReq) WriteTo(writer io.Writer) (int64, error) { 3900 if !s.Atime.Packed() && s.FD.Packed() && s.GID.Packed() && s.Mtime.Packed() && s.UID.Packed() { 3901 // Type SetStatReq doesn't have a packed layout in memory, fall back to MarshalBytes. 3902 buf := make([]byte, s.SizeBytes()) 3903 s.MarshalBytes(buf) 3904 length, err := writer.Write(buf) 3905 return int64(length), err 3906 } 3907 3908 // Construct a slice backed by dst's underlying memory. 3909 var buf []byte 3910 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3911 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 3912 hdr.Len = s.SizeBytes() 3913 hdr.Cap = s.SizeBytes() 3914 3915 length, err := writer.Write(buf) 3916 // Since we bypassed the compiler's escape analysis, indicate that s 3917 // must live until the use above. 3918 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 3919 return int64(length), err 3920 } 3921 3922 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 3923 func (s *SetStatReq) CheckedMarshal(dst []byte) ([]byte, bool) { 3924 if s.SizeBytes() > len(dst) { 3925 return dst, false 3926 } 3927 return s.MarshalUnsafe(dst), true 3928 } 3929 3930 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 3931 func (s *SetStatReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 3932 if s.SizeBytes() > len(src) { 3933 return src, false 3934 } 3935 return s.UnmarshalUnsafe(src), true 3936 } 3937 3938 // SizeBytes implements marshal.Marshallable.SizeBytes. 3939 func (s *SetStatResp) SizeBytes() int { 3940 return 8 3941 } 3942 3943 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 3944 func (s *SetStatResp) MarshalBytes(dst []byte) []byte { 3945 hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.FailureMask)) 3946 dst = dst[4:] 3947 hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.FailureErrNo)) 3948 dst = dst[4:] 3949 return dst 3950 } 3951 3952 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 3953 func (s *SetStatResp) UnmarshalBytes(src []byte) []byte { 3954 s.FailureMask = uint32(hostarch.ByteOrder.Uint32(src[:4])) 3955 src = src[4:] 3956 s.FailureErrNo = uint32(hostarch.ByteOrder.Uint32(src[:4])) 3957 src = src[4:] 3958 return src 3959 } 3960 3961 // Packed implements marshal.Marshallable.Packed. 3962 //go:nosplit 3963 func (s *SetStatResp) Packed() bool { 3964 return true 3965 } 3966 3967 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 3968 func (s *SetStatResp) MarshalUnsafe(dst []byte) []byte { 3969 size := s.SizeBytes() 3970 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 3971 return dst[size:] 3972 } 3973 3974 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 3975 func (s *SetStatResp) UnmarshalUnsafe(src []byte) []byte { 3976 size := s.SizeBytes() 3977 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 3978 return src[size:] 3979 } 3980 3981 // CopyOutN implements marshal.Marshallable.CopyOutN. 3982 func (s *SetStatResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 3983 // Construct a slice backed by dst's underlying memory. 3984 var buf []byte 3985 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 3986 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 3987 hdr.Len = s.SizeBytes() 3988 hdr.Cap = s.SizeBytes() 3989 3990 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 3991 // Since we bypassed the compiler's escape analysis, indicate that s 3992 // must live until the use above. 3993 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 3994 return length, err 3995 } 3996 3997 // CopyOut implements marshal.Marshallable.CopyOut. 3998 func (s *SetStatResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 3999 return s.CopyOutN(cc, addr, s.SizeBytes()) 4000 } 4001 4002 // CopyInN implements marshal.Marshallable.CopyInN. 4003 func (s *SetStatResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4004 // Construct a slice backed by dst's underlying memory. 4005 var buf []byte 4006 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4007 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4008 hdr.Len = s.SizeBytes() 4009 hdr.Cap = s.SizeBytes() 4010 4011 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4012 // Since we bypassed the compiler's escape analysis, indicate that s 4013 // must live until the use above. 4014 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4015 return length, err 4016 } 4017 4018 // CopyIn implements marshal.Marshallable.CopyIn. 4019 func (s *SetStatResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4020 return s.CopyInN(cc, addr, s.SizeBytes()) 4021 } 4022 4023 // WriteTo implements io.WriterTo.WriteTo. 4024 func (s *SetStatResp) WriteTo(writer io.Writer) (int64, error) { 4025 // Construct a slice backed by dst's underlying memory. 4026 var buf []byte 4027 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4028 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4029 hdr.Len = s.SizeBytes() 4030 hdr.Cap = s.SizeBytes() 4031 4032 length, err := writer.Write(buf) 4033 // Since we bypassed the compiler's escape analysis, indicate that s 4034 // must live until the use above. 4035 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4036 return int64(length), err 4037 } 4038 4039 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 4040 func (s *SetStatResp) CheckedMarshal(dst []byte) ([]byte, bool) { 4041 if s.SizeBytes() > len(dst) { 4042 return dst, false 4043 } 4044 return s.MarshalUnsafe(dst), true 4045 } 4046 4047 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 4048 func (s *SetStatResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 4049 if s.SizeBytes() > len(src) { 4050 return src, false 4051 } 4052 return s.UnmarshalUnsafe(src), true 4053 } 4054 4055 // SizeBytes implements marshal.Marshallable.SizeBytes. 4056 func (s *StatFS) SizeBytes() int { 4057 return 64 4058 } 4059 4060 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 4061 func (s *StatFS) MarshalBytes(dst []byte) []byte { 4062 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Type)) 4063 dst = dst[8:] 4064 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.BlockSize)) 4065 dst = dst[8:] 4066 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Blocks)) 4067 dst = dst[8:] 4068 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.BlocksFree)) 4069 dst = dst[8:] 4070 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.BlocksAvailable)) 4071 dst = dst[8:] 4072 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.Files)) 4073 dst = dst[8:] 4074 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.FilesFree)) 4075 dst = dst[8:] 4076 hostarch.ByteOrder.PutUint64(dst[:8], uint64(s.NameLength)) 4077 dst = dst[8:] 4078 return dst 4079 } 4080 4081 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 4082 func (s *StatFS) UnmarshalBytes(src []byte) []byte { 4083 s.Type = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4084 src = src[8:] 4085 s.BlockSize = int64(hostarch.ByteOrder.Uint64(src[:8])) 4086 src = src[8:] 4087 s.Blocks = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4088 src = src[8:] 4089 s.BlocksFree = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4090 src = src[8:] 4091 s.BlocksAvailable = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4092 src = src[8:] 4093 s.Files = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4094 src = src[8:] 4095 s.FilesFree = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4096 src = src[8:] 4097 s.NameLength = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4098 src = src[8:] 4099 return src 4100 } 4101 4102 // Packed implements marshal.Marshallable.Packed. 4103 //go:nosplit 4104 func (s *StatFS) Packed() bool { 4105 return true 4106 } 4107 4108 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 4109 func (s *StatFS) MarshalUnsafe(dst []byte) []byte { 4110 size := s.SizeBytes() 4111 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 4112 return dst[size:] 4113 } 4114 4115 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 4116 func (s *StatFS) UnmarshalUnsafe(src []byte) []byte { 4117 size := s.SizeBytes() 4118 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 4119 return src[size:] 4120 } 4121 4122 // CopyOutN implements marshal.Marshallable.CopyOutN. 4123 func (s *StatFS) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4124 // Construct a slice backed by dst's underlying memory. 4125 var buf []byte 4126 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4127 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4128 hdr.Len = s.SizeBytes() 4129 hdr.Cap = s.SizeBytes() 4130 4131 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4132 // Since we bypassed the compiler's escape analysis, indicate that s 4133 // must live until the use above. 4134 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4135 return length, err 4136 } 4137 4138 // CopyOut implements marshal.Marshallable.CopyOut. 4139 func (s *StatFS) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4140 return s.CopyOutN(cc, addr, s.SizeBytes()) 4141 } 4142 4143 // CopyInN implements marshal.Marshallable.CopyInN. 4144 func (s *StatFS) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4145 // Construct a slice backed by dst's underlying memory. 4146 var buf []byte 4147 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4148 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4149 hdr.Len = s.SizeBytes() 4150 hdr.Cap = s.SizeBytes() 4151 4152 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4153 // Since we bypassed the compiler's escape analysis, indicate that s 4154 // must live until the use above. 4155 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4156 return length, err 4157 } 4158 4159 // CopyIn implements marshal.Marshallable.CopyIn. 4160 func (s *StatFS) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4161 return s.CopyInN(cc, addr, s.SizeBytes()) 4162 } 4163 4164 // WriteTo implements io.WriterTo.WriteTo. 4165 func (s *StatFS) WriteTo(writer io.Writer) (int64, error) { 4166 // Construct a slice backed by dst's underlying memory. 4167 var buf []byte 4168 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4169 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4170 hdr.Len = s.SizeBytes() 4171 hdr.Cap = s.SizeBytes() 4172 4173 length, err := writer.Write(buf) 4174 // Since we bypassed the compiler's escape analysis, indicate that s 4175 // must live until the use above. 4176 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4177 return int64(length), err 4178 } 4179 4180 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 4181 func (s *StatFS) CheckedMarshal(dst []byte) ([]byte, bool) { 4182 if s.SizeBytes() > len(dst) { 4183 return dst, false 4184 } 4185 return s.MarshalUnsafe(dst), true 4186 } 4187 4188 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 4189 func (s *StatFS) CheckedUnmarshal(src []byte) ([]byte, bool) { 4190 if s.SizeBytes() > len(src) { 4191 return src, false 4192 } 4193 return s.UnmarshalUnsafe(src), true 4194 } 4195 4196 // SizeBytes implements marshal.Marshallable.SizeBytes. 4197 func (s *StatReq) SizeBytes() int { 4198 return 0 + 4199 (*FDID)(nil).SizeBytes() 4200 } 4201 4202 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 4203 func (s *StatReq) MarshalBytes(dst []byte) []byte { 4204 dst = s.FD.MarshalUnsafe(dst) 4205 return dst 4206 } 4207 4208 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 4209 func (s *StatReq) UnmarshalBytes(src []byte) []byte { 4210 src = s.FD.UnmarshalUnsafe(src) 4211 return src 4212 } 4213 4214 // Packed implements marshal.Marshallable.Packed. 4215 //go:nosplit 4216 func (s *StatReq) Packed() bool { 4217 return s.FD.Packed() 4218 } 4219 4220 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 4221 func (s *StatReq) MarshalUnsafe(dst []byte) []byte { 4222 if s.FD.Packed() { 4223 size := s.SizeBytes() 4224 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 4225 return dst[size:] 4226 } 4227 // Type StatReq doesn't have a packed layout in memory, fallback to MarshalBytes. 4228 return s.MarshalBytes(dst) 4229 } 4230 4231 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 4232 func (s *StatReq) UnmarshalUnsafe(src []byte) []byte { 4233 if s.FD.Packed() { 4234 size := s.SizeBytes() 4235 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 4236 return src[size:] 4237 } 4238 // Type StatReq doesn't have a packed layout in memory, fallback to UnmarshalBytes. 4239 return s.UnmarshalBytes(src) 4240 } 4241 4242 // CopyOutN implements marshal.Marshallable.CopyOutN. 4243 func (s *StatReq) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4244 if !s.FD.Packed() { 4245 // Type StatReq doesn't have a packed layout in memory, fall back to MarshalBytes. 4246 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 4247 s.MarshalBytes(buf) // escapes: fallback. 4248 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4249 } 4250 4251 // Construct a slice backed by dst's underlying memory. 4252 var buf []byte 4253 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4254 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4255 hdr.Len = s.SizeBytes() 4256 hdr.Cap = s.SizeBytes() 4257 4258 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4259 // Since we bypassed the compiler's escape analysis, indicate that s 4260 // must live until the use above. 4261 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4262 return length, err 4263 } 4264 4265 // CopyOut implements marshal.Marshallable.CopyOut. 4266 func (s *StatReq) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4267 return s.CopyOutN(cc, addr, s.SizeBytes()) 4268 } 4269 4270 // CopyInN implements marshal.Marshallable.CopyInN. 4271 func (s *StatReq) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4272 if !s.FD.Packed() { 4273 // Type StatReq doesn't have a packed layout in memory, fall back to UnmarshalBytes. 4274 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 4275 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4276 // Unmarshal unconditionally. If we had a short copy-in, this results in a 4277 // partially unmarshalled struct. 4278 s.UnmarshalBytes(buf) // escapes: fallback. 4279 return length, err 4280 } 4281 4282 // Construct a slice backed by dst's underlying memory. 4283 var buf []byte 4284 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4285 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4286 hdr.Len = s.SizeBytes() 4287 hdr.Cap = s.SizeBytes() 4288 4289 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4290 // Since we bypassed the compiler's escape analysis, indicate that s 4291 // must live until the use above. 4292 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4293 return length, err 4294 } 4295 4296 // CopyIn implements marshal.Marshallable.CopyIn. 4297 func (s *StatReq) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4298 return s.CopyInN(cc, addr, s.SizeBytes()) 4299 } 4300 4301 // WriteTo implements io.WriterTo.WriteTo. 4302 func (s *StatReq) WriteTo(writer io.Writer) (int64, error) { 4303 if !s.FD.Packed() { 4304 // Type StatReq doesn't have a packed layout in memory, fall back to MarshalBytes. 4305 buf := make([]byte, s.SizeBytes()) 4306 s.MarshalBytes(buf) 4307 length, err := writer.Write(buf) 4308 return int64(length), err 4309 } 4310 4311 // Construct a slice backed by dst's underlying memory. 4312 var buf []byte 4313 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4314 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4315 hdr.Len = s.SizeBytes() 4316 hdr.Cap = s.SizeBytes() 4317 4318 length, err := writer.Write(buf) 4319 // Since we bypassed the compiler's escape analysis, indicate that s 4320 // must live until the use above. 4321 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4322 return int64(length), err 4323 } 4324 4325 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 4326 func (s *StatReq) CheckedMarshal(dst []byte) ([]byte, bool) { 4327 if s.SizeBytes() > len(dst) { 4328 return dst, false 4329 } 4330 return s.MarshalUnsafe(dst), true 4331 } 4332 4333 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 4334 func (s *StatReq) CheckedUnmarshal(src []byte) ([]byte, bool) { 4335 if s.SizeBytes() > len(src) { 4336 return src, false 4337 } 4338 return s.UnmarshalUnsafe(src), true 4339 } 4340 4341 // SizeBytes implements marshal.Marshallable.SizeBytes. 4342 func (s *SymlinkAtResp) SizeBytes() int { 4343 return 0 + 4344 (*Inode)(nil).SizeBytes() 4345 } 4346 4347 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 4348 func (s *SymlinkAtResp) MarshalBytes(dst []byte) []byte { 4349 dst = s.Symlink.MarshalUnsafe(dst) 4350 return dst 4351 } 4352 4353 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 4354 func (s *SymlinkAtResp) UnmarshalBytes(src []byte) []byte { 4355 src = s.Symlink.UnmarshalUnsafe(src) 4356 return src 4357 } 4358 4359 // Packed implements marshal.Marshallable.Packed. 4360 //go:nosplit 4361 func (s *SymlinkAtResp) Packed() bool { 4362 return s.Symlink.Packed() 4363 } 4364 4365 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 4366 func (s *SymlinkAtResp) MarshalUnsafe(dst []byte) []byte { 4367 if s.Symlink.Packed() { 4368 size := s.SizeBytes() 4369 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 4370 return dst[size:] 4371 } 4372 // Type SymlinkAtResp doesn't have a packed layout in memory, fallback to MarshalBytes. 4373 return s.MarshalBytes(dst) 4374 } 4375 4376 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 4377 func (s *SymlinkAtResp) UnmarshalUnsafe(src []byte) []byte { 4378 if s.Symlink.Packed() { 4379 size := s.SizeBytes() 4380 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 4381 return src[size:] 4382 } 4383 // Type SymlinkAtResp doesn't have a packed layout in memory, fallback to UnmarshalBytes. 4384 return s.UnmarshalBytes(src) 4385 } 4386 4387 // CopyOutN implements marshal.Marshallable.CopyOutN. 4388 func (s *SymlinkAtResp) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4389 if !s.Symlink.Packed() { 4390 // Type SymlinkAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 4391 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 4392 s.MarshalBytes(buf) // escapes: fallback. 4393 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4394 } 4395 4396 // Construct a slice backed by dst's underlying memory. 4397 var buf []byte 4398 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4399 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4400 hdr.Len = s.SizeBytes() 4401 hdr.Cap = s.SizeBytes() 4402 4403 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4404 // Since we bypassed the compiler's escape analysis, indicate that s 4405 // must live until the use above. 4406 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4407 return length, err 4408 } 4409 4410 // CopyOut implements marshal.Marshallable.CopyOut. 4411 func (s *SymlinkAtResp) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4412 return s.CopyOutN(cc, addr, s.SizeBytes()) 4413 } 4414 4415 // CopyInN implements marshal.Marshallable.CopyInN. 4416 func (s *SymlinkAtResp) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4417 if !s.Symlink.Packed() { 4418 // Type SymlinkAtResp doesn't have a packed layout in memory, fall back to UnmarshalBytes. 4419 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 4420 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4421 // Unmarshal unconditionally. If we had a short copy-in, this results in a 4422 // partially unmarshalled struct. 4423 s.UnmarshalBytes(buf) // escapes: fallback. 4424 return length, err 4425 } 4426 4427 // Construct a slice backed by dst's underlying memory. 4428 var buf []byte 4429 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4430 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4431 hdr.Len = s.SizeBytes() 4432 hdr.Cap = s.SizeBytes() 4433 4434 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4435 // Since we bypassed the compiler's escape analysis, indicate that s 4436 // must live until the use above. 4437 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4438 return length, err 4439 } 4440 4441 // CopyIn implements marshal.Marshallable.CopyIn. 4442 func (s *SymlinkAtResp) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4443 return s.CopyInN(cc, addr, s.SizeBytes()) 4444 } 4445 4446 // WriteTo implements io.WriterTo.WriteTo. 4447 func (s *SymlinkAtResp) WriteTo(writer io.Writer) (int64, error) { 4448 if !s.Symlink.Packed() { 4449 // Type SymlinkAtResp doesn't have a packed layout in memory, fall back to MarshalBytes. 4450 buf := make([]byte, s.SizeBytes()) 4451 s.MarshalBytes(buf) 4452 length, err := writer.Write(buf) 4453 return int64(length), err 4454 } 4455 4456 // Construct a slice backed by dst's underlying memory. 4457 var buf []byte 4458 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4459 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 4460 hdr.Len = s.SizeBytes() 4461 hdr.Cap = s.SizeBytes() 4462 4463 length, err := writer.Write(buf) 4464 // Since we bypassed the compiler's escape analysis, indicate that s 4465 // must live until the use above. 4466 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 4467 return int64(length), err 4468 } 4469 4470 // CheckedMarshal implements marshal.CheckedMarshallable.CheckedMarshal. 4471 func (s *SymlinkAtResp) CheckedMarshal(dst []byte) ([]byte, bool) { 4472 if s.SizeBytes() > len(dst) { 4473 return dst, false 4474 } 4475 return s.MarshalUnsafe(dst), true 4476 } 4477 4478 // CheckedUnmarshal implements marshal.CheckedMarshallable.CheckedUnmarshal. 4479 func (s *SymlinkAtResp) CheckedUnmarshal(src []byte) ([]byte, bool) { 4480 if s.SizeBytes() > len(src) { 4481 return src, false 4482 } 4483 return s.UnmarshalUnsafe(src), true 4484 } 4485 4486 // SizeBytes implements marshal.Marshallable.SizeBytes. 4487 //go:nosplit 4488 func (uid *UID) SizeBytes() int { 4489 return 4 4490 } 4491 4492 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 4493 func (uid *UID) MarshalBytes(dst []byte) []byte { 4494 hostarch.ByteOrder.PutUint32(dst[:4], uint32(*uid)) 4495 return dst[4:] 4496 } 4497 4498 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 4499 func (uid *UID) UnmarshalBytes(src []byte) []byte { 4500 *uid = UID(uint32(hostarch.ByteOrder.Uint32(src[:4]))) 4501 return src[4:] 4502 } 4503 4504 // Packed implements marshal.Marshallable.Packed. 4505 //go:nosplit 4506 func (uid *UID) Packed() bool { 4507 // Scalar newtypes are always packed. 4508 return true 4509 } 4510 4511 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 4512 func (uid *UID) MarshalUnsafe(dst []byte) []byte { 4513 size := uid.SizeBytes() 4514 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(uid), uintptr(size)) 4515 return dst[size:] 4516 } 4517 4518 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 4519 func (uid *UID) UnmarshalUnsafe(src []byte) []byte { 4520 size := uid.SizeBytes() 4521 gohacks.Memmove(unsafe.Pointer(uid), unsafe.Pointer(&src[0]), uintptr(size)) 4522 return src[size:] 4523 } 4524 4525 // CopyOutN implements marshal.Marshallable.CopyOutN. 4526 func (uid *UID) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4527 // Construct a slice backed by dst's underlying memory. 4528 var buf []byte 4529 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4530 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(uid))) 4531 hdr.Len = uid.SizeBytes() 4532 hdr.Cap = uid.SizeBytes() 4533 4534 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4535 // Since we bypassed the compiler's escape analysis, indicate that uid 4536 // must live until the use above. 4537 runtime.KeepAlive(uid) // escapes: replaced by intrinsic. 4538 return length, err 4539 } 4540 4541 // CopyOut implements marshal.Marshallable.CopyOut. 4542 func (uid *UID) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4543 return uid.CopyOutN(cc, addr, uid.SizeBytes()) 4544 } 4545 4546 // CopyInN implements marshal.Marshallable.CopyInN. 4547 func (uid *UID) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4548 // Construct a slice backed by dst's underlying memory. 4549 var buf []byte 4550 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4551 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(uid))) 4552 hdr.Len = uid.SizeBytes() 4553 hdr.Cap = uid.SizeBytes() 4554 4555 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4556 // Since we bypassed the compiler's escape analysis, indicate that uid 4557 // must live until the use above. 4558 runtime.KeepAlive(uid) // escapes: replaced by intrinsic. 4559 return length, err 4560 } 4561 4562 // CopyIn implements marshal.Marshallable.CopyIn. 4563 func (uid *UID) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4564 return uid.CopyInN(cc, addr, uid.SizeBytes()) 4565 } 4566 4567 // WriteTo implements io.WriterTo.WriteTo. 4568 func (uid *UID) WriteTo(writer io.Writer) (int64, error) { 4569 // Construct a slice backed by dst's underlying memory. 4570 var buf []byte 4571 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4572 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(uid))) 4573 hdr.Len = uid.SizeBytes() 4574 hdr.Cap = uid.SizeBytes() 4575 4576 length, err := writer.Write(buf) 4577 // Since we bypassed the compiler's escape analysis, indicate that uid 4578 // must live until the use above. 4579 runtime.KeepAlive(uid) // escapes: replaced by intrinsic. 4580 return int64(length), err 4581 } 4582 4583 // SizeBytes implements marshal.Marshallable.SizeBytes. 4584 func (c *createCommon) SizeBytes() int { 4585 return 6 + 4586 (*FDID)(nil).SizeBytes() + 4587 (*UID)(nil).SizeBytes() + 4588 (*GID)(nil).SizeBytes() + 4589 (*linux.FileMode)(nil).SizeBytes() 4590 } 4591 4592 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 4593 func (c *createCommon) MarshalBytes(dst []byte) []byte { 4594 dst = c.DirFD.MarshalUnsafe(dst) 4595 dst = c.UID.MarshalUnsafe(dst) 4596 dst = c.GID.MarshalUnsafe(dst) 4597 dst = c.Mode.MarshalUnsafe(dst) 4598 // Padding: dst[:sizeof(uint16)] ~= uint16(0) 4599 dst = dst[2:] 4600 // Padding: dst[:sizeof(uint32)] ~= uint32(0) 4601 dst = dst[4:] 4602 return dst 4603 } 4604 4605 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 4606 func (c *createCommon) UnmarshalBytes(src []byte) []byte { 4607 src = c.DirFD.UnmarshalUnsafe(src) 4608 src = c.UID.UnmarshalUnsafe(src) 4609 src = c.GID.UnmarshalUnsafe(src) 4610 src = c.Mode.UnmarshalUnsafe(src) 4611 // Padding: var _ uint16 ~= src[:sizeof(uint16)] 4612 src = src[2:] 4613 // Padding: var _ uint32 ~= src[:sizeof(uint32)] 4614 src = src[4:] 4615 return src 4616 } 4617 4618 // Packed implements marshal.Marshallable.Packed. 4619 //go:nosplit 4620 func (c *createCommon) Packed() bool { 4621 return c.DirFD.Packed() && c.GID.Packed() && c.Mode.Packed() && c.UID.Packed() 4622 } 4623 4624 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 4625 func (c *createCommon) MarshalUnsafe(dst []byte) []byte { 4626 if c.DirFD.Packed() && c.GID.Packed() && c.Mode.Packed() && c.UID.Packed() { 4627 size := c.SizeBytes() 4628 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(c), uintptr(size)) 4629 return dst[size:] 4630 } 4631 // Type createCommon doesn't have a packed layout in memory, fallback to MarshalBytes. 4632 return c.MarshalBytes(dst) 4633 } 4634 4635 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 4636 func (c *createCommon) UnmarshalUnsafe(src []byte) []byte { 4637 if c.DirFD.Packed() && c.GID.Packed() && c.Mode.Packed() && c.UID.Packed() { 4638 size := c.SizeBytes() 4639 gohacks.Memmove(unsafe.Pointer(c), unsafe.Pointer(&src[0]), uintptr(size)) 4640 return src[size:] 4641 } 4642 // Type createCommon doesn't have a packed layout in memory, fallback to UnmarshalBytes. 4643 return c.UnmarshalBytes(src) 4644 } 4645 4646 // CopyOutN implements marshal.Marshallable.CopyOutN. 4647 func (c *createCommon) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4648 if !c.DirFD.Packed() && c.GID.Packed() && c.Mode.Packed() && c.UID.Packed() { 4649 // Type createCommon doesn't have a packed layout in memory, fall back to MarshalBytes. 4650 buf := cc.CopyScratchBuffer(c.SizeBytes()) // escapes: okay. 4651 c.MarshalBytes(buf) // escapes: fallback. 4652 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4653 } 4654 4655 // Construct a slice backed by dst's underlying memory. 4656 var buf []byte 4657 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4658 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 4659 hdr.Len = c.SizeBytes() 4660 hdr.Cap = c.SizeBytes() 4661 4662 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4663 // Since we bypassed the compiler's escape analysis, indicate that c 4664 // must live until the use above. 4665 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 4666 return length, err 4667 } 4668 4669 // CopyOut implements marshal.Marshallable.CopyOut. 4670 func (c *createCommon) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4671 return c.CopyOutN(cc, addr, c.SizeBytes()) 4672 } 4673 4674 // CopyInN implements marshal.Marshallable.CopyInN. 4675 func (c *createCommon) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4676 if !c.DirFD.Packed() && c.GID.Packed() && c.Mode.Packed() && c.UID.Packed() { 4677 // Type createCommon doesn't have a packed layout in memory, fall back to UnmarshalBytes. 4678 buf := cc.CopyScratchBuffer(c.SizeBytes()) // escapes: okay. 4679 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4680 // Unmarshal unconditionally. If we had a short copy-in, this results in a 4681 // partially unmarshalled struct. 4682 c.UnmarshalBytes(buf) // escapes: fallback. 4683 return length, err 4684 } 4685 4686 // Construct a slice backed by dst's underlying memory. 4687 var buf []byte 4688 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4689 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 4690 hdr.Len = c.SizeBytes() 4691 hdr.Cap = c.SizeBytes() 4692 4693 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4694 // Since we bypassed the compiler's escape analysis, indicate that c 4695 // must live until the use above. 4696 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 4697 return length, err 4698 } 4699 4700 // CopyIn implements marshal.Marshallable.CopyIn. 4701 func (c *createCommon) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4702 return c.CopyInN(cc, addr, c.SizeBytes()) 4703 } 4704 4705 // WriteTo implements io.WriterTo.WriteTo. 4706 func (c *createCommon) WriteTo(writer io.Writer) (int64, error) { 4707 if !c.DirFD.Packed() && c.GID.Packed() && c.Mode.Packed() && c.UID.Packed() { 4708 // Type createCommon doesn't have a packed layout in memory, fall back to MarshalBytes. 4709 buf := make([]byte, c.SizeBytes()) 4710 c.MarshalBytes(buf) 4711 length, err := writer.Write(buf) 4712 return int64(length), err 4713 } 4714 4715 // Construct a slice backed by dst's underlying memory. 4716 var buf []byte 4717 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4718 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(c))) 4719 hdr.Len = c.SizeBytes() 4720 hdr.Cap = c.SizeBytes() 4721 4722 length, err := writer.Write(buf) 4723 // Since we bypassed the compiler's escape analysis, indicate that c 4724 // must live until the use above. 4725 runtime.KeepAlive(c) // escapes: replaced by intrinsic. 4726 return int64(length), err 4727 } 4728 4729 // Packed implements marshal.Marshallable.Packed. 4730 //go:nosplit 4731 func (m *MsgDynamic) Packed() bool { 4732 // Type MsgDynamic is dynamic so it might have slice/string headers. Hence, it is not packed. 4733 return false 4734 } 4735 4736 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 4737 func (m *MsgDynamic) MarshalUnsafe(dst []byte) []byte { 4738 // Type MsgDynamic doesn't have a packed layout in memory, fallback to MarshalBytes. 4739 return m.MarshalBytes(dst) 4740 } 4741 4742 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 4743 func (m *MsgDynamic) UnmarshalUnsafe(src []byte) []byte { 4744 // Type MsgDynamic doesn't have a packed layout in memory, fallback to UnmarshalBytes. 4745 return m.UnmarshalBytes(src) 4746 } 4747 4748 // CopyOutN implements marshal.Marshallable.CopyOutN. 4749 //go:nosplit 4750 func (m *MsgDynamic) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4751 // Type MsgDynamic doesn't have a packed layout in memory, fall back to MarshalBytes. 4752 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 4753 m.MarshalBytes(buf) // escapes: fallback. 4754 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4755 } 4756 4757 // CopyOut implements marshal.Marshallable.CopyOut. 4758 func (m *MsgDynamic) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4759 return m.CopyOutN(cc, addr, m.SizeBytes()) 4760 } 4761 4762 // CopyInN implements marshal.Marshallable.CopyInN. 4763 //go:nosplit 4764 func (m *MsgDynamic) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4765 // Type MsgDynamic doesn't have a packed layout in memory, fall back to UnmarshalBytes. 4766 buf := cc.CopyScratchBuffer(m.SizeBytes()) // escapes: okay. 4767 length, err := cc.CopyInBytes(addr, buf) // escapes: okay. 4768 // Unmarshal unconditionally. If we had a short copy-in, this results in a 4769 // partially unmarshalled struct. 4770 m.UnmarshalBytes(buf) // escapes: fallback. 4771 return length, err 4772 } 4773 4774 // CopyIn implements marshal.Marshallable.CopyIn. 4775 func (m *MsgDynamic) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4776 return m.CopyInN(cc, addr, m.SizeBytes()) 4777 } 4778 4779 // WriteTo implements io.WriterTo.WriteTo. 4780 func (m *MsgDynamic) WriteTo(writer io.Writer) (int64, error) { 4781 // Type MsgDynamic doesn't have a packed layout in memory, fall back to MarshalBytes. 4782 buf := make([]byte, m.SizeBytes()) 4783 m.MarshalBytes(buf) 4784 length, err := writer.Write(buf) 4785 return int64(length), err 4786 } 4787 4788 // SizeBytes implements marshal.Marshallable.SizeBytes. 4789 func (m *MsgSimple) SizeBytes() int { 4790 return 16 4791 } 4792 4793 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 4794 func (m *MsgSimple) MarshalBytes(dst []byte) []byte { 4795 hostarch.ByteOrder.PutUint16(dst[:2], uint16(m.A)) 4796 dst = dst[2:] 4797 hostarch.ByteOrder.PutUint16(dst[:2], uint16(m.B)) 4798 dst = dst[2:] 4799 hostarch.ByteOrder.PutUint32(dst[:4], uint32(m.C)) 4800 dst = dst[4:] 4801 hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.D)) 4802 dst = dst[8:] 4803 return dst 4804 } 4805 4806 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 4807 func (m *MsgSimple) UnmarshalBytes(src []byte) []byte { 4808 m.A = uint16(hostarch.ByteOrder.Uint16(src[:2])) 4809 src = src[2:] 4810 m.B = uint16(hostarch.ByteOrder.Uint16(src[:2])) 4811 src = src[2:] 4812 m.C = uint32(hostarch.ByteOrder.Uint32(src[:4])) 4813 src = src[4:] 4814 m.D = uint64(hostarch.ByteOrder.Uint64(src[:8])) 4815 src = src[8:] 4816 return src 4817 } 4818 4819 // Packed implements marshal.Marshallable.Packed. 4820 //go:nosplit 4821 func (m *MsgSimple) Packed() bool { 4822 return true 4823 } 4824 4825 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 4826 func (m *MsgSimple) MarshalUnsafe(dst []byte) []byte { 4827 size := m.SizeBytes() 4828 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(size)) 4829 return dst[size:] 4830 } 4831 4832 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 4833 func (m *MsgSimple) UnmarshalUnsafe(src []byte) []byte { 4834 size := m.SizeBytes() 4835 gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(size)) 4836 return src[size:] 4837 } 4838 4839 // CopyOutN implements marshal.Marshallable.CopyOutN. 4840 func (m *MsgSimple) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4841 // Construct a slice backed by dst's underlying memory. 4842 var buf []byte 4843 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4844 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 4845 hdr.Len = m.SizeBytes() 4846 hdr.Cap = m.SizeBytes() 4847 4848 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 4849 // Since we bypassed the compiler's escape analysis, indicate that m 4850 // must live until the use above. 4851 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 4852 return length, err 4853 } 4854 4855 // CopyOut implements marshal.Marshallable.CopyOut. 4856 func (m *MsgSimple) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4857 return m.CopyOutN(cc, addr, m.SizeBytes()) 4858 } 4859 4860 // CopyInN implements marshal.Marshallable.CopyInN. 4861 func (m *MsgSimple) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 4862 // Construct a slice backed by dst's underlying memory. 4863 var buf []byte 4864 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4865 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 4866 hdr.Len = m.SizeBytes() 4867 hdr.Cap = m.SizeBytes() 4868 4869 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 4870 // Since we bypassed the compiler's escape analysis, indicate that m 4871 // must live until the use above. 4872 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 4873 return length, err 4874 } 4875 4876 // CopyIn implements marshal.Marshallable.CopyIn. 4877 func (m *MsgSimple) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 4878 return m.CopyInN(cc, addr, m.SizeBytes()) 4879 } 4880 4881 // WriteTo implements io.WriterTo.WriteTo. 4882 func (m *MsgSimple) WriteTo(writer io.Writer) (int64, error) { 4883 // Construct a slice backed by dst's underlying memory. 4884 var buf []byte 4885 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4886 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m))) 4887 hdr.Len = m.SizeBytes() 4888 hdr.Cap = m.SizeBytes() 4889 4890 length, err := writer.Write(buf) 4891 // Since we bypassed the compiler's escape analysis, indicate that m 4892 // must live until the use above. 4893 runtime.KeepAlive(m) // escapes: replaced by intrinsic. 4894 return int64(length), err 4895 } 4896 4897 // CopyMsg1SliceIn copies in a slice of MsgSimple objects from the task's memory. 4898 func CopyMsg1SliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []MsgSimple) (int, error) { 4899 count := len(dst) 4900 if count == 0 { 4901 return 0, nil 4902 } 4903 size := (*MsgSimple)(nil).SizeBytes() 4904 4905 ptr := unsafe.Pointer(&dst) 4906 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 4907 4908 // Construct a slice backed by dst's underlying memory. 4909 var buf []byte 4910 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4911 hdr.Data = uintptr(val) 4912 hdr.Len = size * count 4913 hdr.Cap = size * count 4914 4915 length, err := cc.CopyInBytes(addr, buf) 4916 // Since we bypassed the compiler's escape analysis, indicate that dst 4917 // must live until the use above. 4918 runtime.KeepAlive(dst) // escapes: replaced by intrinsic. 4919 return length, err 4920 } 4921 4922 // CopyMsg1SliceOut copies a slice of MsgSimple objects to the task's memory. 4923 func CopyMsg1SliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []MsgSimple) (int, error) { 4924 count := len(src) 4925 if count == 0 { 4926 return 0, nil 4927 } 4928 size := (*MsgSimple)(nil).SizeBytes() 4929 4930 ptr := unsafe.Pointer(&src) 4931 val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data)) 4932 4933 // Construct a slice backed by dst's underlying memory. 4934 var buf []byte 4935 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 4936 hdr.Data = uintptr(val) 4937 hdr.Len = size * count 4938 hdr.Cap = size * count 4939 4940 length, err := cc.CopyOutBytes(addr, buf) 4941 // Since we bypassed the compiler's escape analysis, indicate that src 4942 // must live until the use above. 4943 runtime.KeepAlive(src) // escapes: replaced by intrinsic. 4944 return length, err 4945 } 4946 4947 // MarshalUnsafeMsg1Slice is like MsgSimple.MarshalUnsafe, but for a []MsgSimple. 4948 func MarshalUnsafeMsg1Slice(src []MsgSimple, dst []byte) []byte { 4949 count := len(src) 4950 if count == 0 { 4951 return dst 4952 } 4953 4954 size := (*MsgSimple)(nil).SizeBytes() 4955 buf := dst[:size*count] 4956 gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf))) 4957 return dst[size*count:] 4958 } 4959 4960 // UnmarshalUnsafeMsg1Slice is like MsgSimple.UnmarshalUnsafe, but for a []MsgSimple. 4961 func UnmarshalUnsafeMsg1Slice(dst []MsgSimple, src []byte) []byte { 4962 count := len(dst) 4963 if count == 0 { 4964 return src 4965 } 4966 4967 size := (*MsgSimple)(nil).SizeBytes() 4968 buf := src[:size*count] 4969 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf))) 4970 return src[size*count:] 4971 } 4972 4973 // SizeBytes implements marshal.Marshallable.SizeBytes. 4974 func (s *sockHeader) SizeBytes() int { 4975 return 6 + 4976 (*MID)(nil).SizeBytes() 4977 } 4978 4979 // MarshalBytes implements marshal.Marshallable.MarshalBytes. 4980 func (s *sockHeader) MarshalBytes(dst []byte) []byte { 4981 hostarch.ByteOrder.PutUint32(dst[:4], uint32(s.payloadLen)) 4982 dst = dst[4:] 4983 dst = s.message.MarshalUnsafe(dst) 4984 // Padding: dst[:sizeof(uint16)] ~= uint16(0) 4985 dst = dst[2:] 4986 return dst 4987 } 4988 4989 // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. 4990 func (s *sockHeader) UnmarshalBytes(src []byte) []byte { 4991 s.payloadLen = uint32(hostarch.ByteOrder.Uint32(src[:4])) 4992 src = src[4:] 4993 src = s.message.UnmarshalUnsafe(src) 4994 // Padding: var _ uint16 ~= src[:sizeof(uint16)] 4995 src = src[2:] 4996 return src 4997 } 4998 4999 // Packed implements marshal.Marshallable.Packed. 5000 //go:nosplit 5001 func (s *sockHeader) Packed() bool { 5002 return s.message.Packed() 5003 } 5004 5005 // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. 5006 func (s *sockHeader) MarshalUnsafe(dst []byte) []byte { 5007 if s.message.Packed() { 5008 size := s.SizeBytes() 5009 gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(s), uintptr(size)) 5010 return dst[size:] 5011 } 5012 // Type sockHeader doesn't have a packed layout in memory, fallback to MarshalBytes. 5013 return s.MarshalBytes(dst) 5014 } 5015 5016 // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. 5017 func (s *sockHeader) UnmarshalUnsafe(src []byte) []byte { 5018 if s.message.Packed() { 5019 size := s.SizeBytes() 5020 gohacks.Memmove(unsafe.Pointer(s), unsafe.Pointer(&src[0]), uintptr(size)) 5021 return src[size:] 5022 } 5023 // Type sockHeader doesn't have a packed layout in memory, fallback to UnmarshalBytes. 5024 return s.UnmarshalBytes(src) 5025 } 5026 5027 // CopyOutN implements marshal.Marshallable.CopyOutN. 5028 func (s *sockHeader) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 5029 if !s.message.Packed() { 5030 // Type sockHeader doesn't have a packed layout in memory, fall back to MarshalBytes. 5031 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 5032 s.MarshalBytes(buf) // escapes: fallback. 5033 return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 5034 } 5035 5036 // Construct a slice backed by dst's underlying memory. 5037 var buf []byte 5038 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 5039 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 5040 hdr.Len = s.SizeBytes() 5041 hdr.Cap = s.SizeBytes() 5042 5043 length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. 5044 // Since we bypassed the compiler's escape analysis, indicate that s 5045 // must live until the use above. 5046 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 5047 return length, err 5048 } 5049 5050 // CopyOut implements marshal.Marshallable.CopyOut. 5051 func (s *sockHeader) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 5052 return s.CopyOutN(cc, addr, s.SizeBytes()) 5053 } 5054 5055 // CopyInN implements marshal.Marshallable.CopyInN. 5056 func (s *sockHeader) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) { 5057 if !s.message.Packed() { 5058 // Type sockHeader doesn't have a packed layout in memory, fall back to UnmarshalBytes. 5059 buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. 5060 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 5061 // Unmarshal unconditionally. If we had a short copy-in, this results in a 5062 // partially unmarshalled struct. 5063 s.UnmarshalBytes(buf) // escapes: fallback. 5064 return length, err 5065 } 5066 5067 // Construct a slice backed by dst's underlying memory. 5068 var buf []byte 5069 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 5070 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 5071 hdr.Len = s.SizeBytes() 5072 hdr.Cap = s.SizeBytes() 5073 5074 length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay. 5075 // Since we bypassed the compiler's escape analysis, indicate that s 5076 // must live until the use above. 5077 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 5078 return length, err 5079 } 5080 5081 // CopyIn implements marshal.Marshallable.CopyIn. 5082 func (s *sockHeader) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) { 5083 return s.CopyInN(cc, addr, s.SizeBytes()) 5084 } 5085 5086 // WriteTo implements io.WriterTo.WriteTo. 5087 func (s *sockHeader) WriteTo(writer io.Writer) (int64, error) { 5088 if !s.message.Packed() { 5089 // Type sockHeader doesn't have a packed layout in memory, fall back to MarshalBytes. 5090 buf := make([]byte, s.SizeBytes()) 5091 s.MarshalBytes(buf) 5092 length, err := writer.Write(buf) 5093 return int64(length), err 5094 } 5095 5096 // Construct a slice backed by dst's underlying memory. 5097 var buf []byte 5098 hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) 5099 hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(s))) 5100 hdr.Len = s.SizeBytes() 5101 hdr.Cap = s.SizeBytes() 5102 5103 length, err := writer.Write(buf) 5104 // Since we bypassed the compiler's escape analysis, indicate that s 5105 // must live until the use above. 5106 runtime.KeepAlive(s) // escapes: replaced by intrinsic. 5107 return int64(length), err 5108 } 5109