Liste des Groupes | Revenir à cl c |
Em 12/15/2024 1:39 AM, Chris M. Thomasson escreveu: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.On 12/14/2024 7:05 PM, Thiago Adams wrote:Yes this conversion is not implemented yet.>>
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;
}
________________________
>
>
Is
atomic_exchange(&foo.bar.m_atomic, 42);
The generated code for
foo.bar.m_atomic = 42;
?
I may look this at future.Cool. :^)
Les messages affichés proviennent d'usenet.