-
Notifications
You must be signed in to change notification settings - Fork 53
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
atomic_ref: reconsider "struct rgb" case #35
Comments
It cannot be implemented because the padding bits are undefined and there is no portable way to clear them. Types with padding bits are unsupported by Boost.Atomic with a sole exception of |
I think you confused two recently created issues. This one is about odd sized types, not padding bits. Also regarding padding bits, I understand it cannot be implemented, I just think that caveats section in the documentation should be expanded. |
It doesn't matter how padding bits are introduced - either for member alignment to a byte boundary (which is the case with bit fields) or to its natural alignment (which may be the case when the padding is inserted between members) or to align the structure size to a multiple of its own alignment (which is the case with the trailing padding). In the particular example with |
With compare exchange, not modifying content can be accomplished by compare-exchange, and in case of failure due to bits not belonging to value, retry with changing the expectation for these bits See also this comment: ORNL/cpp-proposals-pub#130 (comment) Alignment is harder, but can be dealt with too. First, on some platforms, only plain loads/stores are subject to tearing due to misalignment, CAS would work. Second, you need to prevent accessing memory page that not belongs to the value to avoid access violation. But is is all doable. And third, |
I'm not sure that would work portably. For instance, on x86, IIRC, atomic instructions only synchronize if they are applied on the same address and the memory operands have the same size. So, for example, if you have this kind of code:
I don't think operations through
To my knowledge, this is only kind of allowed on x86 (for some atomic sizes), and it is gradually becoming illegal even there. See split-lock detection for instance. |
Ok, understood, if you are looking into portable solutions, then yes, agreed, |
Regarding
atomic_ref
withIt can be implemented by implementing every operation (including load) via CAS loop of wider type.
But may be still not worth doing this way.
See this thread: ORNL/cpp-proposals-pub#130
The text was updated successfully, but these errors were encountered: