4 ms·
C++ cannot represent an atomic type with less than natural alignment, and you cannot access that which does not exist, so that's the end of your road. Consider
by JonChesterfield 3y ago
C++ cannot represent an atomic type with less than natural alignment, and you cannot access that which does not exist, so that's the end of your road. Consider a language with lower intrinsic overhead.
Usually the answer is to ignore the atomic abstractions of C++ and use the GCC style atomic intrinsics (they take a void* instead of some atomic qualified thing) but I'm not totally confident they'll do the right thing if the target memory has less than natural alignment.
Beware crossing cache lines with your operation. I'm not sure what the x64 instructions do in such a case.
- dataflow 3y ago> Usually the answer is to ignore the atomic abstractions of C++ and use the GCC style atomic intrinsics I'm saying I don't see any such intrinsics for this. I do believe x86 and x64 LOCK works correctly across cache lines.