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

Commit e776ba5

Browse files
bors[bot]adamgreig
andauthored
Merge #62
62: Prepare v0.3.7 r=jonas-schievink a=adamgreig This PR reverts #48 in master, allowing 0.3.7 to support cortex-m 0.7 while being a non-breaking-change to 0.3.5. As previously I'll copy these CHANGELOG entries over to cortex-m afterwards. Co-authored-by: Adam Greig <[email protected]>
2 parents 0db2864 + 86a636e commit e776ba5

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
## [v0.3.7] - 2020-12-02
9+
10+
- Replaces the yanked v0.3.6 by reverting #48, so the semihosting macros
11+
continue to return a Result.
12+
813
## [v0.3.6] - 2020-12-01
914

15+
v0.3.6 was yanked because it incorrectly included #48, which was a breaking
16+
change.
17+
1018
### Added
1119

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

117125
- Initial release
118126

119-
[Unreleased]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.6...HEAD
127+
[Unreleased]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.7...HEAD
128+
[v0.3.7]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.6...v0.3.7
120129
[v0.3.6]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.5...v0.3.6
121130
[v0.3.5]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.4...v0.3.5
122131
[v0.3.4]: https://github.com/rust-embedded/cortex-m-semihosting/compare/v0.3.3...v0.3.4

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
1010
name = "cortex-m-semihosting"
1111
readme = "README.md"
1212
repository = "https://github.com/rust-embedded/cortex-m-semihosting"
13-
version = "0.3.6"
13+
version = "0.3.7"
1414
edition = "2018"
1515

1616
[features]

src/export.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,44 @@ use crate::hio::{self, HStderr, HStdout};
88

99
static mut HSTDOUT: Option<HStdout> = None;
1010

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

1717
HSTDOUT.as_mut().unwrap().write_str(s).map_err(drop)
18-
});
18+
})
1919
}
2020

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

2727
HSTDOUT.as_mut().unwrap().write_fmt(args).map_err(drop)
28-
});
28+
})
2929
}
3030

3131
static mut HSTDERR: Option<HStderr> = None;
3232

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

3939
HSTDERR.as_mut().unwrap().write_str(s).map_err(drop)
40-
});
40+
})
4141
}
4242

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

4949
HSTDERR.as_mut().unwrap().write_fmt(args).map_err(drop)
50-
});
50+
})
5151
}

src/macros.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@ macro_rules! syscall {
2020
};
2121
}
2222

23-
/// Macro version of `syscall1`.
23+
/// Macro version of `syscall1`
2424
#[macro_export]
2525
macro_rules! syscall1 {
2626
($nr:ident, $a1:expr) => {
2727
$crate::syscall1($crate::nr::$nr, $a1 as usize)
2828
};
2929
}
3030

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

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

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

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

93-
/// Macro that prints and returns the value of a given expression for quick and
94-
/// dirty debugging.
95-
///
96-
/// Works exactly like `dbg!` in the standard library, replacing `eprintln!`
97-
/// with `heprintln!`.
89+
/// Macro that prints and returns the value of a given expression
90+
/// for quick and dirty debugging. Works exactly like `dbg!` in
91+
/// the standard library, replacing `eprintln` with `heprintln`,
92+
/// which it unwraps.
9893
#[macro_export]
9994
macro_rules! dbg {
10095
() => {
101-
$crate::heprintln!("[{}:{}]", file!(), line!());
96+
$crate::heprintln!("[{}:{}]", file!(), line!()).unwrap();
10297
};
10398
($val:expr) => {
10499
// Use of `match` here is intentional because it affects the lifetimes
105100
// of temporaries - https://stackoverflow.com/a/48732525/1063961
106101
match $val {
107102
tmp => {
108103
$crate::heprintln!("[{}:{}] {} = {:#?}",
109-
file!(), line!(), stringify!($val), &tmp);
104+
file!(), line!(), stringify!($val), &tmp).unwrap();
110105
tmp
111106
}
112107
}

0 commit comments

Comments
 (0)