Browse Source

fix macros

pull/6374/head
Pat Hickey 2 years ago
parent
commit
e199109a0b
  1. 6
      src/lib.rs
  2. 12
      src/macros.rs

6
src/lib.rs

@ -4,7 +4,6 @@ use crate::bindings::{
exit, filesystem, instance_monotonic_clock, instance_wall_clock, monotonic_clock, network,
poll, random, streams, wall_clock,
};
use core::arch::wasm32;
use core::cell::{Cell, RefCell, UnsafeCell};
use core::cmp::min;
use core::ffi::c_void;
@ -18,11 +17,12 @@ use wasi::*;
#[cfg(all(feature = "command", feature = "reactor"))]
compile_error!("only one of the `command` and `reactor` features may be selected at a time");
mod descriptors;
use crate::descriptors::{Descriptor, Descriptors, StreamType, Streams};
#[macro_use]
mod macros;
mod descriptors;
use crate::descriptors::{Descriptor, Descriptors, StreamType, Streams};
pub mod bindings {
#[cfg(feature = "command")]
wit_bindgen::generate!({

12
src/macros.rs

@ -53,7 +53,11 @@ macro_rules! unreachable {
eprint!("unreachable executed at adapter line ");
crate::macros::eprint_u32(line!());
eprint!("\n");
wasm32::unreachable()
#[cfg(target_arch = "wasm32")]
core::arch::wasm32::unreachable();
// This is here to keep rust-analyzer happy when building for native:
#[cfg(not(target_arch = "wasm32"))]
std::process::abort();
}};
($arg:tt) => {{
@ -62,7 +66,11 @@ macro_rules! unreachable {
eprint!(": ");
eprintln!($arg);
eprint!("\n");
wasm32::unreachable()
#[cfg(target_arch = "wasm32")]
core::arch::wasm32::unreachable();
// This is here to keep rust-analyzer happy when building for native:
#[cfg(not(target_arch = "wasm32"))]
std::process::abort();
}};
}

Loading…
Cancel
Save