OSDN Git Service

conf: Check the availability of PTHREAD_MUTEX_RECURSIVE
authorTakashi Iwai <tiwai@suse.de>
Tue, 16 May 2017 14:02:59 +0000 (16:02 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 16 May 2017 14:26:20 +0000 (16:26 +0200)
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
src/conf.c
src/pcm/pcm.c

index ec25476..a17f2c4 100644 (file)
@@ -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))
index 2b52b44..9a88743 100644 (file)
@@ -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);
 }
index 8a7a595..200b10c 100644 (file)
@@ -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