Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix link error in ensure_no_std #247

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions ensure_no_std/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
extern crate alloc;
extern crate wee_alloc;

#[no_mangle]
#[allow(non_snake_case)]
fn _Unwind_Resume() {}

#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

Expand All @@ -31,7 +35,7 @@ unsafe fn oom(_: ::core::alloc::Layout) -> ! {
// Needed for non-wasm targets.
#[lang = "eh_personality"]
#[no_mangle]
extern fn eh_personality() {}
extern "C" fn eh_personality() {}

use alloc::{format, vec, vec::Vec};
use deku::prelude::*;
Expand All @@ -49,21 +53,21 @@ struct DekuTest {

#[no_mangle]
pub extern "C" fn main() -> () {
let test_data: Vec<u8> = vec![0b10101_101, 0x02, 0xBE, 0xEF];
let test_data: Vec<u8> = vec![0b10101_101, 0x02, 0xBE, 0xEF];

// Test reading
let (_rest, val) = DekuTest::from_bytes((&test_data, 0)).unwrap();
assert_eq!(
DekuTest {
field_a: 0b10101,
field_b: 0b101,
count: 0x02,
data: vec![0xBE, 0xEF]
},
val
);
// Test reading
let (_rest, val) = DekuTest::from_bytes((&test_data, 0)).unwrap();
assert_eq!(
DekuTest {
field_a: 0b10101,
field_b: 0b101,
count: 0x02,
data: vec![0xBE, 0xEF]
},
val
);

// Test writing
let val = val.to_bytes().unwrap();
assert_eq!(test_data, val);
// Test writing
let val = val.to_bytes().unwrap();
assert_eq!(test_data, val);
}