diff options
-rw-r--r-- | pkg/abi/linux/linux_abi_autogen_unsafe.go | 148 | ||||
-rw-r--r-- | pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go | 159 | ||||
-rw-r--r-- | pkg/abi/linux/linux_amd64_state_autogen.go | 1 | ||||
-rw-r--r-- | pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go | 151 | ||||
-rw-r--r-- | pkg/abi/linux/linux_arm64_state_autogen.go | 1 | ||||
-rw-r--r-- | pkg/abi/linux/sem.go | 12 | ||||
-rw-r--r-- | pkg/abi/linux/sem_amd64.go | 33 | ||||
-rw-r--r-- | pkg/abi/linux/sem_arm64.go | 31 |
8 files changed, 376 insertions, 160 deletions
diff --git a/pkg/abi/linux/linux_abi_autogen_unsafe.go b/pkg/abi/linux/linux_abi_autogen_unsafe.go index b6b61a128..3ccd566d4 100644 --- a/pkg/abi/linux/linux_abi_autogen_unsafe.go +++ b/pkg/abi/linux/linux_abi_autogen_unsafe.go @@ -68,7 +68,6 @@ var _ marshal.Marshallable = (*RobustListHead)(nil) var _ marshal.Marshallable = (*Rusage)(nil) var _ marshal.Marshallable = (*SeccompData)(nil) var _ marshal.Marshallable = (*Sembuf)(nil) -var _ marshal.Marshallable = (*SemidDS)(nil) var _ marshal.Marshallable = (*ShmInfo)(nil) var _ marshal.Marshallable = (*ShmParams)(nil) var _ marshal.Marshallable = (*ShmidDS)(nil) @@ -6700,153 +6699,6 @@ func (s *SeccompData) WriteTo(writer io.Writer) (int64, error) { } // SizeBytes implements marshal.Marshallable.SizeBytes. -func (s *SemidDS) SizeBytes() int { - return 24 + - (*IPCPerm)(nil).SizeBytes() + - (*TimeT)(nil).SizeBytes() + - (*TimeT)(nil).SizeBytes() -} - -// MarshalBytes implements marshal.Marshallable.MarshalBytes. -func (s *SemidDS) MarshalBytes(dst []byte) { - s.SemPerm.MarshalBytes(dst[:s.SemPerm.SizeBytes()]) - dst = dst[s.SemPerm.SizeBytes():] - s.SemOTime.MarshalBytes(dst[:s.SemOTime.SizeBytes()]) - dst = dst[s.SemOTime.SizeBytes():] - s.SemCTime.MarshalBytes(dst[:s.SemCTime.SizeBytes()]) - dst = dst[s.SemCTime.SizeBytes():] - usermem.ByteOrder.PutUint64(dst[:8], uint64(s.SemNSems)) - dst = dst[8:] - usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused3)) - dst = dst[8:] - usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused4)) - dst = dst[8:] -} - -// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. -func (s *SemidDS) UnmarshalBytes(src []byte) { - s.SemPerm.UnmarshalBytes(src[:s.SemPerm.SizeBytes()]) - src = src[s.SemPerm.SizeBytes():] - s.SemOTime.UnmarshalBytes(src[:s.SemOTime.SizeBytes()]) - src = src[s.SemOTime.SizeBytes():] - s.SemCTime.UnmarshalBytes(src[:s.SemCTime.SizeBytes()]) - src = src[s.SemCTime.SizeBytes():] - s.SemNSems = uint64(usermem.ByteOrder.Uint64(src[:8])) - src = src[8:] - s.unused3 = uint64(usermem.ByteOrder.Uint64(src[:8])) - src = src[8:] - s.unused4 = uint64(usermem.ByteOrder.Uint64(src[:8])) - src = src[8:] -} - -// Packed implements marshal.Marshallable.Packed. -//go:nosplit -func (s *SemidDS) Packed() bool { - return s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() -} - -// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. -func (s *SemidDS) MarshalUnsafe(dst []byte) { - if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { - safecopy.CopyIn(dst, unsafe.Pointer(s)) - } else { - // Type SemidDS doesn't have a packed layout in memory, fallback to MarshalBytes. - s.MarshalBytes(dst) - } -} - -// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. -func (s *SemidDS) UnmarshalUnsafe(src []byte) { - if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { - safecopy.CopyOut(unsafe.Pointer(s), src) - } else { - // Type SemidDS doesn't have a packed layout in memory, fallback to UnmarshalBytes. - s.UnmarshalBytes(src) - } -} - -// CopyOutN implements marshal.Marshallable.CopyOutN. -//go:nosplit -func (s *SemidDS) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error) { - if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { - // Type SemidDS doesn't have a packed layout in memory, fall back to MarshalBytes. - buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. - s.MarshalBytes(buf) // escapes: fallback. - return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. - } - - // 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 *SemidDS) 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 *SemidDS) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error) { - if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { - // Type SemidDS doesn't have a packed layout in memory, fall back to UnmarshalBytes. - buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. - length, err := cc.CopyInBytes(addr, buf) // escapes: okay. - // Unmarshal unconditionally. If we had a short copy-in, this results in a - // partially unmarshalled struct. - s.UnmarshalBytes(buf) // escapes: fallback. - return length, err - } - - // 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 *SemidDS) WriteTo(writer io.Writer) (int64, error) { - if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { - // Type SemidDS doesn't have a packed layout in memory, fall back to MarshalBytes. - buf := make([]byte, s.SizeBytes()) - s.MarshalBytes(buf) - length, err := writer.Write(buf) - return int64(length), err - } - - // 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 *Sembuf) SizeBytes() int { return 6 } diff --git a/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go b/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go index 89de1b0a6..f556eae68 100644 --- a/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go +++ b/pkg/abi/linux/linux_amd64_abi_autogen_unsafe.go @@ -4,6 +4,7 @@ // +build amd64 // +build amd64 // +build amd64 +// +build amd64 package linux @@ -20,8 +21,11 @@ import ( // Marshallable types used by this file. var _ marshal.Marshallable = (*EpollEvent)(nil) +var _ marshal.Marshallable = (*IPCPerm)(nil) var _ marshal.Marshallable = (*PtraceRegs)(nil) +var _ marshal.Marshallable = (*SemidDS)(nil) var _ marshal.Marshallable = (*Stat)(nil) +var _ marshal.Marshallable = (*TimeT)(nil) var _ marshal.Marshallable = (*Timespec)(nil) // SizeBytes implements marshal.Marshallable.SizeBytes. @@ -585,3 +589,158 @@ func (p *PtraceRegs) WriteTo(writer io.Writer) (int64, error) { return int64(length), err } +// SizeBytes implements marshal.Marshallable.SizeBytes. +func (s *SemidDS) SizeBytes() int { + return 40 + + (*IPCPerm)(nil).SizeBytes() + + (*TimeT)(nil).SizeBytes() + + (*TimeT)(nil).SizeBytes() +} + +// MarshalBytes implements marshal.Marshallable.MarshalBytes. +func (s *SemidDS) MarshalBytes(dst []byte) { + s.SemPerm.MarshalBytes(dst[:s.SemPerm.SizeBytes()]) + dst = dst[s.SemPerm.SizeBytes():] + s.SemOTime.MarshalBytes(dst[:s.SemOTime.SizeBytes()]) + dst = dst[s.SemOTime.SizeBytes():] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused1)) + dst = dst[8:] + s.SemCTime.MarshalBytes(dst[:s.SemCTime.SizeBytes()]) + dst = dst[s.SemCTime.SizeBytes():] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused2)) + dst = dst[8:] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.SemNSems)) + dst = dst[8:] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused3)) + dst = dst[8:] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused4)) + dst = dst[8:] +} + +// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. +func (s *SemidDS) UnmarshalBytes(src []byte) { + s.SemPerm.UnmarshalBytes(src[:s.SemPerm.SizeBytes()]) + src = src[s.SemPerm.SizeBytes():] + s.SemOTime.UnmarshalBytes(src[:s.SemOTime.SizeBytes()]) + src = src[s.SemOTime.SizeBytes():] + s.unused1 = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] + s.SemCTime.UnmarshalBytes(src[:s.SemCTime.SizeBytes()]) + src = src[s.SemCTime.SizeBytes():] + s.unused2 = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] + s.SemNSems = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] + s.unused3 = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] + s.unused4 = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] +} + +// Packed implements marshal.Marshallable.Packed. +//go:nosplit +func (s *SemidDS) Packed() bool { + return s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() +} + +// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. +func (s *SemidDS) MarshalUnsafe(dst []byte) { + if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + safecopy.CopyIn(dst, unsafe.Pointer(s)) + } else { + // Type SemidDS doesn't have a packed layout in memory, fallback to MarshalBytes. + s.MarshalBytes(dst) + } +} + +// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. +func (s *SemidDS) UnmarshalUnsafe(src []byte) { + if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + safecopy.CopyOut(unsafe.Pointer(s), src) + } else { + // Type SemidDS doesn't have a packed layout in memory, fallback to UnmarshalBytes. + s.UnmarshalBytes(src) + } +} + +// CopyOutN implements marshal.Marshallable.CopyOutN. +//go:nosplit +func (s *SemidDS) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error) { + if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + // Type SemidDS doesn't have a packed layout in memory, fall back to MarshalBytes. + buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. + s.MarshalBytes(buf) // escapes: fallback. + return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. + } + + // 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 *SemidDS) 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 *SemidDS) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + // Type SemidDS doesn't have a packed layout in memory, fall back to UnmarshalBytes. + buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. + // Unmarshal unconditionally. If we had a short copy-in, this results in a + // partially unmarshalled struct. + s.UnmarshalBytes(buf) // escapes: fallback. + return length, err + } + + // 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 *SemidDS) WriteTo(writer io.Writer) (int64, error) { + if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + // Type SemidDS doesn't have a packed layout in memory, fall back to MarshalBytes. + buf := make([]byte, s.SizeBytes()) + s.MarshalBytes(buf) + length, err := writer.Write(buf) + return int64(length), err + } + + // 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 +} + diff --git a/pkg/abi/linux/linux_amd64_state_autogen.go b/pkg/abi/linux/linux_amd64_state_autogen.go index 78a4a30e7..3d3dea994 100644 --- a/pkg/abi/linux/linux_amd64_state_autogen.go +++ b/pkg/abi/linux/linux_amd64_state_autogen.go @@ -4,6 +4,7 @@ // +build amd64 // +build amd64 // +build amd64 +// +build amd64 package linux diff --git a/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go b/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go index fdc8a87ce..7b643ba4c 100644 --- a/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go +++ b/pkg/abi/linux/linux_arm64_abi_autogen_unsafe.go @@ -3,6 +3,7 @@ // +build arm64 // +build arm64 // +build arm64 +// +build arm64 package linux @@ -19,8 +20,11 @@ import ( // Marshallable types used by this file. var _ marshal.Marshallable = (*EpollEvent)(nil) +var _ marshal.Marshallable = (*IPCPerm)(nil) var _ marshal.Marshallable = (*PtraceRegs)(nil) +var _ marshal.Marshallable = (*SemidDS)(nil) var _ marshal.Marshallable = (*Stat)(nil) +var _ marshal.Marshallable = (*TimeT)(nil) var _ marshal.Marshallable = (*Timespec)(nil) // SizeBytes implements marshal.Marshallable.SizeBytes. @@ -505,3 +509,150 @@ func (p *PtraceRegs) WriteTo(writer io.Writer) (int64, error) { return int64(length), err } +// SizeBytes implements marshal.Marshallable.SizeBytes. +func (s *SemidDS) SizeBytes() int { + return 24 + + (*IPCPerm)(nil).SizeBytes() + + (*TimeT)(nil).SizeBytes() + + (*TimeT)(nil).SizeBytes() +} + +// MarshalBytes implements marshal.Marshallable.MarshalBytes. +func (s *SemidDS) MarshalBytes(dst []byte) { + s.SemPerm.MarshalBytes(dst[:s.SemPerm.SizeBytes()]) + dst = dst[s.SemPerm.SizeBytes():] + s.SemOTime.MarshalBytes(dst[:s.SemOTime.SizeBytes()]) + dst = dst[s.SemOTime.SizeBytes():] + s.SemCTime.MarshalBytes(dst[:s.SemCTime.SizeBytes()]) + dst = dst[s.SemCTime.SizeBytes():] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.SemNSems)) + dst = dst[8:] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused3)) + dst = dst[8:] + usermem.ByteOrder.PutUint64(dst[:8], uint64(s.unused4)) + dst = dst[8:] +} + +// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes. +func (s *SemidDS) UnmarshalBytes(src []byte) { + s.SemPerm.UnmarshalBytes(src[:s.SemPerm.SizeBytes()]) + src = src[s.SemPerm.SizeBytes():] + s.SemOTime.UnmarshalBytes(src[:s.SemOTime.SizeBytes()]) + src = src[s.SemOTime.SizeBytes():] + s.SemCTime.UnmarshalBytes(src[:s.SemCTime.SizeBytes()]) + src = src[s.SemCTime.SizeBytes():] + s.SemNSems = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] + s.unused3 = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] + s.unused4 = uint64(usermem.ByteOrder.Uint64(src[:8])) + src = src[8:] +} + +// Packed implements marshal.Marshallable.Packed. +//go:nosplit +func (s *SemidDS) Packed() bool { + return s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() +} + +// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe. +func (s *SemidDS) MarshalUnsafe(dst []byte) { + if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + safecopy.CopyIn(dst, unsafe.Pointer(s)) + } else { + // Type SemidDS doesn't have a packed layout in memory, fallback to MarshalBytes. + s.MarshalBytes(dst) + } +} + +// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe. +func (s *SemidDS) UnmarshalUnsafe(src []byte) { + if s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + safecopy.CopyOut(unsafe.Pointer(s), src) + } else { + // Type SemidDS doesn't have a packed layout in memory, fallback to UnmarshalBytes. + s.UnmarshalBytes(src) + } +} + +// CopyOutN implements marshal.Marshallable.CopyOutN. +//go:nosplit +func (s *SemidDS) CopyOutN(cc marshal.CopyContext, addr usermem.Addr, limit int) (int, error) { + if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + // Type SemidDS doesn't have a packed layout in memory, fall back to MarshalBytes. + buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. + s.MarshalBytes(buf) // escapes: fallback. + return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay. + } + + // 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 *SemidDS) 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 *SemidDS) CopyIn(cc marshal.CopyContext, addr usermem.Addr) (int, error) { + if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + // Type SemidDS doesn't have a packed layout in memory, fall back to UnmarshalBytes. + buf := cc.CopyScratchBuffer(s.SizeBytes()) // escapes: okay. + length, err := cc.CopyInBytes(addr, buf) // escapes: okay. + // Unmarshal unconditionally. If we had a short copy-in, this results in a + // partially unmarshalled struct. + s.UnmarshalBytes(buf) // escapes: fallback. + return length, err + } + + // 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 *SemidDS) WriteTo(writer io.Writer) (int64, error) { + if !s.SemCTime.Packed() && s.SemOTime.Packed() && s.SemPerm.Packed() { + // Type SemidDS doesn't have a packed layout in memory, fall back to MarshalBytes. + buf := make([]byte, s.SizeBytes()) + s.MarshalBytes(buf) + length, err := writer.Write(buf) + return int64(length), err + } + + // 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 +} + diff --git a/pkg/abi/linux/linux_arm64_state_autogen.go b/pkg/abi/linux/linux_arm64_state_autogen.go index 5fc6cf73f..adc1f568e 100644 --- a/pkg/abi/linux/linux_arm64_state_autogen.go +++ b/pkg/abi/linux/linux_arm64_state_autogen.go @@ -3,6 +3,7 @@ // +build arm64 // +build arm64 // +build arm64 +// +build arm64 package linux diff --git a/pkg/abi/linux/sem.go b/pkg/abi/linux/sem.go index 487a626cc..1b2f76c0b 100644 --- a/pkg/abi/linux/sem.go +++ b/pkg/abi/linux/sem.go @@ -34,18 +34,6 @@ const ( const SEM_UNDO = 0x1000 -// SemidDS is equivalent to struct semid64_ds. -// -// +marshal -type SemidDS struct { - SemPerm IPCPerm - SemOTime TimeT - SemCTime TimeT - SemNSems uint64 - unused3 uint64 - unused4 uint64 -} - // Sembuf is equivalent to struct sembuf. // // +marshal slice:SembufSlice diff --git a/pkg/abi/linux/sem_amd64.go b/pkg/abi/linux/sem_amd64.go new file mode 100644 index 000000000..ab980cb4f --- /dev/null +++ b/pkg/abi/linux/sem_amd64.go @@ -0,0 +1,33 @@ +// Copyright 2020 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build amd64 + +package linux + +// SemidDS is equivalent to struct semid64_ds. +// +// Source: arch/x86/include/uapi/asm/sembuf.h +// +// +marshal +type SemidDS struct { + SemPerm IPCPerm + SemOTime TimeT + unused1 uint64 + SemCTime TimeT + unused2 uint64 + SemNSems uint64 + unused3 uint64 + unused4 uint64 +} diff --git a/pkg/abi/linux/sem_arm64.go b/pkg/abi/linux/sem_arm64.go new file mode 100644 index 000000000..521468fb1 --- /dev/null +++ b/pkg/abi/linux/sem_arm64.go @@ -0,0 +1,31 @@ +// Copyright 2020 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build arm64 + +package linux + +// SemidDS is equivalent to struct semid64_ds. +// +// Source: include/uapi/asm-generic/sembuf.h +// +// +marshal +type SemidDS struct { + SemPerm IPCPerm + SemOTime TimeT + SemCTime TimeT + SemNSems uint64 + unused3 uint64 + unused4 uint64 +} |