Function libffi::low::call
[−]
[src]
pub unsafe fn call<R>(
cif: *mut ffi_cif,
fun: CodePtr,
args: *mut *mut c_void
) -> R
Calls a C function as specified by a CIF.
Arguments
cif— describes the argument and result types and the calling conventionfun— the function to callargs— the arguments to pass tofun
Result
The result of calling fun with args.
Examples
use std::os::raw::c_void; use libffi::low::*; extern "C" fn c_function(a: u64, b: u64) -> u64 { a + b } let result = unsafe { let mut args: Vec<*mut ffi_type> = vec![ &mut types::uint64, &mut types::uint64 ]; let mut cif: ffi_cif = Default::default(); prep_cif(&mut cif, ffi_abi_FFI_DEFAULT_ABI, 2, &mut types::uint64, args.as_mut_ptr()).unwrap(); call(&mut cif, CodePtr(c_function as *mut _), vec![ &mut 4u64 as *mut _ as *mut c_void, &mut 5u64 as *mut _ as *mut c_void ].as_mut_ptr()) }; assert_eq!(9, result);