Kernelspace C11 atomics for MIPS
Ed Schouten
ed at 80386.nl
Tue Jun 4 17:23:35 UTC 2013
2013/6/4 Konstantin Belousov <kostikbel at gmail.com>:
> I do not think so. The compilers are free to use whatever means to
> implement the stdatomic. In particular, they are allowed to use simple
> global lock to protect the 'atomic' access, see ATOMIC_type_LOCK_FREE
> documented macros.
Well, yes, no, it's complicated. The fact is, we are still free to
implement <stdatomic.h> without using those compiler's features. For
example, we could have also decided to implement <stdatomic.h> using
only code we provide ourselves, as follows:
static inline int8_t
our_8bit_atomic_store(...)
{
...
}
#define atomic_store(...) _Generic( \
int8_t: our_8bit_atomic_store(....), \
... \
)
Also, it is extremely unlikely that compilers implement handlers for
non-lock-free atomics themselves. Both Clang and GCC 4.7+, for
example, will call into __atomic_*_{1,2,4,8,16,c}() whenever it does
not know built-in CPU instructions to perform the operation. More
details:
http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary
So in my opinion there are tons of ways we can still influence how the
atomic operations are performed. The patch I sent out already
demonstrates this, as we are free to implement the GCC intrinsics the
way we like.
--
Ed Schouten <ed at 80386.nl>
More information about the freebsd-arch
mailing list