Conversation
hellerve
approved these changes
Aug 26, 2026
Member
|
Thank you for your contribution! One more |
Member
|
i took over the reformat in #6. i ported your commit over, so attribution stays the same! thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This keeps the existing
DynLib.open/getAPI intact and adds an ownership-aware typed binding path:DynLib.open-owned+DynLib.defbinderproduce a bound function that owns its loader handle; dropping the function closes the handle.DynLib.open-pinned+DynLib.defpinned-binderintentionally retain a process-lifetime handle and let many functions borrow it. This is the conservative default for callbacks, TLS, Rustcdylibs, and foreign libraries that may retain references to their own code.DynLibBoundFn.call0..call8andDynLibPinnedFn.call0..call8invoke the statically declared signature.dlsymhelpers returnLambdaby value, avoiding the allocation leaked by the compatibility lookup.dlerror()text.The binder signature remains an explicit C ABI assertion.
dlsymhas no portable type reflection, so generated bindings should derive it from an authoritative header or adapter descriptor.Why two lifetime modes?
An owned binding makes the common safety relationship representable in Carp: the callable cannot outlive the
dlopenhandle it contains. It uses one handle per bound function; platform loaders normally reference-count repeated opens of the same image.Pinned loading handles the cases where unloading cannot be proven safe. Its type has no deleter, and binders only borrow it, so one pinned image can provide many functions without manufacturing false unload guarantees.
Compatibility
The original polymorphic API and examples continue to work unchanged. The README now recommends typed binders for new code and documents the remaining ABI assertion.
Validation
floorfloor,ceil, and binarypow