[Top][All Lists]

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

Re: [Tinycc-devel] [PATCH 3/3] stdatomic: stdatomic.h header

From: Christian Jullien
Subject: Re: [Tinycc-devel] [PATCH 3/3] stdatomic: stdatomic.h header
Date: Wed, 27 Jan 2021 07:56:00 +0100

Here are some unsorted reflections:
- With more cores / cpu, atomic is a must have otherwise tcc will soon be a 
"has-been" toy compiler unable to compile most projects.
- TinyCC has "tiny" in its name, adding atomic makes it bigger
- tcc has many C11 supports and will probably add more
- One of the tcc goals is to offer a drop down replacement of gcc/clang which 
all have stdatomic
- Having atomic is a big task as we support 
Linux/FreeBSD/NetBSD/OpenBSD/Windows operating systems, 
i386/x86_64/arm/arm64/riscv and gcc/clang/msvc and implementation should be 
My conclusion is that stdatomic is really needed but it's rather a big task as 
it must both support compiler dedicated instrinsics and C11 stdatomic API with 
a strong test suite that proves implementation fully works.
I don't want an half implemented semi-broken implementation that fits nobody 
needs. I compile all my C projects daily on many platforms with tcc, I use a 
compiler feature only if it works on all of them.


-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On 
Behalf Of Kyryl Melekhin
Sent: Tuesday, January 26, 2021 23:55
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] [PATCH 3/3] stdatomic: stdatomic.h header

Elijah Stone <elronnd@elronnd.net> wrote:

> On Tue, 26 Jan 2021, Kyryl Melekhin wrote:
> > Also while atomics are probably better solution so using something like 
> > mutex or spinlock, they are platform dependant
> They're no more platform-dependent than addition.  Obviously they do need 
> support from the CPU, but so does everything else.  They don't depend on 
> any OS-specific facilities or anything like that.
> > they just kind of produce code smell
> How's that?

Absolutely agree with you that atomics are nothing more but just cpu
instructions. I probably think this way because I always try to not use
any GNU compiler extensions or anything too fancy that would require use
of extra features. So for example just calling pthread_mutex_lock() does
not require anything from compiler other than to call the function.
I think part of contributing to this midset is that I only write C99
code, and tcc being not able to support atomics until now assured me
not to use them. It's hard to accept some feature like this one after
avoiding it for very long time. I might come to change my mind.

Tinycc-devel mailing list

reply via email to

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