Skip to content

safe &'static mut references through a runtime checked macro #70

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

Merged
merged 2 commits into from
Jan 15, 2018

Conversation

japaric
Copy link
Member

@japaric japaric commented Dec 23, 2017

runtime checked implementation of japaric/cortex-m-rtfm#59 that doesn't depend on RTFM macros

TODO

  • bikeshed macro syntax

@therealprof
Copy link
Contributor

Looks great, I'm not too hot about the name static_ though. What about singleton?

@japaric
Copy link
Member Author

japaric commented Dec 23, 2017

I'm not too hot about the name static_ though.

Me neither.

What about singleton?

Sounds better to me.

Please continue bikeshedding :-).

Copy link
Member

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some minor nits, but otherwise this looks great! I also agree that singleton! is a nicer name than static_!.

src/macros.rs Outdated
@@ -22,3 +22,44 @@ macro_rules! iprintln {
iprint!($channel, concat!($fmt, "\n"), $($arg)*);
};
}

/// Macro to create an statically allocated value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "a statically allocated value", I think?

src/macros.rs Outdated
///
/// # Example
///
/// ``` ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to un-ignore this example by adding this to the beginning:

# #[macro_use] extern crate cortex_m;
// rest of example

It still won't run, because of the deliberate panic, but the ignore can be replaced with no_run, which will at least will make sure that the example can be compiled.

@japaric
Copy link
Member Author

japaric commented Jan 15, 2018

OK, thanks everyone for the feedback. Let's go ahead with singleton! for the name.

@homunkulus r+

@homunkulus
Copy link
Contributor

📌 Commit 4f9664c has been approved by japaric

@homunkulus
Copy link
Contributor

⌛ Testing commit 4f9664c with merge ca3d4ef...

japaric pushed a commit that referenced this pull request Jan 15, 2018
safe `&'static mut` references through a runtime checked macro

runtime checked implementation of japaric/cortex-m-rtfm#59 that doesn't depend on RTFM macros

TODO

- [ ] bikeshed macro syntax
@homunkulus
Copy link
Contributor

☀️ Test successful - status-travis
Approved by: japaric
Pushing ca3d4ef to master...

@homunkulus homunkulus merged commit 4f9664c into master Jan 15, 2018
@jonas-schievink jonas-schievink deleted the safe-static-mut branch May 26, 2020 21:55
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
to make it more compatible with LLD. This commit contains no functional changes.

fixes #70

Overview of changes:

- Alignment checks are enabled now that rust-lld (LLD 7.0) supports the modulo
operator.

- Removed some private symbols (e.g. __foo) in favor of ADDR and SIZEOF.

- Turned .got into a NOLOAD section now that rust-lld supports it.

- Replaced `ABSOLUTE(.)` with `.` as an old LLD overlap bug seems to be gone and
ABSOLUTE seems to cause problems, like #70, on bigger programs.

- Made the linker assertion messages more uniform.

- Extended test suite to check that linking works with both rust-lld and GNU
LD.
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
84: refactor the linker script r=therealprof a=japaric

to make it more compatible with LLD. This commit contains no functional changes.

fixes #70

Overview of changes:

- Alignment checks are enabled now that rust-lld (LLD 7.0) supports the modulo
operator.

- Removed some private symbols (e.g. __foo) in favor of ADDR and SIZEOF.

- Turned .got into a NOLOAD section now that rust-lld supports it.

- Replaced `ABSOLUTE(.)` with `.` as an old LLD overlap bug seems to be gone and
ABSOLUTE seems to cause problems, like #70, on bigger programs.

- Made the linker assertion messages more uniform.

- Extended test suite to check that linking works with both rust-lld and GNU
LD.

r? therealprof (chosen at random)

Co-authored-by: Jorge Aparicio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants