NAME
ttypt/xy-mod.h - Module-side implementation glue for the xy module system.
SYNOPSIS
#include 'xy.h'
Macros
Load a module into the caller's current region.
Deny a hook or module within the caller's current region.
Set or clear the claim gate on the caller's current region.
Enumerate immediate child regions of the caller's current region.
Run fn with the caller's current region temporarily set to the region identified by (region_id, plen).
Return the id half of the current region identity for this thread.
Return the plen half of the current region identity.
Test whether the region identified by (region_id, plen) exists and is addressable.
Create the region identified by (id, plen), or reuse it.
Find the deepest existing region whose prefix covers a point.
Dispatch to the current region's own modules only.
Unload a module from the caller's current region.
Reload a module in place in the caller's current region.
Return the region ID assigned to this module (diagnostic/internal).
Functions
Report this module's xy_ctx ABI generation and size.
Detailed Description
Module-side implementation glue for the xy module system.
Included by module sources to get the injected xy context and the XY_IMPL / XY_CALL expansion machinery.
Macro Definition Documentation
#define XY_CALL_SELF( retp, fname, ...)
Value:
{ \
struct fname##_args args = { __VA_ARGS__ }; \
xy.call_self(retp, &fname##_adapter, &args); \
}
Dispatch to the current region's own modules only. The exact-region counterpart of XY_CALL(), which reaches the current region's whole subtree. Use it for a coarse-to-fine ancestor walk, where each region should get one turn rather than its whole subtree. Deny checks and xy.last() predecessor semantics match XY_CALL().
#define xy_claim_at( id, plen, fn, ud)
Value:
xy_mod_claim_at_(&xy, (id), (plen), (fn), (ud))
Create the region identified by (id, plen), or reuse it. On success the region is the module's current region, so a following xy_load() lands inside it. Rejects plen > 64, a misaligned id, and a plen that is not strictly wider than the region's nearest existing ancestor; an exact match is idempotent. The rejection is about WIDTH, never about id equalling the ancestor's -- claiming (0,16) under the root (0,0) widens the region and is legal. id carries its prefix in the high bits above plen and its width is never inferred from it -- pass both halves.
#define xy_current_region_plen()
Value:
xy_mod_current_region_plen_(&xy)
Return the plen half of the current region identity. Reads the thread-local entry directly โ no lookup, no ambiguity. 0 for the root region.
#define xy_deny( what, type)
Value:
xy_mod_deny_(&xy, (what), (type))
Deny a hook or module within the caller's current region. The deny applies to the caller's current region and all its descendants.
Parameters
what Hook name (XY_DENY_HOOK) or module path (XY_DENY_MODULE)
type XY_DENY_HOOK or XY_DENY_MODULE
#define xy_load( fname)
Value:
xy_mod_load_(&xy, (fname))
Load a module into the caller's current region.
Parameters
fname Path to .so / .dll
#define xy_region_at( prefix_id, plen, region_plen)
Value:
xy_mod_region_at_(&xy, (prefix_id), (plen), (region_plen))
Find the deepest existing region whose prefix covers a point.
Parameters
region_plen Out-param for the covering region's width; set to 0 on every failure path. May be NULL.
Returns
The covering region's id half, or XY_REGION_INVALID if none.
#define xy_region_each( fn, ud)
Value:
xy_mod_region_each_(&xy, (fn), (ud))
Enumerate immediate child regions of the caller's current region.
Parameters
fn Callback: fn(child_id, plen, ud). Return XY_OK to continue.
ud User data passed to fn
#define xy_region_exists( region_id, plen)
Value:
xy_mod_region_exists_(&xy, (region_id), (plen))
Test whether the region identified by (region_id, plen) exists and is addressable.
Returns
XY_OK if that exact region exists, XY_ERR_NOTFOUND otherwise.
#define XY_REGION_INIT
Value:
XY_MODULE_API size_t xy_region_state_size(void) \
{ return sizeof(struct xy_rs_s); }
Emit the xy_region_state_size() export after the struct definition.
#define XY_REGION_STATE struct xy_rs_s
Begin per-region state struct declaration.
#define xy_reload( fname)
Value:
xy_mod_reload_(&xy, (fname))
Reload a module in place in the caller's current region.
Parameters
fname Path passed to xy_load() (without .so/.dll suffix)
#define xy_require_claim( fn, ud)
Value:
xy_mod_require_claim_(&xy, (fn), (ud))
Set or clear the claim gate on the caller's current region. Non-NULL fn: enables the gate โ subsequent xy_load() calls require an xy_claim symbol from the module. NULL fn: clears the gate โ subsequent xy_load() calls need no xy_claim.
Parameters
fn Claim handler function, or NULL to clear.
ud User data passed to fn (ignored when fn is NULL).
#define XY_RS ((struct xy_rs_s *)xy.region_state)
Typed pointer to the current region's state block.
#define xy_unload( fname)
Value:
xy_mod_unload_(&xy, (fname))
Unload a module from the caller's current region.
Parameters
fname Path passed to xy_load() (without .so/.dll suffix)
#define xy_with_region( region_id, plen, fn, ud)
Value:
xy_mod_with_region_(&xy, (region_id), (plen), (fn), (ud))
Run fn with the caller's current region temporarily set to the region identified by (region_id, plen). Nested hook calls inside fn inherit that region.
Returns
XY_ERR_NOTFOUND if no region with that exact (id, plen) exists.
Function Documentation
XY_MODULE_API XY_MOD_WEAK_ uint64_t xy_ctx_abi (void )
Report this module's xy_ctx ABI generation and size. A module must export this symbol with exactly this signature, returning XY_CTX_ABI_DESC. xy-mod.h emits it automatically for C modules and xy_module!() does so for Rust modules; a hand-written module that only exports get_xy_ptr must add it by hand.
The host compares the returned descriptor against its own before writing anything into the module's context. A module built against a different header has an object of a different size, and the host's write would overrun it โ corrupting unrelated data in the module's BSS rather than failing. A module that does not export this symbol at all is refused the same way, because an unversioned module cannot be proven safe.
Only modules that actually have a context need this. A module that exports neither get_xy_ptr nor a xy_self_init_ctx call has nothing for the host to write into, so there is nothing to overrun and nothing to declare; bootstrap modules like the site's core are in that class and load unchanged.
Returns
XY_CTX_ABI_DESC as compiled into the calling module.
Author
Generated automatically by Doxygen for libxylem from the source code.