Files
hakorune/src/abi/nyrt_shim.rs

45 lines
1.2 KiB
Rust
Raw Normal View History

// CABI shim (PoC). These functions are noops for 20.36/20.37.
// Kept tiny and isolated. Linkage names match include/nyrt.h.
#[no_mangle]
pub extern "C" fn nyrt_init() -> i32 { 0 }
#[no_mangle]
pub extern "C" fn nyrt_teardown() { }
#[no_mangle]
pub extern "C" fn nyrt_load_mir_json(_json_text: *const ::std::os::raw::c_char) -> u64 { 1 }
#[no_mangle]
pub extern "C" fn nyrt_exec_main(_module_handle: u64) -> i32 { 0 }
#[no_mangle]
pub extern "C" fn nyrt_hostcall(
_name: *const ::std::os::raw::c_char,
_method: *const ::std::os::raw::c_char,
_payload_json: *const ::std::os::raw::c_char,
_out_buf: *mut ::std::os::raw::c_char,
_out_buf_len: u32,
) -> i32 { 0 }
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::CString;
#[test]
fn load_and_exec_noop_returns_zero() {
// init/teardown are no-ops but should stay callable
assert_eq!(unsafe { nyrt_init() }, 0);
let json = CString::new("{}").expect("CString");
let handle = unsafe { nyrt_load_mir_json(json.as_ptr()) };
assert_eq!(handle, 1);
assert_eq!(unsafe { nyrt_exec_main(handle) }, 0);
// ensure teardown does not panic even when called after exec
unsafe { nyrt_teardown() };
}
}