ISO C11's stdatomic.h

Mukund Sivaraman muks at isc.org
Thu Sep 10 11:13:52 UTC 2015


On Thu, Sep 10, 2015 at 12:24:28PM +0200, Petr Spacek wrote:
> It would be interesting to see some benchmarks comparing hand-made
> atomics with those generated by GCC ...

There are variant implementations of atomic implementations in BIND
(libisc):

- On unix, if GCC is used as the compiler, it uses the extended asm
  syntax to get at function arguments. If GCC is not used, it has
  variant code that reads values passed according to the arch's calling
  convention. There are implementations for x86, x86_64, mips, alpha,
  ppc, sparc64 and ia64.

- On Windows, it uses the Interlocked*() functions.

The advantages of using C standard atomics is that the responsibility
for their correctness is transferred to the C implementation, and
support for many more platforms are available by now.

It's unlikely to change performance significantly. For example, on
x86_64 gcc emits exactly the same code as libisc contains, except gcc
inlines the lock + cmpxchg, lock + xchg, etc. avoiding a function
call. The ISC functions are (unfortunately) static with implementation
in headers, which likely get inlined in several places as well.

		Mukund
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/bind-workers/attachments/20150910/d1dcce9b/attachment.bin>


More information about the bind-workers mailing list