Skip to content

Conversation

derMihai
Copy link
Contributor

@derMihai derMihai commented Apr 25, 2025

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 involved With the exception atomic_bit_unsigned(), there is no type casting s.t. everything can be checked by the compiler.

Issues/PRs references

Completes #21429.

@github-actions github-actions bot added the Area: sys Area: System label Apr 25, 2025
@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 25, 2025
@crasbe crasbe requested a review from maribu April 25, 2025 14:33
@maribu maribu enabled auto-merge April 25, 2025 14:55
@maribu maribu disabled auto-merge April 25, 2025 15:23
@riot-ci
Copy link

riot-ci commented Apr 25, 2025

Murdock results

✔️ PASSED

7541ef3 sys/atomic_utils: add bit set/clear helpers for unsigned int

Success Failures Total Runtime
10320 0 10320 11m:13s

Artifacts

@derMihai derMihai force-pushed the mir/unsigned_set_clear branch from 894706c to 94485f6 Compare April 26, 2025 13:53
@derMihai derMihai force-pushed the mir/unsigned_set_clear branch from 94485f6 to 67b2f56 Compare April 26, 2025 14:45
@maribu maribu enabled auto-merge April 26, 2025 15:47
uint8_t bit)
{
#if UINT_MAX == UINT16_MAX
return atomic_bit_u16(dest, bit);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

/* 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);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

auto-merge was automatically disabled April 28, 2025 11:25

Head branch was pushed to by a user without write access

@derMihai derMihai force-pushed the mir/unsigned_set_clear branch from 67b2f56 to f7c4917 Compare April 28, 2025 11:25
@maribu maribu enabled auto-merge April 28, 2025 11:40
auto-merge was automatically disabled April 28, 2025 13:26

Head branch was pushed to by a user without write access

@derMihai derMihai force-pushed the mir/unsigned_set_clear branch from f7c4917 to 7541ef3 Compare April 28, 2025 13:26
@benpicco benpicco added this pull request to the merge queue Apr 30, 2025
Merged via the queue into RIOT-OS:master with commit 217ab24 Apr 30, 2025
25 checks passed
@Teufelchen1 Teufelchen1 added this to the Release 2025.07 milestone Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants