.TH "ttypt/xy-mod.h" 3 "libxylem" \" -*- nroff -*- .ad l .nh .SH NAME ttypt/xy-mod.h \- Module-side implementation glue for the xy module system\&. .SH SYNOPSIS .br .PP \fR#include 'xy\&.h'\fP .br .SS "Macros" .in +1c .ti -1c .RI "#define \fBxy_load\fP(fname)" .br .RI "Load a module into the caller's current region\&. " .ti -1c .RI "#define \fBxy_deny\fP(what, type)" .br .RI "Deny a hook or module within the caller's current region\&. " .ti -1c .RI "#define \fBxy_require_claim\fP(fn, ud)" .br .RI "Set or clear the claim gate on the caller's current region\&. " .ti -1c .RI "#define \fBxy_region_each\fP(fn, ud)" .br .RI "Enumerate immediate child regions of the caller's current region\&. " .ti -1c .RI "#define \fBxy_with_region\fP(region_id, plen, fn, ud)" .br .RI "Run \fRfn\fP with the caller's current region temporarily set to the region identified by (\fRregion_id\fP, \fRplen\fP)\&. " .ti -1c .RI "#define \fBxy_current_region\fP()" .br .RI "Return the id half of the current region identity for this thread\&. " .ti -1c .RI "#define \fBxy_current_region_plen\fP()" .br .RI "Return the plen half of the current region identity\&. " .ti -1c .RI "#define \fBxy_region_exists\fP(region_id, plen)" .br .RI "Test whether the region identified by (\fRregion_id\fP, \fRplen\fP) exists and is addressable\&. " .ti -1c .RI "#define \fBxy_claim_at\fP(id, plen, fn, ud)" .br .RI "Create the region identified by (\fRid\fP, \fRplen\fP), or reuse it\&. " .ti -1c .RI "#define \fBxy_region_at\fP(prefix_id, plen, region_plen)" .br .RI "Find the deepest existing region whose prefix covers a point\&. " .ti -1c .RI "#define \fBXY_CALL_SELF\fP(retp, fname, \&.\&.\&.)" .br .RI "Dispatch to the current region's own modules only\&. " .ti -1c .RI "#define \fBxy_unload\fP(fname)" .br .RI "Unload a module from the caller's current region\&. " .ti -1c .RI "#define \fBxy_reload\fP(fname)" .br .RI "Reload a module in place in the caller's current region\&. " .ti -1c .RI "#define \fBxy_my_region\fP()" .br .RI "Return the region ID assigned to this module (diagnostic/internal)\&. " .ti -1c .RI "#define \fBXY_REGION_STATE\fP struct xy_rs_s" .br .ti -1c .RI "#define \fBXY_REGION_INIT\fP" .br .ti -1c .RI "#define \fBXY_RS\fP ((struct xy_rs_s *)xy\&.region_state)" .br .in -1c .SS "Functions" .in +1c .ti -1c .RI "\fBXY_MODULE_API\fP XY_MOD_WEAK_ uint64_t \fBxy_ctx_abi\fP (void)" .br .RI "Report this module's xy_ctx ABI generation and size\&. " .in -1c .SH "Detailed Description" .PP 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\&. .SH "Macro Definition Documentation" .PP .SS "#define XY_CALL_SELF( retp, fname, \&.\&.\&.)" \fBValue:\fP .nf { \\ struct fname##_args args = { __VA_ARGS__ }; \\ xy\&.call_self(retp, &fname##_adapter, &args); \\ } .PP .fi .PP Dispatch to the current region's own modules only\&. The exact-region counterpart of \fBXY_CALL()\fP, 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 \fBXY_CALL()\fP\&. .SS "#define xy_claim_at( id, plen, fn, ud)" \fBValue:\fP .nf xy_mod_claim_at_(&xy, (id), (plen), (fn), (ud)) .PP .fi .PP Create the region identified by (\fRid\fP, \fRplen\fP), or reuse it\&. On success the region is the module's current region, so a following \fBxy_load()\fP lands inside it\&. Rejects plen > 64, a misaligned \fRid\fP, and a \fRplen\fP that is not strictly wider than the region's nearest existing ancestor; an exact match is idempotent\&. The rejection is about WIDTH, never about \fRid\fP equalling the ancestor's -- claiming (0,16) under the root (0,0) widens the region and is legal\&. \fRid\fP carries its prefix in the high bits above \fRplen\fP and its width is never inferred from it -- pass both halves\&. .SS "#define xy_current_region_plen()" \fBValue:\fP .nf xy_mod_current_region_plen_(&xy) .PP .fi .PP Return the plen half of the current region identity\&. Reads the thread-local entry directly — no lookup, no ambiguity\&. 0 for the root region\&. .SS "#define xy_deny( what, type)" \fBValue:\fP .nf xy_mod_deny_(&xy, (what), (type)) .PP .fi .PP Deny a hook or module within the caller's current region\&. The deny applies to the caller's current region and all its descendants\&. .PP \fBParameters\fP .RS 4 \fIwhat\fP Hook name (XY_DENY_HOOK) or module path (XY_DENY_MODULE) .br \fItype\fP XY_DENY_HOOK or XY_DENY_MODULE .RE .PP .SS "#define xy_load( fname)" \fBValue:\fP .nf xy_mod_load_(&xy, (fname)) .PP .fi .PP Load a module into the caller's current region\&. .PP \fBParameters\fP .RS 4 \fIfname\fP Path to \&.so / \&.dll .RE .PP .SS "#define xy_region_at( prefix_id, plen, region_plen)" \fBValue:\fP .nf xy_mod_region_at_(&xy, (prefix_id), (plen), (region_plen)) .PP .fi .PP Find the deepest existing region whose prefix covers a point\&. .PP \fBParameters\fP .RS 4 \fIregion_plen\fP Out-param for the covering region's width; set to 0 on every failure path\&. May be NULL\&. .RE .PP \fBReturns\fP .RS 4 The covering region's id half, or XY_REGION_INVALID if none\&. .RE .PP .SS "#define xy_region_each( fn, ud)" \fBValue:\fP .nf xy_mod_region_each_(&xy, (fn), (ud)) .PP .fi .PP Enumerate immediate child regions of the caller's current region\&. .PP \fBParameters\fP .RS 4 \fIfn\fP Callback: fn(child_id, plen, ud)\&. Return XY_OK to continue\&. .br \fIud\fP User data passed to fn .RE .PP .SS "#define xy_region_exists( region_id, plen)" \fBValue:\fP .nf xy_mod_region_exists_(&xy, (region_id), (plen)) .PP .fi .PP Test whether the region identified by (\fRregion_id\fP, \fRplen\fP) exists and is addressable\&. .PP \fBReturns\fP .RS 4 XY_OK if that exact region exists, XY_ERR_NOTFOUND otherwise\&. .RE .PP .SS "#define XY_REGION_INIT" \fBValue:\fP .nf XY_MODULE_API size_t xy_region_state_size(void) \\ { return sizeof(struct xy_rs_s); } .PP .fi Emit the xy_region_state_size() export after the struct definition\&. .SS "#define XY_REGION_STATE struct xy_rs_s" Begin per-region state struct declaration\&. .SS "#define xy_reload( fname)" \fBValue:\fP .nf xy_mod_reload_(&xy, (fname)) .PP .fi .PP Reload a module in place in the caller's current region\&. .PP \fBParameters\fP .RS 4 \fIfname\fP Path passed to \fBxy_load()\fP (without \&.so/\&.dll suffix) .RE .PP .SS "#define xy_require_claim( fn, ud)" \fBValue:\fP .nf xy_mod_require_claim_(&xy, (fn), (ud)) .PP .fi .PP Set or clear the claim gate on the caller's current region\&. Non-NULL fn: enables the gate — subsequent \fBxy_load()\fP calls require an xy_claim symbol from the module\&. NULL fn: clears the gate — subsequent \fBxy_load()\fP calls need no xy_claim\&. .PP \fBParameters\fP .RS 4 \fIfn\fP Claim handler function, or NULL to clear\&. .br \fIud\fP User data passed to fn (ignored when fn is NULL)\&. .RE .PP .SS "#define XY_RS ((struct xy_rs_s *)xy\&.region_state)" Typed pointer to the current region's state block\&. .SS "#define xy_unload( fname)" \fBValue:\fP .nf xy_mod_unload_(&xy, (fname)) .PP .fi .PP Unload a module from the caller's current region\&. .PP \fBParameters\fP .RS 4 \fIfname\fP Path passed to \fBxy_load()\fP (without \&.so/\&.dll suffix) .RE .PP .SS "#define xy_with_region( region_id, plen, fn, ud)" \fBValue:\fP .nf xy_mod_with_region_(&xy, (region_id), (plen), (fn), (ud)) .PP .fi .PP Run \fRfn\fP with the caller's current region temporarily set to the region identified by (\fRregion_id\fP, \fRplen\fP)\&. Nested hook calls inside \fRfn\fP inherit that region\&. .PP \fBReturns\fP .RS 4 XY_ERR_NOTFOUND if no region with that exact (id, plen) exists\&. .RE .PP .SH "Function Documentation" .PP .SS "\fBXY_MODULE_API\fP XY_MOD_WEAK_ uint64_t xy_ctx_abi (void )" .PP Report this module's xy_ctx ABI generation and size\&. A module \fBmust\fP export this symbol with exactly this signature, returning \fBXY_CTX_ABI_DESC\fP\&. \fR\fBxy-mod\&.h\fP\fP emits it automatically for C modules and \fRxy_module!()\fP does so for Rust modules; a hand-written module that only exports \fRget_xy_ptr\fP must add it by hand\&. .PP 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\&. .PP Only modules that actually \fIhave\fP a context need this\&. A module that exports neither \fRget_xy_ptr\fP nor a \fR\fBxy_self_init_ctx\fP\fP 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 \fRcore\fP are in that class and load unchanged\&. .PP \fBReturns\fP .RS 4 \fBXY_CTX_ABI_DESC\fP as compiled into the calling module\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for libxylem from the source code\&.