Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150517045536.GA25046@brightrain.aerifal.cx>
Date: Sun, 17 May 2015 00:55:36 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Deduplicating atomics written in terms of CAS

Lots of archs define most or all of their atomics except a_cas in
terms of a_cas. The attached atomic.h is a proposed replacement for
arch-specific atomic.h that would live in src/internal. The arch
atomic.h files would be replaced with atomic_arch.h, which could opt
to define nothing but a_cas, or could define more primitives itself if
it can do so more efficiently.

The second attachment, atomic_generic.h, is an implementation of the
atomics (and other non-atomic ops we've traditionally had in atomic.h)
using GNU C builtins. This file can be used as-is for any new archs
that satisfy the following conditions:

- They're not supported by compilers too old to have the __sync_*
  builtins.

- They don't need runtime switching/detection of atomic
  implementations.

- GCC doesn't generate pathologically bad code for the builtins.

Even if some of these conditions aren't met, atomic_generic.h may be
useful when porting to help determine the right way to implement
atomics by watching what the compiler does, and it may be suitable for
early porting stages before a proper atomic.h is written.

I'm not sure if I'll try to integrate this stuff right away or as part
of the bits deduplication and build system overhaul that's been
coming-soon for a long time.

Comments welcome.

Rich

View attachment "atomic.h" of type "text/plain" (3009 bytes)

View attachment "atomic_generic.h" of type "text/plain" (1064 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.