From patchwork Tue May 16 14:28:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 9729263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E20A0602DB for ; Tue, 16 May 2017 14:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D492A28A0A for ; Tue, 16 May 2017 14:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C94F328A1D; Tue, 16 May 2017 14:28:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0107E28A0A for ; Tue, 16 May 2017 14:28:49 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5B285266CE6; Tue, 16 May 2017 16:28:30 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5CF6A266D01; Tue, 16 May 2017 16:28:29 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 24060266CAF for ; Tue, 16 May 2017 16:28:23 +0200 (CEST) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 86C9CAAB6 for ; Tue, 16 May 2017 14:28:22 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Tue, 16 May 2017 16:28:19 +0200 Message-Id: <20170516142819.7734-2-tiwai@suse.de> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170516142819.7734-1-tiwai@suse.de> References: <20170516142819.7734-1-tiwai@suse.de> Subject: [alsa-devel] [PATCH alsa-lib 2/2] conf: Check the availability of PTHREAD_MUTEX_RECURSIVE X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 ]) +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