All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH alsa-lib 2/2] conf: Check the availability of PTHREAD_MUTEX_RECURSIVE
Date: Tue, 16 May 2017 16:28:19 +0200	[thread overview]
Message-ID: <20170516142819.7734-2-tiwai@suse.de> (raw)
In-Reply-To: <20170516142819.7734-1-tiwai@suse.de>

Check the availability of PTHREAD_MUTEX_RECURSIVE in configure script
and use it only when possible.  A fairly old version of glibc still
seems working, but just to be sure.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 configure.ac  | 9 +++++++++
 src/conf.c    | 2 ++
 src/pcm/pcm.c | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/configure.ac b/configure.ac
index ec254762bed6..a17f2c4aef5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -266,6 +266,15 @@ else
   AC_MSG_RESULT(no)
 fi
 
+dnl Check for pthread
+if test "$HAVE_LIBPTHREAD" = "yes"; then
+  AC_CHECK_DECL(PTHREAD_MUTEX_RECURSIVE,
+    AC_DEFINE(HAVE_PTHREAD_MUTEX_RECURSIVE, [],
+      [Define if your pthreads implementation have PTHREAD_MUTEX_RECURSIVE]),
+    ,
+    [#include <pthread.h>])
+fi
+
 dnl Check for __thread
 AC_MSG_CHECKING([for __thread])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (__GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ < 2))
diff --git a/src/conf.c b/src/conf.c
index 2b52b44e9144..9a887433a4fe 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -490,7 +490,9 @@ static void snd_config_init_mutex(void)
 	pthread_mutexattr_t attr;
 
 	pthread_mutexattr_init(&attr);
+#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE
 	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+#endif
 	pthread_mutex_init(&snd_config_update_mutex, &attr);
 	pthread_mutexattr_destroy(&attr);
 }
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 8a7a5950de3c..200b10c2c09c 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2600,7 +2600,9 @@ int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
 	INIT_LIST_HEAD(&pcm->async_handlers);
 #ifdef THREAD_SAFE_API
 	pthread_mutexattr_init(&attr);
+#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE
 	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+#endif
 	pthread_mutex_init(&pcm->lock, &attr);
 	/* use locking as default;
 	 * each plugin may suppress this in its open call
-- 
2.13.0

      reply	other threads:[~2017-05-16 14:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 14:28 [PATCH alsa-lib 1/2] build: Define __USE_UNIX98 for old glibc Takashi Iwai
2017-05-16 14:28 ` Takashi Iwai [this message]

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=20170516142819.7734-2-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /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.
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.