Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Prepare v0.3.7 #62

Merged
merged 2 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [v0.3.7] - 2020-12-02

- Replaces the yanked v0.3.6 by reverting #48, so the semihosting macros
continue to return a Result.

## [v0.3.6] - 2020-12-01

v0.3.6 was yanked because it incorrectly included #48, which was a breaking
change.

### Added

- Update cortex-m dependency to support version 0.7.
Expand Down Expand Up @@ -116,7 +124,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).

- Initial release

[Unreleased]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.6...HEAD
[Unreleased]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.7...HEAD
[v0.3.7]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.6...v0.3.7
[v0.3.6]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.5...v0.3.6
[v0.3.5]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.4...v0.3.5
[v0.3.4]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.3...v0.3.4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
name = "cortex-m-semihosting"
readme = "README.md"
repository = "https://github.com/rust-embedded/cortex-m-semihosting"
version = "0.3.6"
version = "0.3.7"
edition = "2018"

[features]
Expand Down
24 changes: 12 additions & 12 deletions src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,44 @@ use crate::hio::{self, HStderr, HStdout};

static mut HSTDOUT: Option<HStdout> = None;

pub fn hstdout_str(s: &str) {
let _result = interrupt::free(|_| unsafe {
pub fn hstdout_str(s: &str) -> Result<(), ()> {
interrupt::free(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
}

HSTDOUT.as_mut().unwrap().write_str(s).map_err(drop)
});
})
}

pub fn hstdout_fmt(args: fmt::Arguments) {
let _result = interrupt::free(|_| unsafe {
pub fn hstdout_fmt(args: fmt::Arguments) -> Result<(), ()> {
interrupt::free(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
}

HSTDOUT.as_mut().unwrap().write_fmt(args).map_err(drop)
});
})
}

static mut HSTDERR: Option<HStderr> = None;

pub fn hstderr_str(s: &str) {
let _result = interrupt::free(|_| unsafe {
pub fn hstderr_str(s: &str) -> Result<(), ()> {
interrupt::free(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
}

HSTDERR.as_mut().unwrap().write_str(s).map_err(drop)
});
})
}

pub fn hstderr_fmt(args: fmt::Arguments) {
let _result = interrupt::free(|_| unsafe {
pub fn hstderr_fmt(args: fmt::Arguments) -> Result<(), ()> {
interrupt::free(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
}

HSTDERR.as_mut().unwrap().write_fmt(args).map_err(drop)
});
})
}
31 changes: 13 additions & 18 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ macro_rules! syscall {
};
}

/// Macro version of `syscall1`.
/// Macro version of `syscall1`
#[macro_export]
macro_rules! syscall1 {
($nr:ident, $a1:expr) => {
$crate::syscall1($crate::nr::$nr, $a1 as usize)
};
}

/// Macro for printing to the HOST standard output.
/// Macro for printing to the HOST standard output
///
/// This is similar to the `print!` macro in the standard library. Both will panic on any failure to
/// print.
/// This macro returns a `Result<(), ()>` value
#[macro_export]
macro_rules! hprint {
($s:expr) => {
Expand All @@ -44,8 +43,7 @@ macro_rules! hprint {

/// Macro for printing to the HOST standard output, with a newline.
///
/// This is similar to the `println!` macro in the standard library. Both will panic on any failure to
/// print.
/// This macro returns a `Result<(), ()>` value
#[macro_export]
macro_rules! hprintln {
() => {
Expand All @@ -59,10 +57,9 @@ macro_rules! hprintln {
};
}

/// Macro for printing to the HOST standard error.
/// Macro for printing to the HOST standard error
///
/// This is similar to the `eprint!` macro in the standard library. Both will panic on any failure
/// to print.
/// This macro returns a `Result<(), ()>` value
#[macro_export]
macro_rules! heprint {
($s:expr) => {
Expand All @@ -75,8 +72,7 @@ macro_rules! heprint {

/// Macro for printing to the HOST standard error, with a newline.
///
/// This is similar to the `eprintln!` macro in the standard library. Both will panic on any failure
/// to print.
/// This macro returns a `Result<(), ()>` value
#[macro_export]
macro_rules! heprintln {
() => {
Expand All @@ -90,23 +86,22 @@ macro_rules! heprintln {
};
}

/// Macro that prints and returns the value of a given expression for quick and
/// dirty debugging.
///
/// Works exactly like `dbg!` in the standard library, replacing `eprintln!`
/// with `heprintln!`.
/// Macro that prints and returns the value of a given expression
/// for quick and dirty debugging. Works exactly like `dbg!` in
/// the standard library, replacing `eprintln` with `heprintln`,
/// which it unwraps.
#[macro_export]
macro_rules! dbg {
() => {
$crate::heprintln!("[{}:{}]", file!(), line!());
$crate::heprintln!("[{}:{}]", file!(), line!()).unwrap();
};
($val:expr) => {
// Use of `match` here is intentional because it affects the lifetimes
// of temporaries - https://stackoverflow.com/a/48732525/1063961
match $val {
tmp => {
$crate::heprintln!("[{}:{}] {} = {:#?}",
file!(), line!(), stringify!($val), &tmp);
file!(), line!(), stringify!($val), &tmp).unwrap();
tmp
}
}
Expand Down