diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-12-04 04:01:09 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-12-04 04:01:09 +0000 |
commit | 0ba39926c86fb6789cd48b93b5cbfca8d64c56ee (patch) | |
tree | b46b51918c405693b228aa513b9863d416523e3e /pkg/abi/linux | |
parent | 6be31bb4fcef461797469e047b25c095fbf572bf (diff) | |
parent | a78cef0ed7ce15583424f5873f0aa6fdad1d5c2f (diff) |
Merge release-20201130.0-36-ga78cef0ed (automated)
Diffstat (limited to 'pkg/abi/linux')
-rw-r--r-- | pkg/abi/linux/linux_abi_autogen_unsafe.go | 126 | ||||
-rw-r--r-- | pkg/abi/linux/sem.go | 24 |
2 files changed, 150 insertions, 0 deletions
diff --git a/pkg/abi/linux/linux_abi_autogen_unsafe.go b/pkg/abi/linux/linux_abi_autogen_unsafe.go index 3ccd566d4..aa0bfcc6b 100644 --- a/pkg/abi/linux/linux_abi_autogen_unsafe.go +++ b/pkg/abi/linux/linux_abi_autogen_unsafe.go @@ -67,6 +67,7 @@ var _ marshal.Marshallable = (*RSeqCriticalSection)(nil) var _ marshal.Marshallable = (*RobustListHead)(nil) var _ marshal.Marshallable = (*Rusage)(nil) var _ marshal.Marshallable = (*SeccompData)(nil) +var _ marshal.Marshallable = (*SemInfo)(nil) var _ marshal.Marshallable = (*Sembuf)(nil) var _ marshal.Marshallable = (*ShmInfo)(nil) var _ marshal.Marshallable = (*ShmParams)(nil) @@ -6882,6 +6883,131 @@ func UnmarshalUnsafeSembufSlice(dst []Sembuf, src []byte) (int, error) { } // SizeBytes implements marshal.Marshallable.SizeBytes. +func (s *SemInfo) SizeBytes() int { + return 40 +} + +// MarshalBytes implements marshal.Marshallable.MarshalBytes. +func (s *SemInfo) MarshalBytes(dst []byte) { + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemMap)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemMni)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemMns)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemMnu)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemMsl)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemOpm)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemUme)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemUsz)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemVmx)) + dst = dst[4:] + usermem.ByteOrder.PutUint32(dst[:4], uint32(s.SemAem)) + dst = dst[4:] +} + +// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. +func (s *SemInfo) UnmarshalBytes(src []byte) { + s.SemMap = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemMni = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemMns = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemMnu = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemMsl = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemOpm = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemUme = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemUsz = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemVmx = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] + s.SemAem = uint32(usermem.ByteOrder.Uint32(src[:4])) + src = src[4:] +} + +// Packed implements marshal.Marshallable.Packed. +//go:nosplit +func (s *SemInfo) Packed() bool { + return true +} + +// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. +func (s *SemInfo) MarshalUnsafe(dst []byte) { + safecopy.CopyIn(dst, unsafe.Pointer(s)) +} + +// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. +func (s *SemInfo) UnmarshalUnsafe(src []byte) { + safecopy.CopyOut(unsafe.Pointer(s), src) +} + +// CopyOutN implements marshal.Marshallable.CopyOutN. +//go:nosplit +func (s *SemInfo) CopyOutN(cc marshal.CopyContext, addr usermem.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(s))) + hdr.Len = s.SizeBytes() + hdr.Cap = s.SizeBytes() + + length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. + // Since we bypassed the compiler's escape analysis, indicate that s + // must live until the use above. + runtime.KeepAlive(s) // escapes: replaced by intrinsic. + return length, err +} + +// CopyOut implements marshal.Marshallable.CopyOut. +//go:nosplit +func (s *SemInfo) CopyOut(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + return s.CopyOutN(cc, addr, s.SizeBytes()) +} + +// CopyIn implements marshal.Marshallable.CopyIn. +//go:nosplit +func (s *SemInfo) CopyIn(cc marshal.CopyContext, addr usermem.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(s))) + hdr.Len = s.SizeBytes() + hdr.Cap = s.SizeBytes() + + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. + // Since we bypassed the compiler's escape analysis, indicate that s + // must live until the use above. + runtime.KeepAlive(s) // escapes: replaced by intrinsic. + return length, err +} + +// WriteTo implements io.WriterTo.WriteTo. +func (s *SemInfo) 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(s))) + hdr.Len = s.SizeBytes() + hdr.Cap = s.SizeBytes() + + length, err := writer.Write(buf) + // Since we bypassed the compiler's escape analysis, indicate that s + // must live until the use above. + runtime.KeepAlive(s) // escapes: replaced by intrinsic. + return int64(length), err +} + +// SizeBytes implements marshal.Marshallable.SizeBytes. func (s *ShmidDS) SizeBytes() int { return 40 + (*IPCPerm)(nil).SizeBytes() + diff --git a/pkg/abi/linux/sem.go b/pkg/abi/linux/sem.go index 167d2ff74..0adff8dff 100644 --- a/pkg/abi/linux/sem.go +++ b/pkg/abi/linux/sem.go @@ -41,6 +41,12 @@ const ( SEMMNS = SEMMNI * SEMMSL SEMOPM = 500 SEMVMX = 32767 + SEMAEM = SEMVMX + + // followings are unused in kernel + SEMUME = SEMOPM + SEMMNU = SEMMNS + SEMMAP = SEMMNS ) const SEM_UNDO = 0x1000 @@ -53,3 +59,21 @@ type Sembuf struct { SemOp int16 SemFlg int16 } + +// SemInfo is equivalent to struct seminfo. +// +// Source: include/uapi/linux/sem.h +// +// +marshal +type SemInfo struct { + SemMap uint32 + SemMni uint32 + SemMns uint32 + SemMnu uint32 + SemMsl uint32 + SemOpm uint32 + SemUme uint32 + SemUsz uint32 + SemVmx uint32 + SemAem uint32 +} |