1#![allow(clippy::missing_safety_doc, clippy::too_many_arguments, non_snake_case)]
13
14pub mod array;
15pub mod closure;
16pub mod float;
17pub mod fs;
18pub mod handle;
19pub mod int;
20pub mod io;
21pub mod io_error;
22pub mod marshal;
23pub mod model;
24pub mod nat;
25pub mod object;
26pub mod panic;
27pub mod process;
28pub mod string;
29pub mod thunk;
30pub mod uint;
31
32pub use array::*;
33pub use closure::*;
34pub use float::*;
35pub use fs::*;
36pub use handle::*;
37pub use int::*;
38pub use io::*;
39pub use io_error::*;
40pub use marshal::*;
41pub use model::*;
42pub use nat::*;
43pub use object::*;
44pub use panic::*;
45pub use process::*;
46pub use string::*;
47pub use thunk::*;
48pub use uint::*;
49
50pub unsafe fn lean_system_platform_nbits(_unit: Obj) -> Obj {
52 lean_box(usize::BITS as usize)
53}
54
55pub unsafe fn lean_system_platform_windows(_unit: Obj) -> u8 {
57 cfg!(windows) as u8
58}
59
60pub unsafe fn lean_system_platform_osx(_unit: Obj) -> u8 {
62 cfg!(target_os = "macos") as u8
63}
64
65pub unsafe fn lean_system_platform_linux(_unit: Obj) -> u8 {
67 cfg!(target_os = "linux") as u8
68}
69
70pub unsafe fn lean_system_platform_emscripten(_unit: Obj) -> u8 {
72 cfg!(target_os = "emscripten") as u8
73}
74
75pub unsafe fn lean_system_platform_target(_unit: Obj) -> Obj {
77 lean_mk_string(env!("LEANFRAN_TARGET"))
78}
79
80pub unsafe fn lean_internal_get_hardware_concurrency(_unit: Obj) -> u32 {
82 std::thread::available_parallelism().map_or(0, |n| n.get() as u32)
83}
84
85pub unsafe fn lean_ptr_addr_unsafe(a: Obj) -> usize {
87 lean_ptr_addr(a)
88}
89
90include!(concat!(env!("OUT_DIR"), "/externs.rs"));
91
92#[doc(hidden)]
94pub fn runtime_externs_lean() -> String {
95 let mut s = String::from(
96 "/-! C names of the functions the runtime `leanfran-runtime` provides. Generated by `make gen-externs`. -/\n\nnamespace LeanRust\n\ndef runtimeExterns : Array String := #[\n",
97 );
98 let items: Vec<String> = EXTERNS.iter().map(|n| format!(" \"{n}\"")).collect();
99 s.push_str(&items.join(",\n"));
100 s.push_str("\n]\n\nend LeanRust\n");
101 s
102}