Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 20 Feb 2017 17:24:19 +0100
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Re: No definition of PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 in musl

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

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.