[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: Dmitry Selyutin
Subject: Re: [Tinycc-devel] [PATCH 3/3] stdatomic: stdatomic.h header
Date: Wed, 27 Jan 2021 09:49:39 +0300

The two potential issues with stdatomic.h in general are:
1) it is not mandated by freestanding implementations (that is, even the header is not mentioned at all), so de iure one cannot use stdatomic.h, for example, in OS development;
2) on some platforms, this might be not implementable at all, at least not without some tricks like disabling interrupts, so a kernel support is needed.

De facto, however, for most platforms in use, this works regardless of the fact whether implementation is hosted or not; if we support more exotic cases, the code generator for these platforms may simply end up with compile-time error, or at least can put some unresolved references.

Also the whole point of hosted/freestanding does not apply to tcc, because tcc does not have option to operate in freestanding mode.

ср, 27 янв. 2021 г., 06:56 Kyryl Melekhin <k.melekhin@gmail.com>:
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]