1#![no_std]
2extern crate alloc;
3use alloc::vec::Vec;
4
5extern crate cstring;
6pub use cstring::{cstr, CString};
7
8mod v1 {
9 use super::*;
10 extern "C" {
11 pub fn register_scope(scope: CString);
12 pub fn device_error(err: CString);
13 }
14}
15
16pub fn register_scope(scope: &str) {
17 unsafe {
18 v1::register_scope(cstr(scope));
19 }
20}
21
22pub fn device_error(scope: &str) {
23 unsafe {
24 v1::device_error(cstr(scope));
25 }
26}
27
28#[no_mangle]
29fn malloc(size: usize) -> *mut u8 {
30 let mut buf = Vec::with_capacity(size as usize);
31 let ptr = buf.as_mut_ptr();
32 core::mem::forget(buf);
33 ptr
34}