pub struct BareFnOnce<B: Copy, F, A: JitAlloc = GlobalJitAlloc> { /* private fields */ }Expand description
Wrapper around a
FnOnce
closure which exposes a bare function thunk that can invoke it without
additional arguments.
Implementations§
Source§impl<B: Copy, F, A: JitAlloc> BareFnOnce<B, F, A>
impl<B: Copy, F, A: JitAlloc> BareFnOnce<B, F, A>
Sourcepub fn with_jit_alloc<CC>(
cconv: CC,
fun: F,
jit_alloc: A,
) -> Result<Self, JitAllocError>where
(CC, F): FnOnceThunk<CC, B>,
👎Deprecated since 0.3.0: please use try_new_in instead
pub fn with_jit_alloc<CC>(
cconv: CC,
fun: F,
jit_alloc: A,
) -> Result<Self, JitAllocError>where
(CC, F): FnOnceThunk<CC, B>,
try_new_in insteadWraps fun, producing a bare function with calling convention
cconv.
Uses the provided JIT allocator to allocate the W^X memory used to create the thunk.
Sourcepub fn try_new_in<CC>(
cconv: CC,
fun: F,
jit_alloc: A,
) -> Result<Self, JitAllocError>where
(CC, F): FnOnceThunk<CC, B>,
pub fn try_new_in<CC>(
cconv: CC,
fun: F,
jit_alloc: A,
) -> Result<Self, JitAllocError>where
(CC, F): FnOnceThunk<CC, B>,
Wraps fun, producing a bare function with calling convention
cconv.
Uses the provided JIT allocator to allocate the W^X memory used to create the thunk.
Sourcepub fn new_in<CC>(cconv: CC, fun: F, jit_alloc: A) -> Selfwhere
(CC, F): FnOnceThunk<CC, B>,
pub fn new_in<CC>(cconv: CC, fun: F, jit_alloc: A) -> Selfwhere
(CC, F): FnOnceThunk<CC, B>,
Wraps fun, producing a bare function with calling convention
cconv.
Uses jit_alloc to allocate the W^X memory used to create the thunk.
§Panics
If the provided JIT allocator fails to allocate memory. For a non-panicking
version, see try_new_in.
Sourcepub fn new_c_in(fun: F, jit_alloc: A) -> Self
pub fn new_c_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
C
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_system_in(fun: F, jit_alloc: A) -> Self
pub fn new_system_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
system
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_sysv64_in(fun: F, jit_alloc: A) -> Self
Available on non-Windows and x86-64 only.
pub fn new_sysv64_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
sysv64
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_aapcs_in(fun: F, jit_alloc: A) -> Self
Available on ARM only.
pub fn new_aapcs_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
aapcs
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_fastcall_in(fun: F, jit_alloc: A) -> Self
Available on Windows and (x86-64 or x86) only.
pub fn new_fastcall_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
fastcall
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_stdcall_in(fun: F, jit_alloc: A) -> Self
Available on Windows and (x86-64 or x86) only.
pub fn new_stdcall_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
stdcall
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_cdecl_in(fun: F, jit_alloc: A) -> Self
Available on Windows and (x86-64 or x86) only.
pub fn new_cdecl_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
cdecl
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_thiscall_in(fun: F, jit_alloc: A) -> Self
Available on Windows and x86 only.
pub fn new_thiscall_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
thiscall
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn new_win64_in(fun: F, jit_alloc: A) -> Self
Available on Windows and x86-64 only.
pub fn new_win64_in(fun: F, jit_alloc: A) -> Self
Create a bare function thunk using the
win64
calling convention for fun.
The W^X memory required is allocated using the provided JIT allocator.
Sourcepub fn leak(self) -> Bwhere
Self: 'static,
pub fn leak(self) -> Bwhere
Self: 'static,
Leak the underlying closure, returning the unsafe bare function pointer that invokes it.
self must be 'static for this method to be called.
§Safety
While this method is safe, the returned function pointer is not. In particular, it must not be called when:
-
The function has been called before.
-
The closure is not
Send, if calling from a different thread than the current one.
Source§impl<B: Copy, F> BareFnOnce<B, F, GlobalJitAlloc>
impl<B: Copy, F> BareFnOnce<B, F, GlobalJitAlloc>
Sourcepub fn new<CC>(cconv: CC, fun: F) -> Selfwhere
(CC, F): FnOnceThunk<CC, B>,
Available on crate feature bundled_jit_alloc only.
pub fn new<CC>(cconv: CC, fun: F) -> Selfwhere
(CC, F): FnOnceThunk<CC, B>,
bundled_jit_alloc only.Wraps fun, producing a bare function with calling convention cconv.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_c(fun: F) -> Self
Available on crate feature bundled_jit_alloc only.
pub fn new_c(fun: F) -> Self
bundled_jit_alloc only.Create a bare function thunk using the
C
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_system(fun: F) -> Self
Available on crate feature bundled_jit_alloc only.
pub fn new_system(fun: F) -> Self
bundled_jit_alloc only.Create a bare function thunk using the
system
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_sysv64(fun: F) -> Self
Available on non-Windows and x86-64 and crate feature bundled_jit_alloc only.
pub fn new_sysv64(fun: F) -> Self
bundled_jit_alloc only.Create a bare function thunk using the
sysv64
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_aapcs(fun: F) -> Self
Available on crate feature bundled_jit_alloc and ARM only.
pub fn new_aapcs(fun: F) -> Self
bundled_jit_alloc and ARM only.Create a bare function thunk using the
aapcs
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_fastcall(fun: F) -> Self
Available on Windows and (x86-64 or x86) and crate feature bundled_jit_alloc only.
pub fn new_fastcall(fun: F) -> Self
bundled_jit_alloc only.Create a bare function thunk using the
fastcall
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_stdcall(fun: F) -> Self
Available on Windows and (x86-64 or x86) and crate feature bundled_jit_alloc only.
pub fn new_stdcall(fun: F) -> Self
bundled_jit_alloc only.Create a bare function thunk using the
stdcall
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_cdecl(fun: F) -> Self
Available on Windows and (x86-64 or x86) and crate feature bundled_jit_alloc only.
pub fn new_cdecl(fun: F) -> Self
bundled_jit_alloc only.Create a bare function thunk using the
cdecl
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.
Sourcepub fn new_thiscall(fun: F) -> Self
Available on Windows and x86 and crate feature bundled_jit_alloc only.
pub fn new_thiscall(fun: F) -> Self
bundled_jit_alloc only.Create a bare function thunk using the
thiscall
calling convention for fun.
The W^X memory required is allocated using the global JIT allocator.