mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl <musl@lists.openwall.com>
Subject: Re: C11 threads
Date: Fri, 25 Jul 2014 11:41:41 -0400	[thread overview]
Message-ID: <20140725154141.GC4038@brightrain.aerifal.cx> (raw)
In-Reply-To: <1406286404.6438.38.camel@eris.loria.fr>

On Fri, Jul 25, 2014 at 01:06:44PM +0200, Jens Gustedt wrote:
> Hi,
> thanks a lot for your feedback.
> 
> Am Freitag, den 25.07.2014, 12:40 +0200 schrieb Szabolcs Nagy:
> > * Jens Gustedt <jens.gustedt@inria.fr> [2014-07-25 12:00:37 +0200]:
> > >  after I have seen that gcc since 4.9 has a working implementation of
> > > atomics, I convinced myself to implement C11 threads within musl.
> > > 
> > 
> > the conclusion about threads.h was that it should be
> > abi compatible with glibc so we are waiting for them
> 
> They have that has a student summer project, so it seems to have low
> priority for them.

Their GSOC funding for the project fell through due to missed
deadlines, so it's now an unfunded student project if it's even moving
forward at all. That may be the reason. :(

> > so i think you should coordinate with libc-alpha too
> > 
> > > Choices :
> > > 
> > >  - all types are just the corresponding POSIX types
> > > 
> > 
> > if glibc does the same then it's ok
> 
> At least from the project description it seems that they prospect an
> incremental implementation.

Yes, that was their decision and they were generally uninterested in
discussing whether it was the best decision. I tend to agree that it's
the right choice, but thought it could use more discussion before a
decision was made.

> > > Issues :
> > > 
> > >  - a lot of C11 are just weak symbols. to avoid polluting the link
> > >    space of a C11 application, I had to transform a lot of POSIX
> > >    function symbols into weak symbols, too.
> > > 
> 
> > i think this not ok: posix usually requires inequal
> > function pointers for all public functions
> 
> C11 requires that the namespace not be polluted.
> 
> That conflict could be solved conveniently and easily by
> 
>  (1) compiling the same files twice and replacing the pthread symbol
>      by the other in the second compilation
> 
>  (2) copy the .o file and to some ld magic
> 
> Which one to choose?

Neither of these is very reasonable. Probably the best is to
namespace-protect (i.e. prefix with __ and add the external name as a
weak alias) all of the pthread functions which need to be used for
implementing C11 functions, then add either second weak aliases (if
the equal function pointer issue is not a problem and the signature is
identical) or thin wrappers (probably my preference anyway) for the
C11 functions to call the __pthread ones.

The latter also allows us to add alternative implementations for the
C11 ones later on an incremental basis, if we want to. I generally
don't like the whole C11 threads mess, but the one potential advantage
they have is having weaker semantics which may allow better
performance, and definitely allows smaller size if the application
only uses them (but of course makes libc.a and libc.so larger).

The other thing nice about eventually having mostly-separate (I say
mostly because thread creation/destruction still needs to be unified,
I would think) code for POSIX and C11 would be that we could avoid
having permanent restrictions on the namespace usage for pthread
functions.

> > >  - the include file threads.h includes pthread.h, so the namespace of
> > >    the C11 implementation is poluted with the pthreads stuff
> > > 
> > 
> > i think this is not ok in the final version
> 
> yes, I thought so, too. I would have to find a convenient way to just
> include the magic constants. Or would it be ok, to just duplicate
> them.
> 
> For the types this should be easy to have them typedef'ed to some
> opaque struct.

For the types that vary per-arch, I don't see any way around having
them in the alltypes.h.in bits. As for the constants, which ones are
you talking about? I don't think it's so easy to directly use the
POSIX ones for C11 since they have some different semantics (flag bits
vs enumeration-style) for a few. Also this is one area where we still
need to be careful to match the glibc ABI.

Rich


  parent reply	other threads:[~2014-07-25 15:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-25 10:00 Jens Gustedt
2014-07-25 10:40 ` Szabolcs Nagy
2014-07-25 11:06   ` Jens Gustedt
2014-07-25 13:04     ` Szabolcs Nagy
2014-07-25 13:38       ` Jens Gustedt
2014-07-25 13:42       ` Morten Welinder
2014-07-25 14:15         ` Szabolcs Nagy
2014-07-25 16:14       ` Rich Felker
2014-07-25 21:59         ` Jens Gustedt
2014-07-25 22:25           ` Rich Felker
2014-07-25 15:41     ` Rich Felker [this message]
2014-07-25 17:10       ` Jens Gustedt
2014-07-25 22:19         ` Rich Felker
2014-07-25 23:26           ` Jens Gustedt
2014-07-26  2:24             ` Rich Felker
2014-07-26  7:16               ` Jens Gustedt
2014-07-26  7:35                 ` Rich Felker
2014-07-26  8:32                   ` Jens Gustedt
2014-07-26  9:03                     ` Rich Felker
2014-07-26 11:15                       ` Jens Gustedt
2014-07-26 15:48                 ` Jens Gustedt

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=20140725154141.GC4038@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).