| Deutsch English Français Italiano |
|
<vjng40$o6pe$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: transpiling to low level C
Date: Sun, 15 Dec 2024 13:01:52 -0800
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <vjng40$o6pe$1@dont-email.me>
References: <vjlh19$8j4k$1@dont-email.me> <vjlmia$dese$1@dont-email.me>
<vjmc7j$hhg1$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 15 Dec 2024 22:01:55 +0100 (CET)
Injection-Info: dont-email.me; posting-host="1b9ecb52f1e3580c8ecb0ff3bc0436cb";
logging-data="793390"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YH/IkU5fMqrJdJmC7uGLWfd3oj9dbzOI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:GuCYKiNbG8V40KhLf6hLMv9X7XM=
Content-Language: en-US
In-Reply-To: <vjmc7j$hhg1$2@dont-email.me>
Bytes: 2382
On 12/15/2024 2:49 AM, Thiago Adams wrote:
> Em 12/15/2024 1:39 AM, Chris M. Thomasson escreveu:
>> On 12/14/2024 7:05 PM, Thiago Adams wrote:
>>>
>>> I am working on a C backend that generates simple C code.
>>>
>>> You can test it here:
>>> http://thradams.com/cake/playground.html
>>
>> [...]
>>
>> Wrt to C11, it is missing <stdatomic.h>:
>> ________________________
>> #include <stdio.h>
>> #include <stdatomic.h>
>>
>> struct ct_bar
>> {
>> int a;
>> int b;
>> atomic_int m_atomic;
>> };
>>
>> struct ct_foo
>> {
>> char* a;
>> struct ct_bar bar;
>> };
>>
>> int main()
>> {
>> struct ct_foo foo = { "Hello", { 1, 2, 0 } };
>>
>> atomic_exchange(&foo.bar.m_atomic, 42);
>>
>> printf("%s\n%d\n%d\n%d\n",
>> foo.a, foo.bar.a, foo.bar.b, foo.bar.m_atomic);
>>
>> return 0;
>> }
>> ________________________
>>
>>
>
> Yes this conversion is not implemented yet.
>
> Is
> atomic_exchange(&foo.bar.m_atomic, 42);
>
> The generated code for
> foo.bar.m_atomic = 42;
> ?
Yes. atomic_exchange is an atomic RMW. Iirc, it defaults to seq_cst
memory_order. atomic_exchange_explicit allows us to define a different
memory_order.
> I may look this at future.
Cool. :^)