Function libffi::low::prep_cif
[−]
[src]
pub unsafe fn prep_cif(
cif: *mut ffi_cif,
abi: ffi_abi,
nargs: usize,
rtype: *mut ffi_type,
atypes: *mut *mut ffi_type
) -> Result<()>
Initalizes a CIF (Call Interface) with the given ABI and types.
We need to initialize a CIF before we can use it to call a function
or create a closure. This function lets us specify the calling
convention to use and the argument and result types. For varargs
CIF initialization, see prep_cif_var
.
Safety
The CIF cif
retains references to rtype
and atypes
, so if
they are no longer live when the CIF is used then the behavior is
undefined.
Arguments
cif
— the CIF to initializeabi
— the calling convention to usenargs
— the number of argumentsrtype
— the result typeatypes
— the argument types (length must be at leastnargs
)
Result
Ok(())
for success or Err(e)
for failure.
Examples
use libffi::low::*; let mut args: [*mut ffi_type; 2] = unsafe { [ &mut types::sint32, &mut types::uint64 ] }; let mut cif: ffi_cif = Default::default(); unsafe { prep_cif(&mut cif, ffi_abi_FFI_DEFAULT_ABI, 2, &mut types::pointer, args.as_mut_ptr()) }.unwrap();