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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
// Automatically generated marshal implementation. See tools/go_marshal.
package auth
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 = (*GID)(nil)
var _ marshal.Marshallable = (*UID)(nil)
// SizeBytes implements marshal.Marshallable.SizeBytes.
//go:nosplit
func (gid *GID) SizeBytes() int {
return 4
}
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (gid *GID) MarshalBytes(dst []byte) []byte {
hostarch.ByteOrder.PutUint32(dst[:4], uint32(*gid))
return dst[4:]
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (gid *GID) UnmarshalBytes(src []byte) []byte {
*gid = GID(uint32(hostarch.ByteOrder.Uint32(src[:4])))
return src[4:]
}
// Packed implements marshal.Marshallable.Packed.
//go:nosplit
func (gid *GID) Packed() bool {
// Scalar newtypes are always packed.
return true
}
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (gid *GID) MarshalUnsafe(dst []byte) []byte {
size := gid.SizeBytes()
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(gid), uintptr(size))
return dst[size:]
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (gid *GID) UnmarshalUnsafe(src []byte) []byte {
size := gid.SizeBytes()
gohacks.Memmove(unsafe.Pointer(gid), unsafe.Pointer(&src[0]), uintptr(size))
return src[size:]
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
func (gid *GID) 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(gid)))
hdr.Len = gid.SizeBytes()
hdr.Cap = gid.SizeBytes()
length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that gid
// must live until the use above.
runtime.KeepAlive(gid) // escapes: replaced by intrinsic.
return length, err
}
// CopyOut implements marshal.Marshallable.CopyOut.
func (gid *GID) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
return gid.CopyOutN(cc, addr, gid.SizeBytes())
}
// CopyIn implements marshal.Marshallable.CopyIn.
func (gid *GID) 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(gid)))
hdr.Len = gid.SizeBytes()
hdr.Cap = gid.SizeBytes()
length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that gid
// must live until the use above.
runtime.KeepAlive(gid) // escapes: replaced by intrinsic.
return length, err
}
// WriteTo implements io.WriterTo.WriteTo.
func (gid *GID) 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(gid)))
hdr.Len = gid.SizeBytes()
hdr.Cap = gid.SizeBytes()
length, err := writer.Write(buf)
// Since we bypassed the compiler's escape analysis, indicate that gid
// must live until the use above.
runtime.KeepAlive(gid) // escapes: replaced by intrinsic.
return int64(length), err
}
// CopyGIDSliceIn copies in a slice of GID objects from the task's memory.
func CopyGIDSliceIn(cc marshal.CopyContext, addr hostarch.Addr, dst []GID) (int, error) {
count := len(dst)
if count == 0 {
return 0, nil
}
size := (*GID)(nil).SizeBytes()
ptr := unsafe.Pointer(&dst)
val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(val)
hdr.Len = size * count
hdr.Cap = size * count
length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that dst
// must live until the use above.
runtime.KeepAlive(dst) // escapes: replaced by intrinsic.
return length, err
}
// CopyGIDSliceOut copies a slice of GID objects to the task's memory.
func CopyGIDSliceOut(cc marshal.CopyContext, addr hostarch.Addr, src []GID) (int, error) {
count := len(src)
if count == 0 {
return 0, nil
}
size := (*GID)(nil).SizeBytes()
ptr := unsafe.Pointer(&src)
val := gohacks.Noescape(unsafe.Pointer((*reflect.SliceHeader)(ptr).Data))
// Construct a slice backed by dst's underlying memory.
var buf []byte
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
hdr.Data = uintptr(val)
hdr.Len = size * count
hdr.Cap = size * count
length, err := cc.CopyOutBytes(addr, buf) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that src
// must live until the use above.
runtime.KeepAlive(src) // escapes: replaced by intrinsic.
return length, err
}
// MarshalUnsafeGIDSlice is like GID.MarshalUnsafe, but for a []GID.
func MarshalUnsafeGIDSlice(src []GID, dst []byte) []byte {
count := len(src)
if count == 0 {
return dst
}
size := (*GID)(nil).SizeBytes()
buf := dst[:size*count]
gohacks.Memmove(unsafe.Pointer(&buf[0]), unsafe.Pointer(&src[0]), uintptr(len(buf)))
return dst[size*count:]
}
// UnmarshalUnsafeGIDSlice is like GID.UnmarshalUnsafe, but for a []GID.
func UnmarshalUnsafeGIDSlice(dst []GID, src []byte) []byte {
count := len(dst)
if count == 0 {
return src
}
size := (*GID)(nil).SizeBytes()
buf := src[:size*count]
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(&buf[0]), uintptr(len(buf)))
return src[size*count:]
}
// SizeBytes implements marshal.Marshallable.SizeBytes.
//go:nosplit
func (uid *UID) SizeBytes() int {
return 4
}
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
func (uid *UID) MarshalBytes(dst []byte) []byte {
hostarch.ByteOrder.PutUint32(dst[:4], uint32(*uid))
return dst[4:]
}
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
func (uid *UID) UnmarshalBytes(src []byte) []byte {
*uid = UID(uint32(hostarch.ByteOrder.Uint32(src[:4])))
return src[4:]
}
// Packed implements marshal.Marshallable.Packed.
//go:nosplit
func (uid *UID) Packed() bool {
// Scalar newtypes are always packed.
return true
}
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
func (uid *UID) MarshalUnsafe(dst []byte) []byte {
size := uid.SizeBytes()
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(uid), uintptr(size))
return dst[size:]
}
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
func (uid *UID) UnmarshalUnsafe(src []byte) []byte {
size := uid.SizeBytes()
gohacks.Memmove(unsafe.Pointer(uid), unsafe.Pointer(&src[0]), uintptr(size))
return src[size:]
}
// CopyOutN implements marshal.Marshallable.CopyOutN.
func (uid *UID) 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(uid)))
hdr.Len = uid.SizeBytes()
hdr.Cap = uid.SizeBytes()
length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that uid
// must live until the use above.
runtime.KeepAlive(uid) // escapes: replaced by intrinsic.
return length, err
}
// CopyOut implements marshal.Marshallable.CopyOut.
func (uid *UID) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
return uid.CopyOutN(cc, addr, uid.SizeBytes())
}
// CopyIn implements marshal.Marshallable.CopyIn.
func (uid *UID) 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(uid)))
hdr.Len = uid.SizeBytes()
hdr.Cap = uid.SizeBytes()
length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
// Since we bypassed the compiler's escape analysis, indicate that uid
// must live until the use above.
runtime.KeepAlive(uid) // escapes: replaced by intrinsic.
return length, err
}
// WriteTo implements io.WriterTo.WriteTo.
func (uid *UID) 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(uid)))
hdr.Len = uid.SizeBytes()
hdr.Cap = uid.SizeBytes()
length, err := writer.Write(buf)
// Since we bypassed the compiler's escape analysis, indicate that uid
// must live until the use above.
runtime.KeepAlive(uid) // escapes: replaced by intrinsic.
return int64(length), err
}
|