Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" 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: References: 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: 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 : >> ________________________ >> #include >> #include >> >> 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. :^)