package eventfd
import "gvisor.dev/gvisor/pkg/eventfd"
Package eventfd wraps Linux's eventfd(2) syscall.
Index ¶
- type Eventfd
- func Create() (Eventfd, error)
- func Wrap(fd int) Eventfd
- func (ev Eventfd) Close() error
- func (ev *Eventfd) DisableMMIO()
- func (ev Eventfd) Dup() (Eventfd, error)
- func (ev *Eventfd) EnableMMIO(addr uintptr, ctrl MMIOController)
- func (ev Eventfd) FD() int
- func (ev Eventfd) MMIOAddr() uintptr
- func (ev Eventfd) MMIOWrite(val uint64) error
- func (ev Eventfd) Notify() error
- func (ev Eventfd) Read() (uint64, error)
- func (ev Eventfd) Wait() error
- func (ev Eventfd) Write(val uint64) error
- type MMIOController
Types ¶
type Eventfd ¶
type Eventfd struct {
// contains filtered or unexported fields
}
Eventfd represents a Linux eventfd object.
func Create ¶
Create returns an initialized eventfd.
func Wrap ¶
Wrap returns an initialized Eventfd using the provided fd.
func (Eventfd) Close ¶
Close closes the eventfd, after which it should not be used.
func (*Eventfd) DisableMMIO ¶
func (ev *Eventfd) DisableMMIO()
DisableMMIO undoes the effect of a previous call to EnableMMIO. DisableMMIO cannot be called concurrently with Write, MMIOWrite, or MMIOAddr.
func (Eventfd) Dup ¶
Dup copies the eventfd, calling dup(2) on the underlying file descriptor.
func (*Eventfd) EnableMMIO ¶
func (ev *Eventfd) EnableMMIO(addr uintptr, ctrl MMIOController)
EnableMMIO causes future calls to ev.Write() to use memory-mapped writes to addr, subject to ctrl. EnableMMIO cannot be called concurrently with Write, MMIOWrite, or MMIOAddr.
This feature is used to support KVM ioeventfds. Since this requires that addr is mapped read-only or with no permissions in the host virtual address space (so that writes in host mode fault), it cannot reasonably be Go-managed memory, so it's safe to type as uintptr rather than a pointer.
func (Eventfd) FD ¶
FD returns the underlying file descriptor. Use with care, as this breaks the Eventfd abstraction.
func (Eventfd) MMIOAddr ¶
MMIOAddr returns the address set by the last call to EnableMMIO.
func (Eventfd) MMIOWrite ¶
MMIOWrite is equivalent to Write, but returns an error if the write cannot be implemented by writing to the address set by EnableMMIO. This is primarily useful for testing.
func (Eventfd) Notify ¶
Notify alerts other users of the eventfd. Users can receive alerts by calling Wait or Read.
func (Eventfd) Read ¶
Read blocks until eventfd is non-zero (i.e. someone calls Notify or Write) and returns the value read.
func (Eventfd) Wait ¶
Wait blocks until eventfd is non-zero (i.e. someone calls Notify or Write).
func (Eventfd) Write ¶
Write writes a specific value to the eventfd.
type MMIOController ¶
type MMIOController interface { // Enabled returns true if writing to the associated MMIO address can // succeed. This is inherently racy, so if the memory-mapped write faults, // the eventfd will fall back to writing using a syscall. Enabled() bool // Close is called when the associated Eventfd is closed. Close(ev Eventfd) }
MMIOController controls eventfd memory-mapped I/O.
Source Files ¶
eventfd.go eventfd_unsafe.go
- Version
- v0.0.0-20250605235530-a6711d1e1dc6 (latest)
- Published
- Jun 5, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 4 hours ago –
Tools for package owners.