1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
// Automatically generated marshal implementation. See tools/go_marshal.
package kernel
import (
"gvisor.dev/gvisor/pkg/gohacks"
"gvisor.dev/gvisor/pkg/hostarch"
"gvisor.dev/gvisor/pkg/marshal"
"io"
"reflect"
"runtime"
"unsafe"
)
// Marshallable types used by this file.
var _ marshal.Marshallable = (*ThreadID)(nil)
var _ marshal.Marshallable = (*vdsoParams)(nil)
// SizeBytes implements marshal.Marshallable.SizeBytes.
//go:nosplit
func (tid *ThreadID) SizeBytes() int {
return 4
}
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (tid *ThreadID) MarshalBytes(dst []byte) []byte {
hostarch.ByteOrder.PutUint32(dst[:4], uint32(*tid))
return dst[4:]
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (tid *ThreadID) UnmarshalBytes(src []byte) []byte {
*tid = ThreadID(int32(hostarch.ByteOrder.Uint32(src[:4])))
return src[4:]
}
// Packed implements marshal.Marshallable.Packed.
//go:nosplit
func (tid *ThreadID) Packed() bool {
// Scalar newtypes are always packed.
return true
}
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (tid *ThreadID) MarshalUnsafe(dst []byte) []byte {
size := tid.SizeBytes()
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(tid), uintptr(size))
return dst[size:]
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (tid *ThreadID) UnmarshalUnsafe(src []byte) []byte {
size := tid.SizeBytes()
gohacks.Memmove(unsafe.Pointer(tid), unsafe.Pointer(&src[0]), uintptr(size))
return src[size:]
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
func (tid *ThreadID) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(tid)))
hdr.Len = tid.SizeBytes()
hdr.Cap = tid.SizeBytes()
length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that tid
// must live until the use above.
runtime.KeepAlive(tid) // escapes: replaced by intrinsic.
return length, err
}
// CopyOut implements marshal.Marshallable.CopyOut.
func (tid *ThreadID) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
return tid.CopyOutN(cc, addr, tid.SizeBytes())
}
// CopyIn implements marshal.Marshallable.CopyIn.
func (tid *ThreadID) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(tid)))
hdr.Len = tid.SizeBytes()
hdr.Cap = tid.SizeBytes()
length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that tid
// must live until the use above.
runtime.KeepAlive(tid) // escapes: replaced by intrinsic.
return length, err
}
// WriteTo implements io.WriterTo.WriteTo.
func (tid *ThreadID) WriteTo(writer io.Writer) (int64, error) {
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(tid)))
hdr.Len = tid.SizeBytes()
hdr.Cap = tid.SizeBytes()
length, err := writer.Write(buf)
// Since we bypassed the compiler's escape analysis, indicate that tid
// must live until the use above.
runtime.KeepAlive(tid) // escapes: replaced by intrinsic.
return int64(length), err
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
func (v *vdsoParams) SizeBytes() int {
return 64
}
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (v *vdsoParams) MarshalBytes(dst []byte) []byte {
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.monotonicReady))
dst = dst[8:]
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.monotonicBaseCycles))
dst = dst[8:]
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.monotonicBaseRef))
dst = dst[8:]
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.monotonicFrequency))
dst = dst[8:]
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.realtimeReady))
dst = dst[8:]
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.realtimeBaseCycles))
dst = dst[8:]
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.realtimeBaseRef))
dst = dst[8:]
hostarch.ByteOrder.PutUint64(dst[:8], uint64(v.realtimeFrequency))
dst = dst[8:]
return dst
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (v *vdsoParams) UnmarshalBytes(src []byte) []byte {
v.monotonicReady = uint64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
v.monotonicBaseCycles = int64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
v.monotonicBaseRef = int64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
v.monotonicFrequency = uint64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
v.realtimeReady = uint64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
v.realtimeBaseCycles = int64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
v.realtimeBaseRef = int64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
v.realtimeFrequency = uint64(hostarch.ByteOrder.Uint64(src[:8]))
src = src[8:]
return src
}
// Packed implements marshal.Marshallable.Packed.
//go:nosplit
func (v *vdsoParams) Packed() bool {
return true
}
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (v *vdsoParams) MarshalUnsafe(dst []byte) []byte {
size := v.SizeBytes()
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(v), uintptr(size))
return dst[size:]
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (v *vdsoParams) UnmarshalUnsafe(src []byte) []byte {
size := v.SizeBytes()
gohacks.Memmove(unsafe.Pointer(v), unsafe.Pointer(&src[0]), uintptr(size))
return src[size:]
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
func (v *vdsoParams) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(v)))
hdr.Len = v.SizeBytes()
hdr.Cap = v.SizeBytes()
length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that v
// must live until the use above.
runtime.KeepAlive(v) // escapes: replaced by intrinsic.
return length, err
}
// CopyOut implements marshal.Marshallable.CopyOut.
func (v *vdsoParams) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
return v.CopyOutN(cc, addr, v.SizeBytes())
}
// CopyIn implements marshal.Marshallable.CopyIn.
func (v *vdsoParams) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(v)))
hdr.Len = v.SizeBytes()
hdr.Cap = v.SizeBytes()
length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that v
// must live until the use above.
runtime.KeepAlive(v) // escapes: replaced by intrinsic.
return length, err
}
// WriteTo implements io.WriterTo.WriteTo.
func (v *vdsoParams) WriteTo(writer io.Writer) (int64, error) {
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(v)))
hdr.Len = v.SizeBytes()
hdr.Cap = v.SizeBytes()
length, err := writer.Write(buf)
// Since we bypassed the compiler's escape analysis, indicate that v
// must live until the use above.
runtime.KeepAlive(v) // escapes: replaced by intrinsic.
return int64(length), err
}
|