Skip to content

Commit b851c3b

Browse files
Merge #219
219: Inline attr. macro docs and fix links r=therealprof a=jonas-schievink This makes `cortex-m-rt-macros` purely an implementation detail, so I've put a warning in place to reflect that. This should close rust-embedded/cortex-m-rt#138 Co-authored-by: Jonas Schievink <[email protected]>
2 parents 3445f11 + c284d55 commit b851c3b

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

cortex-m-rt/macros/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Internal implementation details of `cortex-m-rt`.
2+
//!
3+
//! Do not use this crate directly.
4+
15
#![deny(warnings)]
26

37
extern crate proc_macro;

cortex-m-rt/src/lib.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
//!
1717
//! This crate also provides the following attributes:
1818
//!
19-
//! - `#[entry]` to declare the entry point of the program
20-
//! - `#[exception]` to override an exception handler. If not overridden all exception handlers
21-
//! default to an infinite loop.
22-
//! - `#[pre_init]` to run code *before* `static` variables are initialized
19+
//! - [`#[entry]`][attr-entry] to declare the entry point of the program
20+
//! - [`#[exception]`][attr-exception] to override an exception handler. If not overridden all
21+
//! exception handlers default to an infinite loop.
22+
//! - [`#[pre_init]`][attr-pre_init] to run code *before* `static` variables are initialized
2323
//!
2424
//! This crate also implements a related attribute called `#[interrupt]`, which allows you
2525
//! to define interrupt handlers. However, since which interrupts are available depends on the
2626
//! microcontroller in use, this attribute should be re-exported and used from a device crate.
2727
//!
28-
//! The documentation for these attributes can be found in the [Reexports](#reexports) section.
28+
//! The documentation for these attributes can be found in the [Attribute Macros](#attributes)
29+
//! section.
2930
//!
3031
//! # Requirements
3132
//!
@@ -194,11 +195,10 @@
194195
//! One will always find the following (unmangled) symbols in `cortex-m-rt` applications:
195196
//!
196197
//! - `Reset`. This is the reset handler. The microcontroller will executed this function upon
197-
//! booting. This function will call the user program entry point (cf. [`#[entry]`]) using the `main`
198-
//! symbol so you may also find that symbol in your program; if you do, `main` will contain your
199-
//! application code. Some other times `main` gets inlined into `Reset` so you won't find it.
200-
//!
201-
//! [`#[entry]`]: https://docs.rs/cortex-m-rt-macros/0.1.5/cortex_m_rt_macros/attr.entry.html
198+
//! booting. This function will call the user program entry point (cf. [`#[entry]`][attr-entry])
199+
//! using the `main` symbol so you may also find that symbol in your program; if you do, `main`
200+
//! will contain your application code. Some other times `main` gets inlined into `Reset` so you
201+
//! won't find it.
202202
//!
203203
//! - `DefaultHandler`. This is the default handler. If not overridden using `#[exception] fn
204204
//! DefaultHandler(..` this will be an infinite loop.
@@ -227,9 +227,9 @@
227227
//! `__EXCEPTIONS` in the `.vector_table` section.
228228
//!
229229
//! - `__pre_init`. This is a function to be run before RAM is initialized. It defaults to an empty
230-
//! function. The function called can be changed by calling the `pre_init!` macro. The empty
231-
//! function is not optimized out by default, but if an empty function is passed to `pre_init!` the
232-
//! function call will be optimized out.
230+
//! function. The function called can be changed by applying the [`#[pre_init]`][attr-pre_init]
231+
//! attribute to a function. The empty function is not optimized out by default, but if an empty
232+
//! function is passed to [`#[pre_init]`][attr-pre_init] the function call will be optimized out.
233233
//!
234234
//! If you override any exception handler you'll find it as an unmangled symbol, e.g. `SysTick` or
235235
//! `SVCall`, in the output of `objdump`,
@@ -245,13 +245,14 @@
245245
//!
246246
//! ## Setting the program entry point
247247
//!
248-
//! This section describes how `#[entry]` is implemented. This information is useful to developers who
249-
//! want to provide an alternative to `#[entry]` that provides extra guarantees.
248+
//! This section describes how [`#[entry]`][attr-entry] is implemented. This information is useful
249+
//! to developers who want to provide an alternative to [`#[entry]`][attr-entry] that provides extra
250+
//! guarantees.
250251
//!
251252
//! The `Reset` handler will call a symbol named `main` (unmangled) *after* initializing `.bss` and
252253
//! `.data`, and enabling the FPU (if the target is `thumbv7em-none-eabihf`). A function with the
253254
//! `entry` attribute will be set to have the export name "`main`"; in addition, its mutable
254-
//! statics are turned into safe mutable references (see [`#[entry]`] for details).
255+
//! statics are turned into safe mutable references (see [`#[entry]`][attr-entry] for details).
255256
//!
256257
//! The unmangled `main` symbol must have signature `extern "C" fn() -> !` or its invocation from
257258
//! `Reset` will result in undefined behavior.
@@ -385,6 +386,10 @@
385386
//! Be very careful with the `link_section` attribute because it's easy to misuse in ways that cause
386387
//! undefined behavior. At some point in the future we may add an attribute to safely place static
387388
//! variables in this section.
389+
//!
390+
//! [attr-entry]: attr.entry.html
391+
//! [attr-exception]: attr.exception.html
392+
//! [attr-pre_init]: attr.pre_init.html
388393
389394
// # Developer notes
390395
//
@@ -402,7 +407,9 @@ use core::fmt;
402407
use core::sync::atomic::{self, Ordering};
403408

404409
#[cfg(feature = "device")]
410+
#[doc(inline)]
405411
pub use macros::interrupt;
412+
#[doc(inline)]
406413
pub use macros::{entry, exception, pre_init};
407414

408415
#[export_name = "error: cortex-m-rt appears more than once in the dependency graph"]

0 commit comments

Comments
 (0)