Releases: tremwil/closure-ffi
Releases · tremwil/closure-ffi
v5.1.2
Added
- Calling convention marker types are no longer limited by operating system, but purely target architecture.
- CI tests for additional targets:
armv7(soft and hard float) andthumbv7Linux
Fixed
- C-variadic calling convention support (was broken by changes to the nightly feature)
- Linker errors on x86 for platforms that don't allow absolute relocations in code sections
- Make
global_jit_alloc-written code compatible withdefault_jit_alloc. With this configuration,
the allocator provided by theglobal_jit_alloc!macro will be ignored.
v5.0.1
Fixed
- Use forked
iced-x86crate to avoid conflicts with dependents using it with thestdfeature. This is temporary until a new iced version is released to allowstdandno_stdfeatures to be enabled at the same time.
v5.0.0
Breaking Changes
- Compiling with a Thumb JSON target file will now require Nightly Rust.
- With the addition of the
safe_jitfeature, compiling with--no-default-featureswill now error
unless theno_safe_jitfeature is explicitly enabled to prevent accidentally forgetting to enablesafe_jit. - Strengthened trait bounds on
FnPtr::CCto make some APIs more ergonomic. This is technically a breaking change but is realistically harmless, asFnPtrshould not be implemented by the end user. - Changed the
JitAllocblanket impl from&Jfor allJ: JitAllocto any type implementingDeref<Target = J>. This is more general and avoids having to write forwarding impls when putting aJitAllocin aLazyLock, for example, but may break some downstreamJitAllocwrappers.
Added
-
Thunk generation is now fully safe thanks to the
safe_jitfeature, which uses a disassembler to properly relocate the prologue code instead of assuming it is trivially relocatable. This brings an end to this crate's UB issues. -
Support for the
efiapiandRustcalling conventions.
Fixed
global_jit_allocmacro ambiguous parsing for the unsafe block variant.- Incorrect relocation of thunk prologues on
i686-unknown-linux-gnu.
Removed
- i686-specific Windows calling conventions from x64 Windows targets.
v4.1.0
Changed
- Thunk generation modified to be a zero-cost abstraction: For functions items and non-capturing closures, constructing a
BareFn*type will not allocate or emit code. Instead, it will use a compile-time template that conjures an instance of the ZST to invoke it. - Added changelog to the documentation.
- Added UB warning to the documentation.
v4.0.0
This update adds the scaffolding required to implement "higher order" transformations on bare function thunks. For example, it is now possible to write a function that synchonizes an generic FnMutThunk implementation while printing its return value:
use closure_ffi::{thunk_factory, traits::{FnPtr, FnThunk, FnMutThunk}};
fn lock_and_debug<B: FnPtr, F: Send>(fun: F) -> impl FnThunk<B> + Sync
where
for<'a, 'b, 'c> B::Ret<'a, 'b, 'c>: core::fmt::Debug,
(cc::C, F): FnMutThunk<B>,
{
let locked = std::sync::Mutex::new((cc::C, fun));
thunk_factory::make_sync(move |args| unsafe {
let ret = locked.lock().unwrap().call_mut(args);
println!("value: {ret:?}");
ret
})
}This is particularly useful for hooking libraries.
Breaking Changes
- Removed
where Self: 'a + 'b + 'cbounds onFnPtr::ArgsandFnPtr::Ret - Regression in the expressivity of
bare_hrtb!(): Now requires a'staticbound on certain generic parameters - removed zero-variant enum from
FnPtr::Argsfor extern variaric functions to be able to implement the new trait functions.FnPtr::callnow const panics instead of being impossible to call for them.
Added
FnPtr::make_*_thunkfunctions that can create aFn*Thunkimplementation from a closure with tuple-packed arguments.FnOnceThunk::call_once,FnMutThunk::call_mutandFnThunk::callfor invoking the underlying closure with tuple-packed arguments.thunk_factorymodule for creatingFn*Thunkimplementations that satisfy combinations ofSendandSyncbounds.
Fixed
libcdependency not compatible withno_stdon Linux ARM targets
v3.0.1
Fixed
- docs.rs build
v3.0.0
Breaking Changes
ToBoxedUnsizehas been renamed toToBoxedDynis now an unsafe trait. See the documentation for the
new invariants.SendandSyncimpl bounds onBareFnare now stricter to catch more unsafety.- Major overhaul of feature flags. See README to view the changes.
Added
UntypedBareFn*types that erase the bare function type entirely. Can be used to store
BareFn*wrappers of different types in a data structure.coverageunstable feature to support the-C instrument-coveragerustc flag.
Changed
- Change thunk assembly magic numbers/sentinel values to sequences that are guaranteed to not be emitted by the compiler.
Thanks to @Dasaav-dsv for the help. - Move the arch/feature compile_error checks into the build script for better errors.
- Dual license under Apache-2.0 and MIT.
v2.4.0
Added
c_variadicfeature to add partial support for C variadic functions.
v2.3.0
Added
tuple_traitfeature to add acore::marker::Tuplebound toFnPtr::Args, allowing better
interoperability with other Nightly features such asfn_traitsandunboxed_closures.
Changed
- use
dep:crateoptional dependency toggles to prevent implicit dependency named features.
This is technically a breaking change, but as these features are not documented I have decided
to not bump the major version.
v2.2.0
Fixed
bundled_jit_allocshould now work oni686-pc-windows-msvcwithout linker errors
Changed
- Bundled JIT allocator now uses
jit-allocator2, a maintained fork ofjit-allocatorwhich fixes a linker issue oni686-pc-windows-msvc.