core.stdc.stdatomic

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Wed Nov 15 03:07:38 UTC 2023


On 15/11/2023 8:00 AM, Walter Bright wrote:
> On 11/14/2023 12:51 AM, Richard (Rikki) Andrew Cattermole wrote:
>> Question: Why do people want another wrapper around some inline 
>> assembly that already exists in core.atomic?
> 
> Because they have existing carefully crafted code in C and want to 
> translate it to D.
> 
> 
>> Writing a wrapper around stdatomic.h would take probably 2 hours.
> 
> Great! That saves each stdatomic C user 2 hours who wants to get their 
> code in D.

So what I'm getting at here is that we can already do a best effort 
approach to this by swapping stdatomic to core.atomic, but it does not 
bring the value that people are wanting to do so.

The codegen must be similar, if the C compiler for a target uses a 
function call, so can we. If they use intrinsics with inlining so must us.

This way the behavior will be similar, and the port can be a success. 
Otherwise you are introducing new and potentially wrong behavior; which 
means a failure in trying to fulfill your ideas.


More information about the Digitalmars-d mailing list