Date: Mon, 3 May 2021 13:00:27 -0400
+1
On 4/15/2021 2:20 PM, Jens Maurer via Liaison wrote:
> 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
> _______________________________________________
> Liaison mailing list
> Liaison_at_[hidden]
> Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> Link to this post: http://lists.isocpp.org/liaison/2021/04/0448.php
On 4/15/2021 2:20 PM, Jens Maurer via Liaison wrote:
> 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
> _______________________________________________
> Liaison mailing list
> Liaison_at_[hidden]
> Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> Link to this post: http://lists.isocpp.org/liaison/2021/04/0448.php
Received on 2021-05-03 12:02:11