Date: Thu, 15 Apr 2021 20:20:45 +0200
On 15/04/2021 11.51, Uecker, Martin wrote:
>
>
> Am Donnerstag, den 15.04.2021, 08:44 +0100 schrieb Anthony Williams:
>> Atomic atomic;
>> Padded some_value=init();
>>
>> Thread 1:
>> atomic=some_value;
>>
>> Thread 2:
>> Padded local=some_value;
>> Padded new_value=whatever();
>>
>> if(atomic->compare_exchange_strong(local,new_value))
>> do_stuff();
> C++ could also change to treating padding bytes similar
> to C which would also solve the problems with
> atomic_exchange_compare (including unions), align it
> with C, and make low-level programming manipulating
> padding bytes possible.
From a C++ perspective, it seems undesirable to urge programmers
to use "memcpy" in lieu of "Padded local=some_value" to get
the desired behavior from the "if(cmpxchg)" operation.
Jens
>
>
> Am Donnerstag, den 15.04.2021, 08:44 +0100 schrieb Anthony Williams:
>> Atomic atomic;
>> Padded some_value=init();
>>
>> Thread 1:
>> atomic=some_value;
>>
>> Thread 2:
>> Padded local=some_value;
>> Padded new_value=whatever();
>>
>> if(atomic->compare_exchange_strong(local,new_value))
>> do_stuff();
> C++ could also change to treating padding bytes similar
> to C which would also solve the problems with
> atomic_exchange_compare (including unions), align it
> with C, and make low-level programming manipulating
> padding bytes possible.
From a C++ perspective, it seems undesirable to urge programmers
to use "memcpy" in lieu of "Padded local=some_value" to get
the desired behavior from the "if(cmpxchg)" operation.
Jens
Received on 2021-04-15 13:20:52