diff --git a/src/box2dxt.lcb b/src/box2dxt.lcb index 54a2b6a..cb2a01c 100644 --- a/src/box2dxt.lcb +++ b/src/box2dxt.lcb @@ -442,8 +442,8 @@ private foreign handler _query_normal_y(in pI as CInt) returns CDouble binds to private foreign handler _query_fraction(in pI as CInt) returns CDouble binds to "c:box2dxt>b2lc_query_fraction!cdecl" -- ---- native loader assist (Linux) ---------------------------------- --- The ONLY two bindings that do NOT target the box2dxt shim: they bind to --- the platform's own dynamic loader (dlopen/dlerror), resolved from the +-- The ONLY three bindings that do NOT target the box2dxt shim: they bind to +-- the platform's own loader/libc (dlopen/dlerror/realpath), resolved from the -- host process's global symbol table. That is the whole point -- they must -- be callable BEFORE box2dxt.so is loadable, so a script can preload the -- shim by absolute path. On Linux the engine hands the bare name @@ -459,6 +459,10 @@ private foreign handler _query_fraction(in pI as CInt) returns CDouble binds to -- dlopen still lives in libdl -> "c:libdl.so.2>dlopen!cdecl". private foreign handler _dlopen(in pPath as ZStringNative, in pFlags as CInt) returns optional Pointer binds to "c:>dlopen!cdecl" private foreign handler _dlerror() returns optional ZStringNative binds to "c:>dlerror!cdecl" +-- realpath("/proc/self/exe", nil) -> the running engine's own executable path +-- on Linux; used by the b2LoadNativeLibHere helper below to locate the engine +-- folder. Returns nothing off Linux (no /proc). Only ever called on Linux. +private foreign handler _realpath(in pPath as ZStringNative, in pResolved as optional Pointer) returns optional ZStringNative binds to "c:>realpath!cdecl" -- small bool -> int helper (no foreign call, so no unsafe needed) private handler bi(in pB as Boolean) returns Integer @@ -468,6 +472,57 @@ private handler bi(in pB as Boolean) returns Integer return 0 end handler +-- ---- engine-folder preload (Linux helper) -------------------------- +-- Locate the running engine's OWN folder (realpath /proc/self/exe), strip to +-- its directory, and preload "