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?

so personally I always tried to avoid using them, because portability issues might arrise at some point, especially with new hardware and embeded world.

I think you can generally depend on the existence of atomic operations. Embedded platforms are likely to be single-core, so atomicity is irrelevant (except for reentrance, but that's a whole other kettle of fish). Elsewhere, atomic operations are necessary to implement many algorithms efficiently, and they're part of the specification for many programming languages. So I can't imagine anyone would design a CPU that lacked them.

For my part, I have two projects that I would love to use tcc on but can't currently because of the lack of atomics.

 -E

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to