Page MenuHomeFreeBSD

bitset: Fix BIT_TEST_SET_ATOMIC and BIT_TEST_CLR_ATOMIC.
AbandonedPublic

Authored by mmel on Jan 2 2021, 12:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 18, 3:06 AM
Unknown Object (File)
Mon, Nov 17, 5:46 AM
Unknown Object (File)
Sun, Nov 16, 9:24 PM
Unknown Object (File)
Sun, Nov 16, 5:51 PM
Unknown Object (File)
Mon, Nov 10, 5:42 AM
Unknown Object (File)
Oct 29 2025, 9:27 AM
Unknown Object (File)
Oct 15 2025, 1:01 AM
Unknown Object (File)
Oct 15 2025, 1:01 AM
Subscribers
None

Details

Reviewers
rlibby
markj
Summary

The last argument to atomic_testandset/clear_long should be the bit position in the long, not full bitset index.
This completes a fix for 942951ba46ecd5ebab18de006a24dc52e2d3f745 started in D27886.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

mmel requested review of this revision.Jan 2 2021, 12:06 PM
mmel created this revision.

Actually atomic(9) says that it will do the mod:

atomic_testandset(p, v)
        bit = 1 << (v % (sizeof(*p) * NBBY));
        tmp = (*p & bit) != 0;
        *p |= bit;
        return (tmp);

Hmm, right. It would be better to read the manual before coding. My bad.

You're right that 32-bit arm also has a bug though and needs more follow up.