2024-06-12 15:13:09 +08:00
|
|
|
#![deny(
|
|
|
|
future_incompatible,
|
|
|
|
let_underscore,
|
|
|
|
nonstandard_style,
|
|
|
|
rust_2024_compatibility,
|
|
|
|
clippy::all
|
|
|
|
)]
|
2024-06-12 12:27:35 +08:00
|
|
|
#![warn(clippy::pedantic)]
|
|
|
|
#![allow(clippy::semicolon_if_nothing_returned, clippy::uninlined_format_args)]
|
|
|
|
|
2021-10-31 23:52:43 +08:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
static mut NOW: i64 = 0;
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn now_mu() -> i64 {
|
|
|
|
unsafe { NOW }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn at_mu(t: i64) {
|
|
|
|
unsafe { NOW = t }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn delay_mu(dt: i64) {
|
|
|
|
unsafe { NOW += dt }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn rtio_init() {
|
|
|
|
println!("rtio_init");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn rtio_get_counter() -> i64 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn rtio_output(target: i32, data: i32) {
|
2024-06-12 15:13:09 +08:00
|
|
|
println!("rtio_output @{} target={target:04x} data={data}", unsafe { NOW });
|
2021-10-31 23:52:43 +08:00
|
|
|
}
|
|
|
|
|
2021-11-10 17:34:13 +08:00
|
|
|
#[no_mangle]
|
2021-11-19 12:39:57 +08:00
|
|
|
pub extern "C" fn print_int32(x: i32) {
|
2024-06-12 15:13:09 +08:00
|
|
|
println!("print_int32: {x}");
|
2021-11-19 12:39:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub extern "C" fn print_int64(x: i64) {
|
2024-06-12 15:13:09 +08:00
|
|
|
println!("print_int64: {x}");
|
2021-11-10 17:34:13 +08:00
|
|
|
}
|
|
|
|
|
2022-02-13 13:03:38 +08:00
|
|
|
#[no_mangle]
|
2022-02-23 11:43:41 +08:00
|
|
|
pub extern "C" fn __nac3_personality(_state: u32, _exception_object: u32, _context: u32) -> u32 {
|
2022-02-13 13:03:38 +08:00
|
|
|
unimplemented!();
|
|
|
|
}
|
|
|
|
|
2021-10-31 23:52:43 +08:00
|
|
|
fn main() {
|
|
|
|
let filename = env::args().nth(1).unwrap();
|
|
|
|
unsafe {
|
|
|
|
let lib = libloading::Library::new(filename).unwrap();
|
2024-06-12 14:45:03 +08:00
|
|
|
let func: libloading::Symbol<unsafe extern "C" fn()> = lib.get(b"__modinit__").unwrap();
|
2024-06-12 15:13:09 +08:00
|
|
|
func();
|
2021-10-31 23:52:43 +08:00
|
|
|
}
|
|
|
|
}
|