inet.af/netstack@v0.0.0-20220214151720-7585b01ddccf/abi/linux/linux_amd64_abi_autogen_unsafe.go (about)

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