github.com/MerlinKodo/gvisor@v0.0.0-20231110090155-957f62ecf90e/pkg/abi/gasket/gasket_abi_autogen_unsafe.go (about)

     1  // Automatically generated marshal implementation. See tools/go_marshal.
     2  
     3  package gasket
     4  
     5  import (
     6      "github.com/MerlinKodo/gvisor/pkg/gohacks"
     7      "github.com/MerlinKodo/gvisor/pkg/hostarch"
     8      "github.com/MerlinKodo/gvisor/pkg/marshal"
     9      "io"
    10      "reflect"
    11      "runtime"
    12      "unsafe"
    13  )
    14  
    15  // Marshallable types used by this file.
    16  var _ marshal.Marshallable = (*GasketInterruptEventFd)(nil)
    17  var _ marshal.Marshallable = (*GasketInterruptMapping)(nil)
    18  var _ marshal.Marshallable = (*GasketPageTableDmaBufIoctl)(nil)
    19  var _ marshal.Marshallable = (*GasketPageTableIoctl)(nil)
    20  
    21  // SizeBytes implements marshal.Marshallable.SizeBytes.
    22  func (g *GasketInterruptEventFd) SizeBytes() int {
    23      return 16
    24  }
    25  
    26  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
    27  func (g *GasketInterruptEventFd) MarshalBytes(dst []byte) []byte {
    28      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Interrupt))
    29      dst = dst[8:]
    30      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.EventFD))
    31      dst = dst[8:]
    32      return dst
    33  }
    34  
    35  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
    36  func (g *GasketInterruptEventFd) UnmarshalBytes(src []byte) []byte {
    37      g.Interrupt = uint64(hostarch.ByteOrder.Uint64(src[:8]))
    38      src = src[8:]
    39      g.EventFD = uint64(hostarch.ByteOrder.Uint64(src[:8]))
    40      src = src[8:]
    41      return src
    42  }
    43  
    44  // Packed implements marshal.Marshallable.Packed.
    45  //go:nosplit
    46  func (g *GasketInterruptEventFd) Packed() bool {
    47      return true
    48  }
    49  
    50  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
    51  func (g *GasketInterruptEventFd) MarshalUnsafe(dst []byte) []byte {
    52      size := g.SizeBytes()
    53      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
    54      return dst[size:]
    55  }
    56  
    57  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
    58  func (g *GasketInterruptEventFd) UnmarshalUnsafe(src []byte) []byte {
    59      size := g.SizeBytes()
    60      gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
    61      return src[size:]
    62  }
    63  
    64  // CopyOutN implements marshal.Marshallable.CopyOutN.
    65  func (g *GasketInterruptEventFd) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
    66      // Construct a slice backed by dst's underlying memory.
    67      var buf []byte
    68      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
    69      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
    70      hdr.Len = g.SizeBytes()
    71      hdr.Cap = g.SizeBytes()
    72  
    73      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
    74      // Since we bypassed the compiler's escape analysis, indicate that g
    75      // must live until the use above.
    76      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
    77      return length, err
    78  }
    79  
    80  // CopyOut implements marshal.Marshallable.CopyOut.
    81  func (g *GasketInterruptEventFd) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    82      return g.CopyOutN(cc, addr, g.SizeBytes())
    83  }
    84  
    85  // CopyInN implements marshal.Marshallable.CopyInN.
    86  func (g *GasketInterruptEventFd) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
    87      // Construct a slice backed by dst's underlying memory.
    88      var buf []byte
    89      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
    90      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
    91      hdr.Len = g.SizeBytes()
    92      hdr.Cap = g.SizeBytes()
    93  
    94      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
    95      // Since we bypassed the compiler's escape analysis, indicate that g
    96      // must live until the use above.
    97      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
    98      return length, err
    99  }
   100  
   101  // CopyIn implements marshal.Marshallable.CopyIn.
   102  func (g *GasketInterruptEventFd) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   103      return g.CopyInN(cc, addr, g.SizeBytes())
   104  }
   105  
   106  // WriteTo implements io.WriterTo.WriteTo.
   107  func (g *GasketInterruptEventFd) WriteTo(writer io.Writer) (int64, error) {
   108      // Construct a slice backed by dst's underlying memory.
   109      var buf []byte
   110      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   111      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   112      hdr.Len = g.SizeBytes()
   113      hdr.Cap = g.SizeBytes()
   114  
   115      length, err := writer.Write(buf)
   116      // Since we bypassed the compiler's escape analysis, indicate that g
   117      // must live until the use above.
   118      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   119      return int64(length), err
   120  }
   121  
   122  // SizeBytes implements marshal.Marshallable.SizeBytes.
   123  func (g *GasketInterruptMapping) SizeBytes() int {
   124      return 32
   125  }
   126  
   127  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   128  func (g *GasketInterruptMapping) MarshalBytes(dst []byte) []byte {
   129      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Interrupt))
   130      dst = dst[8:]
   131      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.EventFD))
   132      dst = dst[8:]
   133      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.BarIndex))
   134      dst = dst[8:]
   135      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.RegOffset))
   136      dst = dst[8:]
   137      return dst
   138  }
   139  
   140  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   141  func (g *GasketInterruptMapping) UnmarshalBytes(src []byte) []byte {
   142      g.Interrupt = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   143      src = src[8:]
   144      g.EventFD = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   145      src = src[8:]
   146      g.BarIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   147      src = src[8:]
   148      g.RegOffset = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   149      src = src[8:]
   150      return src
   151  }
   152  
   153  // Packed implements marshal.Marshallable.Packed.
   154  //go:nosplit
   155  func (g *GasketInterruptMapping) Packed() bool {
   156      return true
   157  }
   158  
   159  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   160  func (g *GasketInterruptMapping) MarshalUnsafe(dst []byte) []byte {
   161      size := g.SizeBytes()
   162      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
   163      return dst[size:]
   164  }
   165  
   166  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   167  func (g *GasketInterruptMapping) UnmarshalUnsafe(src []byte) []byte {
   168      size := g.SizeBytes()
   169      gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
   170      return src[size:]
   171  }
   172  
   173  // CopyOutN implements marshal.Marshallable.CopyOutN.
   174  func (g *GasketInterruptMapping) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   175      // Construct a slice backed by dst's underlying memory.
   176      var buf []byte
   177      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   178      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   179      hdr.Len = g.SizeBytes()
   180      hdr.Cap = g.SizeBytes()
   181  
   182      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   183      // Since we bypassed the compiler's escape analysis, indicate that g
   184      // must live until the use above.
   185      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   186      return length, err
   187  }
   188  
   189  // CopyOut implements marshal.Marshallable.CopyOut.
   190  func (g *GasketInterruptMapping) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   191      return g.CopyOutN(cc, addr, g.SizeBytes())
   192  }
   193  
   194  // CopyInN implements marshal.Marshallable.CopyInN.
   195  func (g *GasketInterruptMapping) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   196      // Construct a slice backed by dst's underlying memory.
   197      var buf []byte
   198      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   199      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   200      hdr.Len = g.SizeBytes()
   201      hdr.Cap = g.SizeBytes()
   202  
   203      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   204      // Since we bypassed the compiler's escape analysis, indicate that g
   205      // must live until the use above.
   206      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   207      return length, err
   208  }
   209  
   210  // CopyIn implements marshal.Marshallable.CopyIn.
   211  func (g *GasketInterruptMapping) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   212      return g.CopyInN(cc, addr, g.SizeBytes())
   213  }
   214  
   215  // WriteTo implements io.WriterTo.WriteTo.
   216  func (g *GasketInterruptMapping) WriteTo(writer io.Writer) (int64, error) {
   217      // Construct a slice backed by dst's underlying memory.
   218      var buf []byte
   219      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   220      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   221      hdr.Len = g.SizeBytes()
   222      hdr.Cap = g.SizeBytes()
   223  
   224      length, err := writer.Write(buf)
   225      // Since we bypassed the compiler's escape analysis, indicate that g
   226      // must live until the use above.
   227      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   228      return int64(length), err
   229  }
   230  
   231  // SizeBytes implements marshal.Marshallable.SizeBytes.
   232  func (g *GasketPageTableDmaBufIoctl) SizeBytes() int {
   233      return 20
   234  }
   235  
   236  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   237  func (g *GasketPageTableDmaBufIoctl) MarshalBytes(dst []byte) []byte {
   238      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.PageTableIndex))
   239      dst = dst[8:]
   240      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.DeviceAddress))
   241      dst = dst[8:]
   242      hostarch.ByteOrder.PutUint32(dst[:4], uint32(g.DMABufID))
   243      dst = dst[4:]
   244      return dst
   245  }
   246  
   247  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   248  func (g *GasketPageTableDmaBufIoctl) UnmarshalBytes(src []byte) []byte {
   249      g.PageTableIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   250      src = src[8:]
   251      g.DeviceAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   252      src = src[8:]
   253      g.DMABufID = int32(hostarch.ByteOrder.Uint32(src[:4]))
   254      src = src[4:]
   255      return src
   256  }
   257  
   258  // Packed implements marshal.Marshallable.Packed.
   259  //go:nosplit
   260  func (g *GasketPageTableDmaBufIoctl) Packed() bool {
   261      return false
   262  }
   263  
   264  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   265  func (g *GasketPageTableDmaBufIoctl) MarshalUnsafe(dst []byte) []byte {
   266      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fallback to MarshalBytes.
   267      return g.MarshalBytes(dst)
   268  }
   269  
   270  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   271  func (g *GasketPageTableDmaBufIoctl) UnmarshalUnsafe(src []byte) []byte {
   272      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fallback to UnmarshalBytes.
   273      return g.UnmarshalBytes(src)
   274  }
   275  
   276  // CopyOutN implements marshal.Marshallable.CopyOutN.
   277  func (g *GasketPageTableDmaBufIoctl) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   278      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to MarshalBytes.
   279      buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay.
   280      g.MarshalBytes(buf) // escapes: fallback.
   281      return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   282  }
   283  
   284  // CopyOut implements marshal.Marshallable.CopyOut.
   285  func (g *GasketPageTableDmaBufIoctl) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   286      return g.CopyOutN(cc, addr, g.SizeBytes())
   287  }
   288  
   289  // CopyInN implements marshal.Marshallable.CopyInN.
   290  func (g *GasketPageTableDmaBufIoctl) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   291      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to UnmarshalBytes.
   292      buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay.
   293      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   294      // Unmarshal unconditionally. If we had a short copy-in, this results in a
   295      // partially unmarshalled struct.
   296      g.UnmarshalBytes(buf) // escapes: fallback.
   297      return length, err
   298  }
   299  
   300  // CopyIn implements marshal.Marshallable.CopyIn.
   301  func (g *GasketPageTableDmaBufIoctl) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   302      return g.CopyInN(cc, addr, g.SizeBytes())
   303  }
   304  
   305  // WriteTo implements io.WriterTo.WriteTo.
   306  func (g *GasketPageTableDmaBufIoctl) WriteTo(writer io.Writer) (int64, error) {
   307      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to MarshalBytes.
   308      buf := make([]byte, g.SizeBytes())
   309      g.MarshalBytes(buf)
   310      length, err := writer.Write(buf)
   311      return int64(length), err
   312  }
   313  
   314  // SizeBytes implements marshal.Marshallable.SizeBytes.
   315  func (g *GasketPageTableIoctl) SizeBytes() int {
   316      return 32
   317  }
   318  
   319  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   320  func (g *GasketPageTableIoctl) MarshalBytes(dst []byte) []byte {
   321      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.PageTableIndex))
   322      dst = dst[8:]
   323      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Size))
   324      dst = dst[8:]
   325      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.HostAddress))
   326      dst = dst[8:]
   327      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.DeviceAddress))
   328      dst = dst[8:]
   329      return dst
   330  }
   331  
   332  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   333  func (g *GasketPageTableIoctl) UnmarshalBytes(src []byte) []byte {
   334      g.PageTableIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   335      src = src[8:]
   336      g.Size = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   337      src = src[8:]
   338      g.HostAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   339      src = src[8:]
   340      g.DeviceAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   341      src = src[8:]
   342      return src
   343  }
   344  
   345  // Packed implements marshal.Marshallable.Packed.
   346  //go:nosplit
   347  func (g *GasketPageTableIoctl) Packed() bool {
   348      return true
   349  }
   350  
   351  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   352  func (g *GasketPageTableIoctl) MarshalUnsafe(dst []byte) []byte {
   353      size := g.SizeBytes()
   354      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
   355      return dst[size:]
   356  }
   357  
   358  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   359  func (g *GasketPageTableIoctl) UnmarshalUnsafe(src []byte) []byte {
   360      size := g.SizeBytes()
   361      gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
   362      return src[size:]
   363  }
   364  
   365  // CopyOutN implements marshal.Marshallable.CopyOutN.
   366  func (g *GasketPageTableIoctl) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   367      // Construct a slice backed by dst's underlying memory.
   368      var buf []byte
   369      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   370      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   371      hdr.Len = g.SizeBytes()
   372      hdr.Cap = g.SizeBytes()
   373  
   374      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   375      // Since we bypassed the compiler's escape analysis, indicate that g
   376      // must live until the use above.
   377      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   378      return length, err
   379  }
   380  
   381  // CopyOut implements marshal.Marshallable.CopyOut.
   382  func (g *GasketPageTableIoctl) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   383      return g.CopyOutN(cc, addr, g.SizeBytes())
   384  }
   385  
   386  // CopyInN implements marshal.Marshallable.CopyInN.
   387  func (g *GasketPageTableIoctl) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   388      // Construct a slice backed by dst's underlying memory.
   389      var buf []byte
   390      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   391      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   392      hdr.Len = g.SizeBytes()
   393      hdr.Cap = g.SizeBytes()
   394  
   395      length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
   396      // Since we bypassed the compiler's escape analysis, indicate that g
   397      // must live until the use above.
   398      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   399      return length, err
   400  }
   401  
   402  // CopyIn implements marshal.Marshallable.CopyIn.
   403  func (g *GasketPageTableIoctl) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   404      return g.CopyInN(cc, addr, g.SizeBytes())
   405  }
   406  
   407  // WriteTo implements io.WriterTo.WriteTo.
   408  func (g *GasketPageTableIoctl) WriteTo(writer io.Writer) (int64, error) {
   409      // Construct a slice backed by dst's underlying memory.
   410      var buf []byte
   411      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   412      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   413      hdr.Len = g.SizeBytes()
   414      hdr.Cap = g.SizeBytes()
   415  
   416      length, err := writer.Write(buf)
   417      // Since we bypassed the compiler's escape analysis, indicate that g
   418      // must live until the use above.
   419      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   420      return int64(length), err
   421  }
   422