use super::*;
pub type WeldRuntimeContextRef = *mut WeldRuntimeContext;
#[no_mangle]
pub unsafe extern "C" fn weld_init() {
initialize();
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_init(nworkers: i32, memlimit: i64) -> WeldRuntimeContextRef {
Box::into_raw(Box::new(WeldRuntimeContext::new(nworkers, memlimit)))
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_release(run: WeldRuntimeContextRef) {
Box::from_raw(run);
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_malloc(run: WeldRuntimeContextRef, size: i64) -> Ptr {
let run = &mut *run;
run.malloc(size)
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_realloc(
run: WeldRuntimeContextRef,
ptr: Ptr,
newsize: i64,
) -> Ptr {
let run = &mut *run;
run.realloc(ptr, newsize)
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_free(run: WeldRuntimeContextRef, ptr: Ptr) {
let run = &mut *run;
run.free(ptr)
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_set_result(run: WeldRuntimeContextRef, ptr: Ptr) {
let run = &mut *run;
run.set_result(ptr)
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_set_errno(run: WeldRuntimeContextRef, errno: WeldRuntimeErrno) {
let run = &mut *run;
run.set_errno(errno)
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_get_errno(run: WeldRuntimeContextRef) -> WeldRuntimeErrno {
let run = &mut *run;
run.errno()
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_get_result(run: WeldRuntimeContextRef) -> Ptr {
let run = &mut *run;
run.result()
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_assert(run: WeldRuntimeContextRef, cond: u8) -> u8 {
let run = &mut *run;
if cond == 0 {
run.set_errno(WeldRuntimeErrno::AssertionError);
unreachable!()
} else {
1
}
}
#[no_mangle]
pub unsafe extern "C" fn weld_runst_print(_run: WeldRuntimeContextRef, string: *const c_char) {
let string = CStr::from_ptr(string).to_str().unwrap();
println!("{} ", string);
}