Platform types
Portable platform types and feature macros, plus the experimental Windows asynchronous preemption opt-in.
On this page
Platform types
| Type or macro | Purpose |
|---|---|
llam_fd_t |
POSIX fd or Windows SOCKET. |
llam_handle_t |
POSIX fd alias or Windows HANDLE-compatible type. |
llam_iovec_t / llam_mut_iovec_t |
Portable immutable and mutable scatter/gather slices. |
LLAM_INVALID_FD / LLAM_FD_IS_INVALID |
Portable fd/socket invalid sentinel and predicate. |
LLAM_INVALID_HANDLE / LLAM_HANDLE_IS_INVALID |
Portable handle invalid sentinel and predicate. |
LLAM_PLATFORM_WINDOWS / LLAM_PLATFORM_POSIX |
Major platform-family feature macros. |
LLAM_PLATFORM_LINUX / LLAM_PLATFORM_DARWIN |
Supported POSIX platform detection macros. |
LLAM_PLATFORM_BSD / LLAM_PLATFORM_FREEBSD / LLAM_PLATFORM_OPENBSD / LLAM_PLATFORM_NETBSD / LLAM_PLATFORM_DRAGONFLY |
Retired feature macros retained as constant 0 for source compatibility. BSD compiler targets are rejected independently. |
LLAM_PLATFORM_KQUEUE |
Non-zero on macOS targets. |
LLAM_ARCH_X86_64 / LLAM_ARCH_AARCH64 |
Public architecture feature macros. |
LLAM_PLATFORM_NAME |
Human-readable platform name used by diagnostics. |
LLAM_API |
Public symbol visibility/import/export macro. |
BSD support ended in 3.0.0. The zero-valued compatibility macros do not select a runtime backend, native context transport, or compiler profile. The public header rejects retired compiler targets before including platform system headers. Existing BSD applications must use versioned 2.x sources and tooling.
Experimental Windows preemption
llam_runtime_enable_experimental_windows_async_preempt_exOpt a compatibility runtime into the experimental Windows backend.
int llam_runtime_enable_experimental_windows_async_preempt_ex(
llam_runtime_t *runtime,
const llam_windows_async_preempt_opts_t *opts,
size_t opts_size);Atomically enable the experimental fixed-primary Windows async backend.
Host threads only, before the first worker run and before any task is live. The options and range array must remain valid and unchanged until this function returns. The runtime retains neither caller-owned pointer. The caller certifies that every possible interrupted PC in each supplied interval is safe for LLAM's asynchronous context capture and later restore. LLAM checks address bounds, committed executable PE-image backing, module lifetime, supported machine state, and runtime ownership; it cannot prove code semantics, instruction boundaries, exception/unwind safety, or absence of hidden foreign/thread-affine state. The caller must not mutate certified code while enabled. The range array is copied and the image is pinned until runtime shutdown/destroy. Enablement is one-way; there is no public disable. On uncertainty after committed remote context/suspension mutation, LLAM terminates the entire hosting process via Windows fail-fast. This is not a recoverable runtime-local error. The required acknowledgement flag makes that consequence explicit; it does not certify the supplied code. Only Win64 x86-64 experimental builds support this call; other builds return ENOTSUP. Successful enablement still honors the existing AUTO/STRICT preemption mode; code outside certified intervals remains cooperative. Qualified fixed primary workers each own native binding/operation state; all must register before any task dispatch. Full asynchronous continuations restore only on their capture worker. An eligible explicit user yield may release affinity only after a fresh completed cooperative save and retirement of all prior asynchronous ownership. Runtime-internal/park/offload waits remain origin-bound. Native TLS references must not be retained across a migratable yield; use task-local state or pin the task. Dynamic scaling, helper/relief execution and inline foreign detach remain unsupported here. A success racing another host's destroy means enablement linearized first; it does not keep the runtime handle alive after this call returns.
runtime- Live runtime handle, not NULL.
opts- Non-NULL v1 options with a nonempty certified range array.
opts_size- Size of the caller's options struct; must contain all v1 fields. As with other `_ex` inputs, a larger future tail is ignored by an older library; callers requiring future fields must check the ABI minor.
Returns 0 if the complete configuration was enabled; -1 with errno set to EINVAL for malformed inputs, EBUSY for a racing/live/closing runtime, EALREADY if already enabled, ENOTSUP for unavailable backend or unsupported machine/image configuration, or ENOMEM/EOVERFLOW for resource limits. On failure no part of this call's configuration remains installed.
llam_runtime_enable_experimental_windows_async_preempt_ex() atomically opts
an idle, fixed-primary Win64 runtime from llam_runtime_create_compat() into the
experimental backend. The caller passes
nonoverlapping, half-open, caller-certified PE-image PC ranges and the
LLAM_WINDOWS_ASYNC_PREEMPT_ACK_PROCESS_FAILFAST flag. LLAM copies the ranges,
checks PE executable backing and machine support, and pins their modules; it
cannot prove that arbitrary code is safe to interrupt. A committed remote
context failure can terminate the entire hosting process. Other builds retain
the public symbol but return ENOTSUP. See Options and the
Windows build contract before using it.
A successful call racing destroy reports that enablement committed first, not
that the runtime remains usable after the call returns.
Each actual primary worker must register before user dispatch starts. Captured
full native contexts stay on their capture worker; only a completed eligible
explicit cooperative yield with all old asynchronous ownership retired can
release a G for ordinary migration. Internal yields and park/offload wakes
remain origin-bound. Do not retain native-TLS addresses across migration.
Dynamic scaling, async helper/relief execution and inline foreign detach are
not admitted. Native qualification currently covers two and three primary Ms
with the pinned scalar-leaf fixture, not every workload or compiler profile.