From patchwork Fri Feb 22 19:27:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 159073 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2104227jaa; Fri, 22 Feb 2019 11:27:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IYiKFHVsuB95CF8iL0m819m/f+Tfx8CfRI/24JSztii9ljUI7/aBwttSVqDlyFgYnYrMriR X-Received: by 2002:a62:e719:: with SMTP id s25mr5771182pfh.12.1550863663137; Fri, 22 Feb 2019 11:27:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550863663; cv=none; d=google.com; s=arc-20160816; b=miuriommW/rBa0FWidmaavdGsJZlvYhXeQiSbfDR4/g9O5RT03CSAzgrpePT0kZ+EF GVNeOUz+M00UwTNyGlQa62eM/WXFwbX43KLcev3vJKpHymrP4VCRMFPbT3ePQviDIDyE 7L+8FNCBXGcx1rKkhHO9gZx67RuWfnM5q+WRhL+XxgHhxXLcZ0GMHSGnfeLsQatgr951 niKT9VSnqmL8sYuP/edf0g/0pr4BiaUooaqUIrQd9LLk9h05wz4NrArV0rypTKubTE6Q +osTLIcuA+upQWZ7dHL/QpdTxki0TXroQCf+Tc5R9JNlZ2vVwELJreRN9hCMHN5X+vTT ugrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=uQcausP/p13fIUWxfrAMuOVxhKUEpTEwsjNKt4lsswk=; b=h8i5kC0xJM3bQg7jcruO1HU9H/hIdrhrLNw/Qyo1IdtJHASAP4XQBH9ZcFNHXoPvr/ HUhEOVkCmM1VYRp1LjgTfF0cH7QQK9RKEW2XuI0fBKNEtpgxo2M5eWpGGLIHKySXXb3R Ms2H/R/pEihg0teFHneWmwDKYSIBRL4m3SxvUOprK9TFV9MVFzfHLijKS8pSUbaPViGQ jLzsUd9mGuWzUBK6LE+PhCxjq5IqylD938kegFs2u8h15n/Ak72vZh+gzagvJfQilZBs 0zlX80Ok8ZmoU9moJzjv7eilxVP9CPuNGGfsWmI37mIaFGhYreoEu5Eyf2wQp8kQfYw2 Hx9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=gns8ruEb; dkim=pass header.i=@linaro.org header.s=google header.b=qO6DfiZ8; spf=pass (google.com: domain of libc-alpha-return-100228-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100228-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 71si1970389pga.16.2019.02.22.11.27.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 11:27:43 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-100228-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=gns8ruEb; dkim=pass header.i=@linaro.org header.s=google header.b=qO6DfiZ8; spf=pass (google.com: domain of libc-alpha-return-100228-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100228-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=lnmyhGmAp1zqLzvbVekY8ufOaxeQYm1 8PnOeXifQ4jBBgnLf2uZTxn7t4d0BryHUNzF+a9H1Cy4BiN3ahi9MS8CAE+eYYs+ gMTfIkWwIxpjTJC0fbdNkaCCa3W1uV6Ty+phMpGtdUcN6PBjby3OwleHhnyoBMWw zbBFezttx4n4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=LKfBI1VQgOFIOjbZhF2gzKZ/CFg=; b=gns8r uEba0MfVzkr/NykNHTafO8AmPA4vYU/fzZvQOG1xVSqI4c8akmBjdPALNRqpJQup ucxUBbWHNDv9zxvlUg/8p1AnA5aAb83eDwWg153P7v4dHXDMwFEzNngaJtm76GDd QgN1TMkYjchP/m6Fr4fEgaiFjGLg/M+QwfTsb4= Received: (qmail 105029 invoked by alias); 22 Feb 2019 19:27:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 104926 invoked by uid 89); 22 Feb 2019 19:27:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=3118 X-HELO: mail-qk1-f174.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=uQcausP/p13fIUWxfrAMuOVxhKUEpTEwsjNKt4lsswk=; b=qO6DfiZ8FwFuufg+7CRJNCRC5VWxDot+pM63SnG7W6nyMc6Sd2uRfhs8umnGmWEabu xHD0TJD3tCYSD1WNackQl/c9zq+PgfGS0Eh4os0GPFSRSjp5lpqwbxly15E6oZ0Dk1cF SeuVqHaJrKeg9gQr6MjrjrrbnWE1uyPKFUrEHIxSz7jNyI69RasQT6ir8nM+mtC+jBCb RMyG19PRTr7N0xyN2JmdrdwMJmQnZMqHLIQU+wqFoc022Ns6qKSs0bsyAXh9sAsGvs51 vHmOaxZ7glfz/VmuXSa2YKiHHn+F+OILMwudP+iA1GrebvvzLocElNPKSST806zXlbHl +aow== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/4] Assume LLL_LOCK_INITIALIZER is 0 Date: Fri, 22 Feb 2019 16:27:02 -0300 Message-Id: <20190222192703.18177-3-adhemerval.zanella@linaro.org> In-Reply-To: <20190222192703.18177-1-adhemerval.zanella@linaro.org> References: <20190222192703.18177-1-adhemerval.zanella@linaro.org> Since hppa is not an outlier anymore regarding LLL_LOCK_INITIALIZER value, we can now assume it 0 for all architectures. Checked on a build for all major ABIs. * nptl/old_pthread_cond_broadcast.c (__pthread_cond_broadcast_2_0): Assume LLL_LOCK_INITIALIZER being 0. * nptl/old_pthread_cond_signal.c (__pthread_cond_signal_2_0): Likewise. * nptl/old_pthread_cond_timedwait.c (__pthread_cond_timedwait_2_0): Likewise. * nptl/old_pthread_cond_wait.c (__pthread_cond_wait_2_0): Likewise. * sysdeps/nptl/libc-lockP.h (__libc_lock_define_initialized): Likewise. --- nptl/old_pthread_cond_broadcast.c | 9 --------- nptl/old_pthread_cond_signal.c | 9 --------- nptl/old_pthread_cond_timedwait.c | 9 --------- nptl/old_pthread_cond_wait.c | 9 --------- sysdeps/nptl/libc-lockP.h | 17 +++-------------- 5 files changed, 3 insertions(+), 50 deletions(-) -- 2.17.1 diff --git a/nptl/old_pthread_cond_broadcast.c b/nptl/old_pthread_cond_broadcast.c index f561eb941f..04f285a1b1 100644 --- a/nptl/old_pthread_cond_broadcast.c +++ b/nptl/old_pthread_cond_broadcast.c @@ -31,18 +31,9 @@ __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond) { pthread_cond_t *newcond; -#if LLL_LOCK_INITIALIZER == 0 newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); if (newcond == NULL) return ENOMEM; -#else - newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); - if (newcond == NULL) - return ENOMEM; - - /* Initialize the condvar. */ - (void) pthread_cond_init (newcond, NULL); -#endif if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL)) /* Somebody else just initialized the condvar. */ diff --git a/nptl/old_pthread_cond_signal.c b/nptl/old_pthread_cond_signal.c index a167c8addc..9b67cb8a54 100644 --- a/nptl/old_pthread_cond_signal.c +++ b/nptl/old_pthread_cond_signal.c @@ -31,18 +31,9 @@ __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond) { pthread_cond_t *newcond; -#if LLL_LOCK_INITIALIZER == 0 newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); if (newcond == NULL) return ENOMEM; -#else - newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); - if (newcond == NULL) - return ENOMEM; - - /* Initialize the condvar. */ - (void) pthread_cond_init (newcond, NULL); -#endif if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL)) /* Somebody else just initialized the condvar. */ diff --git a/nptl/old_pthread_cond_timedwait.c b/nptl/old_pthread_cond_timedwait.c index f920320b13..a1fde85825 100644 --- a/nptl/old_pthread_cond_timedwait.c +++ b/nptl/old_pthread_cond_timedwait.c @@ -32,18 +32,9 @@ __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex, { pthread_cond_t *newcond; -#if LLL_LOCK_INITIALIZER == 0 newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); if (newcond == NULL) return ENOMEM; -#else - newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); - if (newcond == NULL) - return ENOMEM; - - /* Initialize the condvar. */ - (void) pthread_cond_init (newcond, NULL); -#endif if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL)) /* Somebody else just initialized the condvar. */ diff --git a/nptl/old_pthread_cond_wait.c b/nptl/old_pthread_cond_wait.c index 2be41b36d6..bb65340a17 100644 --- a/nptl/old_pthread_cond_wait.c +++ b/nptl/old_pthread_cond_wait.c @@ -31,18 +31,9 @@ __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex) { pthread_cond_t *newcond; -#if LLL_LOCK_INITIALIZER == 0 newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1); if (newcond == NULL) return ENOMEM; -#else - newcond = (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); - if (newcond == NULL) - return ENOMEM; - - /* Initialize the condvar. */ - (void) pthread_cond_init (newcond, NULL); -#endif if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL)) /* Somebody else just initialized the condvar. */ diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h index fc1bfe57e5..07d583f11a 100644 --- a/sysdeps/nptl/libc-lockP.h +++ b/sysdeps/nptl/libc-lockP.h @@ -71,23 +71,12 @@ typedef pthread_key_t __libc_key_t; For the C library we take a deeper look at the initializer. For this implementation all fields are initialized to zero. Therefore we don't initialize the variable which allows putting it into the - BSS section. (Except on PA-RISC and other odd architectures, where - initialized locks must be set to one due to the lack of normal - atomic operations.) */ + BSS section. */ +_Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0"); #define _LIBC_LOCK_INITIALIZER LLL_LOCK_INITIALIZER -#if IS_IN (libc) || IS_IN (libpthread) -# if LLL_LOCK_INITIALIZER == 0 -# define __libc_lock_define_initialized(CLASS,NAME) \ - CLASS __libc_lock_t NAME; -# else -# define __libc_lock_define_initialized(CLASS,NAME) \ - CLASS __libc_lock_t NAME = LLL_LOCK_INITIALIZER; -# endif -#else -# define __libc_lock_define_initialized(CLASS,NAME) \ +#define __libc_lock_define_initialized(CLASS,NAME) \ CLASS __libc_lock_t NAME; -#endif #define __libc_rwlock_define_initialized(CLASS,NAME) \ CLASS __libc_rwlock_t NAME = PTHREAD_RWLOCK_INITIALIZER;