Fixing core.atomic

Max Haughton maxhaton at gmail.com
Mon May 31 21:01:35 UTC 2021


On Monday, 31 May 2021 at 20:43:37 UTC, Ola Fosheim Grøstad wrote:
> On Monday, 31 May 2021 at 20:01:57 UTC, Max Haughton wrote:
>> On Monday, 31 May 2021 at 17:51:26 UTC, IGotD- wrote:
>>> [...]
>>
>> That and the C++ `std::atomic` will provide the same semantics 
>> on types of wide size (LDC and GDC seem to differ in behaviour 
>> here when you use the atomic primitive functions.)
>
> Are you sure?
>
> «All atomic types except for std::atomic_flag may be 
> implemented using mutexes or other locking operations, rather 
> than using the lock-free atomic CPU instructions.»
>
> https://en.cppreference.com/w/cpp/atomic/atomic_is_lock_free
>
> C/C++ is trying to be hardware-independent to a much larger 
> extent than D.

"Atomic types are also allowed to be sometimes lock-free"

https://gcc.godbolt.org/z/Ph981GvY8 Note the use of library calls.


More information about the Digitalmars-d mailing list