Make armv6m-atomic-hack
less annoying
#1635
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the
armv6m-atomic-hack
crate is, to use a technical term,annoying. Its extension traits only exist when
#[cfg(armv6m)]
isset. This means that, in downstream crates that wish to use
armv6m-atomic-hack
to support v6m targets, the extension traits mayonly be imported when
#[cfg(armv6m)]
is set. BecauseRUSTFLAGS
cfgsdon't propagate across dependency boundaries, this means that each
dependent of
armv6m-atomic-hack
must add a build script with a call tobuild_utils::expose_m_profile()
so that the cfg is set properly whenbuilding for a v6m board. This is, as previously stated, annoying ---
especially when using crates like
counters
, whose#[derive(Count)]
attribute expands to a use of
AtomicU32Ext
, and thus requires anycrate that derives
Count
to add a build script.This branch changes
armv6m-atomic-hack
so that the extension traitsAtomicU32Ext
andAtomicBoolExt
are always defined, regardless ofwhether
#[cfg(armv6m)]
is set. Now, only the implementation of thosetraits differs based on the presence of the
armv6m
cfg --- if it isnot set, an implementation is provided that simply forwards to the
corresponding methods on the
AtomicU32
andAtomicBool
types inlibcore. This way, dependents of
armv6m-atomic-hack
can just importthe extension traits without needing to add a build script with
expose_m_profile()
; now, onlyarmv6m-atomic-hack
itself needs thebuild script. Now, the
armv6m-atomic-hack
crate can no longer beconsidered annoying.