Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libpthread



On Mon, Aug 24, 2015 at 03:03:28PM +0000, Antti Kantee wrote:
> On 24/08/15 14:36, Joerg Sonnenberger wrote:
> >On Mon, Aug 24, 2015 at 02:20:55PM +0000, Antti Kantee wrote:
> >>On 24/08/15 13:26, Joerg Sonnenberger wrote:
> >>>On Mon, Aug 24, 2015 at 12:45:15PM +0000, Antti Kantee wrote:
> >>>>I started work on this again by doing a web search for the error, and found
> >>>>this:
> >>>>http://bugs.musicpd.org/view.php?id=4110
> >>>>
> >>>>There you argue that using constexpr for PTHREAD_MUTEX_INITIALIZER is
> >>>>broken.  So if we assume that you are correct, shouldn't we remove the
> >>>>"constexpr"s from libc++/dist/libcxx/include/__mutex_base?
> >>>
> >>>Except that the standard requires it.
> >>
> >>So are you now saying that that what you said in the above URL is wrong and
> >>that the NetBSD headers are broken?  Let me quote the relevant part of what
> >>you said:
> >
> >Stop inventing things, please.
> 
> A simple "yes/no[, because ...]" is more effective than evading the
> question.  I'm still not sure which one it is.
> 
> >>"Nothing in ISO C11, ISO C++11 or POSIX requires PTHREAD_MUTEX_INITIALIZER
> >>to qualify for constexpr."
> >>
> >>But now you are saying that "the standard" does require
> >>PTHREAD_MUTEX_INITIALIZER to qualify for constexpr.
> >
> >A mutex has to be constexpr constructable. That's in the standard. How a
> >mutex is implemented is not. Nothing in mpd requires the constexpr
> >property, so requiring it just makes things more difficult for no good
> >reason.
> 
> What I understand from that response: the same code is wrong in mpd (and
> presumably every other application) but right in libc++; it's
> standard-compliant to implement mutex in a way which does not compile.

Whether or not all the rules apply to system headers is a question
outside the scope of what I am willing to discuss. If you build a system
with strange flags that explicitly disable the normal system header
logic, you are on your own.

The code in mpd depends on the language DR to be resolved without having
a good reason to do so. "Because I don't trust a compiler to behave"
certainly doesn't qualify.

There are two approaches to implement a mutex in a standard-compliant
way with a PTHREAD_MUTEX_INITIALIZER using volatile elements:
(1) Assume that the compiler has a fix for the DR.
(2) Defer the actual mutex setup until a later point.

Clang implements the DR behavior in so far as skipping the check for
system headers. I have no idea what GCC is doing. The second option
comes with a significant penalty and simple is not acceptable.

Joerg


Home | Main Index | Thread Index | Old Index