package sysenc
import "github.com/cilium/ebpf/internal/sysenc"
Package sysenc provides efficient conversion of Go values to system call interfaces.
Index ¶
- func Unmarshal(data interface{}, buf []byte) error
- type Buffer
- func Marshal(data any, size int) (Buffer, error)
- func SyscallOutput(dst any, size int) Buffer
- func UnsafeBuffer(ptr unsafe.Pointer) Buffer
- func (b Buffer) AppendTo(dst []byte) []byte
- func (b Buffer) Bytes() []byte
- func (b Buffer) CopyTo(dst []byte) int
- func (b Buffer) Pointer() sys.Pointer
- func (b Buffer) Unmarshal(data any) error
Functions ¶
func Unmarshal ¶
Unmarshal a byte slice in the system's native endianness into data.
Returns an error if buf can't be unmarshalled according to the behaviour of binary.Decode.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func Marshal ¶
Marshal turns data into a byte slice using the system's native endianness.
If possible, avoids allocations by directly using the backing memory of data. This means that the variable must not be modified for the lifetime of the returned Buffer.
Returns an error if the data can't be turned into a byte slice according to the behaviour of binary.Write.
func SyscallOutput ¶
SyscallOutput prepares a Buffer for a syscall to write into.
size is the length of the desired buffer in bytes. The buffer may point at the underlying memory of dst, in which case Unmarshal becomes a no-op.
The contents of the buffer are undefined and may be non-zero.
func UnsafeBuffer ¶
UnsafeBuffer constructs a Buffer for zero-copy unmarshaling.
[Pointer] is the only valid method to call on such a Buffer. Use [SyscallBuffer] instead if possible.
func (Buffer) AppendTo ¶
AppendTo appends the buffer onto dst.
func (Buffer) Bytes ¶
Bytes returns the buffer as a byte slice. Returns nil if the Buffer was created using UnsafeBuffer or by zero-copy unmarshaling.
func (Buffer) CopyTo ¶
CopyTo copies the buffer into dst.
Returns the number of copied bytes.
func (Buffer) Pointer ¶
Pointer returns the location where a syscall should write.
func (Buffer) Unmarshal ¶
Unmarshal the buffer into the provided value.
Source Files ¶
buffer.go doc.go layout.go marshal.go
- Version
- v0.18.0 (latest)
- Published
- Apr 2, 2025
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 1 week ago –
Tools for package owners.