forked from M-Labs/nac3
David Mak
2822074b2d
- Remove rust_2024_edition warnings, since it wouldn't be released for another 3 months - Fix new clippy warnings
62 lines
1.4 KiB
Rust
62 lines
1.4 KiB
Rust
#![deny(future_incompatible, let_underscore, nonstandard_style, clippy::all)]
|
|
#![warn(clippy::pedantic)]
|
|
#![allow(clippy::semicolon_if_nothing_returned, clippy::uninlined_format_args)]
|
|
|
|
use std::env;
|
|
|
|
static mut NOW: i64 = 0;
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn now_mu() -> i64 {
|
|
unsafe { NOW }
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn at_mu(t: i64) {
|
|
unsafe { NOW = t }
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn delay_mu(dt: i64) {
|
|
unsafe { NOW += dt }
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn rtio_init() {
|
|
println!("rtio_init");
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn rtio_get_counter() -> i64 {
|
|
0
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn rtio_output(target: i32, data: i32) {
|
|
println!("rtio_output @{} target={target:04x} data={data}", unsafe { NOW });
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn print_int32(x: i32) {
|
|
println!("print_int32: {x}");
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn print_int64(x: i64) {
|
|
println!("print_int64: {x}");
|
|
}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn __nac3_personality(_state: u32, _exception_object: u32, _context: u32) -> u32 {
|
|
unimplemented!();
|
|
}
|
|
|
|
fn main() {
|
|
let filename = env::args().nth(1).unwrap();
|
|
unsafe {
|
|
let lib = libloading::Library::new(filename).unwrap();
|
|
let func: libloading::Symbol<unsafe extern "C" fn()> = lib.get(b"__modinit__").unwrap();
|
|
func();
|
|
}
|
|
}
|