Runtime ABI
This describes the boundary between guest code and host runtime.
Boundary functions
| Function | Direction | Purpose |
|---|---|---|
PBSysThreadEnterMain |
guest → host | Initialize runtime state for main thread. |
PBSysNativeMain |
guest → host | Start native runtime process execution. |
pb_syscall |
guest → host | Execute synchronous syscall operation. |
pb_syscall_async |
guest → host | Execute potentially long-running syscall operation. |
pb_thread |
host ← guest | Enter guest code on a runtime thread. |
Signatures
void pb_thread(
PBSysThreadEntry entry,
void* stack, uint32_t stackSize,
u64 arg1, u64 arg2);
i64 pb_syscall(
PBSysHandle subject,
PBSysCallOp action,
u64 arg1, u64 arg2, u64 arg3,
u64 arg4, u64 arg5, u64 arg6);
;
i64 pb_syscall_async(
PBSysHandle subject,
PBSysCallOp action,
u64 arg1, u64 arg2, u64 arg3,
u64 arg4, u64 arg5, u64 arg6);
Notes:
- On non-wasm builds,
pb_syscall_asyncaliases topb_syscall. PBSysNativeMainis native-only (playbit/sys/native.h).pb_threadis exported by guest and called by host runtime.
Syscall contract
pb_syscall and pb_syscall_async takes:
subject:handleassociated with operation target (or0for none).action:PBSysCallOp_*opcode.a..f: operation-specific arguments.
Return value meaning is operation-specific:
- negative values are
PBSysErrerrors, - otherwise return type depends on syscall wrapper (
PBSysHandle, counts, timestamps, etc).
See System calls and Types.
Native startup timeline
- Guest calls
PBSysThreadEnterMain(flags). - Guest calls
PBSysNativeMain(entry, arg1, arg2, configurator). - Host runtime creates/attaches the runtime main thread.
- Host runtime calls guest
pb_thread(entry, stack, stackSize, arg1, arg2). - Guest executes and uses syscalls/events.
typedef uint64_t (*PBSysNativeAppConfigurator)(PBSysThreadFlags mainThreadFlags);
void PBSysNativeMain(PBSysThreadEntry entry, u64 arg1, u64 arg2,
PBSysNativeAppConfigurator nullable configurator);