From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11067 Path: news.gmane.org!.POSTED!not-for-mail From: Raphael Cohn Newsgroups: gmane.linux.lib.musl.general Subject: Re: No definition of PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP in musl Date: Mon, 20 Feb 2017 17:21:22 +0000 Message-ID: References: <20170220162419.dxpcdbp23up3iopr@voyager> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11426ae61d29130548f97e41 X-Trace: blaine.gmane.org 1487611298 8003 195.159.176.226 (20 Feb 2017 17:21:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Feb 2017 17:21:38 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11082-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 20 18:21:34 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1cfreW-0001gO-IJ for gllmg-musl@m.gmane.org; Mon, 20 Feb 2017 18:21:32 +0100 Original-Received: (qmail 7782 invoked by uid 550); 20 Feb 2017 17:21:36 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 7758 invoked from network); 20 Feb 2017 17:21:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stormmq-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Rq/qYwl108okG9RgetxGrcyPf7nOiiDFNKG3SecO++g=; b=HCjnlbr6pdSPlxpjk7u2HhuKIUnRNm3TjOgGloavYuLfvXPOZQDx4GLFQJUqJo8OH2 9ABVjv2XfSbl1bR1qFf64QMmS4QYfkaEL5Ky7xbJsivwkUZKmQx/KSxsimI8gosrgLgq 8SfvH9LquO5KMDlL0QFvNT6LcwIKXOt93ni79y8f9NeJMGuu1NNcG8ghIUypfJRhhy2A X9SA4OnAXl1Nu+ABgs2nTAZ4UJYoA4jsat0ZNbMl4LtIIa7aCa12zmxgNKwNgObGaHXf gB2pyDjF6pW817vrZXLbxCGKvRsUe61xZIBl/+donccpiiDKghuH+VeXGHohL4/v1dZf w4Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Rq/qYwl108okG9RgetxGrcyPf7nOiiDFNKG3SecO++g=; b=lwmDfgcmkYCahv9kQ+xQmIRnUJ9gyQukauD3uaCPKLkQNXwTYeSZB+iigZI4ljKYlR e9SNNORmNpfUY44ZuqPtlftlAzz61lz4cxCzxs4I4IIwajrBR3PDt8gGhV7vy3MroRVh JyV3UmBkQWV7BSlF63Arcrynga1R418GI68YKsL/hEa78druxBSouSW4KGiW8L7tUqkU EYieA2NsceSjakqV4LIOupm1gxcAfFa1JzO+BhVEwfoqWnqvmKI3Rgatx3+5Ttszqevi IR/CIQxjjpw/QQ/svt1lMIb9PdtjblIEo7u/2DFAe7/8fiTn7krDsHFHrbUEnh7FNoDJ ZgIQ== X-Gm-Message-State: AMke39nW2DziKzK7b8dBUks7/eMBaOkETQTjdKIfp96Ye6bhkepDVtBD+fZTXy7SIUuPTfgKMh+EK3ZTIQfdlQ== X-Received: by 10.107.168.160 with SMTP id e32mr17448793ioj.127.1487611283427; Mon, 20 Feb 2017 09:21:23 -0800 (PST) X-Originating-IP: [90.155.92.123] In-Reply-To: <20170220162419.dxpcdbp23up3iopr@voyager> Xref: news.gmane.org gmane.linux.lib.musl.general:11067 Archived-At: --001a11426ae61d29130548f97e41 Content-Type: text/plain; charset=UTF-8 On 20 February 2017 at 16:24, Markus Wichmann wrote: > On Mon, Feb 20, 2017 at 03:22:41PM +0000, Raphael Cohn wrote: > > Hi, > > > > Whilst trying to compile ReOpenLDAP (https://github.com/ReOpen/ > ReOpenLDAP), > > a fork of OpenLDAP, I'm running into a wall. Some of the code wants a > > definition of PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP. musl doesn't > define > > this; I suspect this is a non-portable glibc extension in pthread.h. Does > > any one have any ideas how I might workaround this? Is there an > alternative > > construction that the code could use? > > > > Well, not directly. > > PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is an initializer that makes a > mutex recursive. What you could do is look for a single use > initialization function. Then you could replace > > static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; > > with > > static pthread_mutex_t mut; > > ... > pthread_mutexattr_t mutattr = {0}; > pthread_mutexattr_init(&mutattr); > pthread_mutexattr_settype(&mutattr, PTHREAD_MUTEX_RECURSIVE); > pthread_mutex_init(&mut, &mutattr); > pthread_mutexattr_destroy(&mutattr); > ... > > That's the portable way to do it. However, the nonportable solution is > generally used to avoid the one-time initialization otherwise necessary. > As such, there may not be a place for you to put the above snippet. In > that case you may have to introduce such a function. > > Alternatively, you could look up the effects the above snippet has on > the mutex under musl, at least at the moment, and declare the > nonportable initializer yourself. At the moment, I think it would be > > #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {{PTHREAD_MUTEX_RECURSIVE}} > > > Any help gladly appreciated. > > > > Hope it helps. > > > Raph > > > > Ciao, > Markus > Thank you Markus and Rich for your help and suggestions. I have a good idea how to tackle this now. --001a11426ae61d29130548f97e41 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 20 February 2017 at 16:24, Markus Wichmann <nullplan@gmx.net> wrote:
On Mon, Feb 2= 0, 2017 at 03:22:41PM +0000, Raphael Cohn wrote:
> Hi,
>
> Whilst trying to compile ReOpenLDAP (https://github.com/ReO= pen/ReOpenLDAP),
> a fork of OpenLDAP, I'm running into a wall. Some of the code want= s a
> definition of PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP. musl doesn&= #39;t define
> this; I suspect this is a non-portable glibc extension in pthread.h. D= oes
> any one have any ideas how I might workaround this? Is there an altern= ative
> construction that the code could use?
>

Well, not directly.

PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is an initializer that makes a<= br> mutex recursive. What you could do is look for a single use
initialization function. Then you could replace

static pthread_mutex_t mut =3D PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;=

with

static pthread_mutex_t mut;

...
=C2=A0 =C2=A0 pthread_mutexattr_t mutattr =3D {0};
=C2=A0 =C2=A0 pthread_mutexattr_init(&mutattr);
=C2=A0 =C2=A0 pthread_mutexattr_settype(&mutattr, PTHREAD_MUTEX_RE= CURSIVE);
=C2=A0 =C2=A0 pthread_mutex_init(&mut, &mutattr);
=C2=A0 =C2=A0 pthread_mutexattr_destroy(&mutattr);
...

That's the portable way to do it. However, the nonportable solution is<= br> generally used to avoid the one-time initialization otherwise necessary. As such, there may not be a place for you to put the above snippet. In
that case you may have to introduce such a function.

Alternatively, you could look up the effects the above snippet has on
the mutex under musl, at least at the moment, and declare the
nonportable initializer yourself. At the moment, I think it would be

#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {{PTHREAD_MUTEX_RECURSI= VE}}

> Any help gladly appreciated.
>

Hope it helps.

> Raph
>

Ciao,
Markus

Thank you Markus an= d Rich for your help and suggestions. I have a good idea how to tackle this= now.
--001a11426ae61d29130548f97e41--