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: 1047071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-100228-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="pw7RFzxO"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="qO6DfiZ8"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 445hF76Sjcz9s70 for ; Sat, 23 Feb 2019 06:27:39 +1100 (AEDT) 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=VPQYGTquvGNk7kg09nF7meOexm6KjPz 40LxtZP6/GUdQeAVNczHJMIpfa6SDINXnLvRqyNAEVfE5/ydjNGdEGIuEMWGYGZl GUtbmdvIzdJDbZOH0oX2C00Fk1+Q+Rt7VXs1RGrsrwmrYUR0vO3PTTvLPsx2jg7h DQEJiAVvWz2o= 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=pw7RF zxOYiDtaVbh0RqwV2DejfqKZDbQPXEPnzyRBFqDeeg7SOU9kv2+ImHD8TsyLqel7 EhJZNARwFxBTh9ov26QlXjGgRRDzfuAK35qbeHfXkeLeKF73lHlTJn10ldUnT9JN IOKthy4jxl4hS1iG7cQ/l8KX2dHCIj4zR26Lkw= 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== 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(-) 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;