mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <jens.gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: Re: atomic.h cleanup
Date: Mon, 11 Jan 2016 21:56:50 +0100	[thread overview]
Message-ID: <1452545810.28095.12.camel@inria.fr> (raw)
In-Reply-To: <20160111190356.GA13558@port70.net>

[-- Attachment #1: Type: text/plain, Size: 2846 bytes --]

Am Montag, den 11.01.2016, 20:03 +0100 schrieb Szabolcs Nagy:
> * Jens Gustedt <jens.gustedt@inria.fr> [2016-01-11 18:12:29 +0100]:
> > Am Montag, den 11.01.2016, 17:35 +0100 schrieb Markus Wichmann:
> > > OTOH, maybe we simply shouldn't write synchronisation primitives
> > > ourselves and instead use the ones provided by GCC (and let other
> > > compilers suck on a salty sausage, if they don't support those
> > > primitives).
> > 
> > I think on the long run we should use C11 atomics and leave the dirty
> > work to the compiler writers. To my experience they do good work with
> > that now, the assembler they produce looks nice.
> > 
> 
> yes but old compilers had various bugs on various targets.
> 
> > My stdatomic library is sitting there, ready to integrate into
> > musl. It solves the problem of backwards compatibility for all
> > compilers that that implement the __sync builtins. (gcc and clang with
> > very old version numbers.)
> > 
> 
> i think simpler compilers like pcc, cparser, tcc
> dont implement that.
> 
> if musl moves to compiler builtins then i'd
> like to have a possibility to compile atomic
> primitives as a separate tu

In a sense, stdatomic has that already. It also implements the atomic
operations as fallback functions, for the case that the compiler isn't
able to synthesise the operation.

But you are right, support for those simpler compilers then would mean
that we'd have to maintain stubs, at least for the most commonly used
4 byte operations.

> > Last time I looked, all usages but one of atomic operations in musl
> > are clean. If an atomic operation is used for a data a some point,
> > atomic operations are used in all other places. So moving to
> > _Atomic(int) would be a option. (Basically this would be `volatile
> > int*` => `_Atomic(int)`, IIRC).

oops I meant `volatile int*` => `_Atomic(int)*`

> pthread_once_t and pthread_spinlock_t are
> publicly visibles type (without volatile and
> _Atomic)
> 
> i dont think we can fix those without abi
> change.

This is really a question what ABI means in this case. The width,
alignment and representation of the `int` would stay the same, we
would just internally (to the library implementation) interpret it as
_Atomic(int).

Also it seems that we do such a re-interpretation already with
`volatile`. One interpretation of the standard says that the object
itself has to be `volatile`, just casting a pointer to `volatile int*`
doesn't inhibit optimizations.

Jens

-- 
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536   ::
:: :::::::::::::::::::::: gsm France : +33 651400183   ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2016-01-11 20:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-10 12:21 Markus Wichmann
2016-01-10 16:57 ` Rich Felker
2016-01-10 17:35   ` Markus Wichmann
2016-01-10 17:50     ` Alexander Monakov
2016-01-11 16:35       ` Markus Wichmann
2016-01-11 17:12         ` Jens Gustedt
2016-01-11 19:03           ` Szabolcs Nagy
2016-01-11 20:56             ` Jens Gustedt [this message]
2016-01-14 22:12               ` Rich Felker
2016-01-14 22:37                 ` Jens Gustedt
2016-01-14 23:32                   ` Rich Felker
2016-01-15  0:46                     ` Szabolcs Nagy
2016-01-10 17:37   ` Markus Wichmann
2016-01-22  0:09   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452545810.28095.12.camel@inria.fr \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).