Browse Source

wire up adapter macros to stderr stream print

pull/6374/head
Pat Hickey 2 years ago
parent
commit
777dd77f65
  1. 3
      src/lib.rs
  2. 4
      src/macros.rs

3
src/lib.rs

@ -52,6 +52,7 @@ pub unsafe extern "C" fn main(
args_len: usize,
preopens: PreopenList,
) -> u32 {
set_stderr_stream(stderr);
State::with_mut(|state| {
// Initialization of `State` automatically fills in some dummy
// structures for fds 0, 1, and 2. Overwrite the stdin/stdout slots of 0
@ -2406,6 +2407,8 @@ extern "C" {
fn set_state_ptr(state: *const RefCell<State>);
fn get_allocation_state() -> AllocationState;
fn set_allocation_state(state: AllocationState);
fn get_stderr_stream() -> Fd;
fn set_stderr_stream(fd: Fd);
}
impl State {

4
src/macros.rs

@ -2,12 +2,10 @@
//!
//! We're avoiding static initializers, so we can't have things like string
//! literals. Replace the standard assert macros with simpler implementations.
// TODO: Wire this up to stderr.
#[allow(dead_code)]
#[doc(hidden)]
pub fn print(message: &[u8]) {
crate::bindings::stderr::print(message)
let _ = unsafe { crate::bindings::streams::write(crate::get_stderr_stream(), message) };
}
/// A minimal `eprint` for debugging.

Loading…
Cancel
Save