* [PATCH 2/2] alsa-utils: pcmjob.c: use portable way to initialize recursive mutex
@ 2013-11-08 13:03 John Spencer
2013-11-08 13:58 ` Jaroslav Kysela
0 siblings, 1 reply; 2+ messages in thread
From: John Spencer @ 2013-11-08 13:03 UTC (permalink / raw)
To: alsa-devel; +Cc: Timo Teräs
[-- Attachment #1: Type: text/plain, Size: 85 bytes --]
attaching the patch, as i currently have problems with git-send-email.
thanks,
--JS
[-- Attachment #2: 0001-pcmjob.c-use-portable-way-to-initialize-recursive-mu.patch --]
[-- Type: text/plain, Size: 1658 bytes --]
From faed06fd4a3b97ee7f4b46c60e3a828e47845d0e Mon Sep 17 00:00:00 2001
From: John Spencer <maillist-alsa@barfooze.de>
Date: Fri, 8 Nov 2013 13:59:41 +0100
Subject: [PATCH] pcmjob.c: use portable way to initialize recursive mutex
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP is not in POSIX, as _NP
(non-portable) suggests.
exposing such a symbol in musl libc would lock in the ABI for all
times and makes it impossible to do future changes to the under-
lying struct without hideous symbol versioning hacks.
use the portable way instead: pthread_once was designed for such
cases.
Signed-off-by: John Spencer <maillist-alsa@barfooze.de>
Tested-by: John Spencer <maillist-alsa@barfooze.de>
---
alsaloop/pcmjob.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/alsaloop/pcmjob.c b/alsaloop/pcmjob.c
index 139b6fd..f32180c 100644
--- a/alsaloop/pcmjob.c
+++ b/alsaloop/pcmjob.c
@@ -62,11 +62,22 @@ static const char *src_types[] = {
};
#endif
-static pthread_mutex_t pcm_open_mutex =
- PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static pthread_once_t pcm_open_mutex_once = PTHREAD_ONCE_INIT;
+static pthread_mutex_t pcm_open_mutex;
+
+static void pcm_open_init_mutex(void)
+{
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init(&pcm_open_mutex, &attr);
+ pthread_mutexattr_destroy(&attr);
+}
static inline void pcm_open_lock(void)
{
+ pthread_once(&pcm_open_mutex_once, pcm_open_init_mutex);
if (workarounds & WORKAROUND_SERIALOPEN)
pthread_mutex_lock(&pcm_open_mutex);
}
--
1.8.4
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] alsa-utils: pcmjob.c: use portable way to initialize recursive mutex
2013-11-08 13:03 [PATCH 2/2] alsa-utils: pcmjob.c: use portable way to initialize recursive mutex John Spencer
@ 2013-11-08 13:58 ` Jaroslav Kysela
0 siblings, 0 replies; 2+ messages in thread
From: Jaroslav Kysela @ 2013-11-08 13:58 UTC (permalink / raw)
To: John Spencer; +Cc: alsa-devel, Timo Teräs
Date 8.11.2013 14:03, John Spencer wrote:
> attaching the patch, as i currently have problems with git-send-email.
Applied to our repo. Thanks.
Jaroslav
--
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-08 13:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-08 13:03 [PATCH 2/2] alsa-utils: pcmjob.c: use portable way to initialize recursive mutex John Spencer
2013-11-08 13:58 ` Jaroslav Kysela
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.