-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/atomic_utils: add bit set/clear helpers for unsigned int #21440
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
Conversation
894706c
to
94485f6
Compare
94485f6
to
67b2f56
Compare
sys/include/atomic_utils.h
Outdated
uint8_t bit) | ||
{ | ||
#if UINT_MAX == UINT16_MAX | ||
return atomic_bit_u16(dest, bit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return atomic_bit_u16(dest, bit); | |
return atomic_bit_u16((volatile uint16_t *)dest, bit); |
On 16 bit platforms the same issue is with uint16_t
, as there both unsigned int
and unsigned short
are 16 bit and uint16_t
can be either.
sys/include/atomic_utils.h
Outdated
/* Some archs define uint32_t as unsigned long, we need to cast. */ | ||
return atomic_bit_u32((uint32_t volatile *)dest, bit); | ||
#else | ||
return atomic_bit_u64(dest, bit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return atomic_bit_u64(dest, bit); | |
return atomic_bit_u64((volatile uint64_t)dest, bit); |
I don't have a practical example, but I do believe that unsigned int
, unsigned long
, and unsigned long long
could in full compliance with the C standard all be 64 bit.
Head branch was pushed to by a user without write access
67b2f56
to
f7c4917
Compare
Head branch was pushed to by a user without write access
f7c4917
to
7541ef3
Compare
Contribution description
Add atomic bit set/clear for
unsigned int
.Testing procedure
These are just very simple mappings from
unsigned
to the fixed size counterparts.No type casting is involvedWith the exceptionatomic_bit_unsigned()
, there is no type casting s.t. everything can be checked by the compiler.Issues/PRs references
Completes #21429.