cabi

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package cabi is the guest side of the Canonical ABI's memory for Go programs built with GOOS=wasip1: the cabi_realloc export a host calls to return lists and strings, guest-side allocations for arguments, and the guest's own linear memory as a wit.Memory. Blocks stay pinned (reachable from Go) until Release, which a caller runs once a host call's results have been copied out.

A program links one cabi_realloc: every guest package of this module that needs it imports this one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alloc

func Alloc(align, size uint32) uint32

Alloc returns a pinned block of size bytes aligned to align.

func Buffer added in v0.6.0

func Buffer(align, size uint32) (addr uint32, keep []byte)

Buffer returns a block of size bytes aligned to align that Release does not unpin: it stays valid while the caller keeps keep reachable (a buffer the host fills later, such as a pending stream read's).

func Release

func Release()

Release unpins every block (their contents must have been read).

Types

type Allocator

type Allocator struct{}

Allocator is Alloc as a wit.Allocator.

func (Allocator) Alloc

func (Allocator) Alloc(align, size uint32) (uint32, error)

Alloc implements wit.Allocator.

type Memory

type Memory struct{}

Memory is the guest's own linear memory.

func (Memory) Read

func (Memory) Read(off, n uint32) ([]byte, bool)

Read returns n bytes at off.

func (Memory) Write

func (Memory) Write(off uint32, b []byte) bool

Write copies b to off.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL