[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] Question about Atomics support in TCC

From: Davidson Francis
Subject: [Tinycc-devel] Question about Atomics support in TCC
Date: Wed, 6 Apr 2022 17:00:33 -0300

I was checking the Atomics support in the TCC (mob) and realized that
while atomic functions work fine, they don't get generated if I use
'implicitly' like in:

   atomic_int foo;
   foo += 5;

no errors are generated either. Is this some sort of bug, or is the
Atomics support in TCC not complete yet?

A complete example (which works in GCC and Clang) taken from [1]:

   #include <stdio.h>
   #include <threads.h> 
   #include <stdatomic.h>

   atomic_int acnt;
   int cnt;
   int f(void* thr_data) {
       for (int n = 0; n < 1000; ++n) {
       return 0;
   int main(void) {
       thrd_t thr[10];
       for(int n = 0; n < 10; ++n)
           thrd_create(&thr[n], f, NULL);
       for(int n = 0; n < 10; ++n)
           thrd_join(thr[n], NULL);
       printf("The atomic counter is %u\n", acnt);
       printf("The non-atomic counter is %u\n", cnt);
       return 0;

The atomic counter is 9889
The non-atomic counter is 9897

[1]: https://en.cppreference.com/w/c/language/atomic

Kinds regards,
Davidson Francis

reply via email to

[Prev in Thread] Current Thread [Next in Thread]