From patchwork Tue Apr 26 19:15:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 53246 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 02F2A3858403 for ; Tue, 26 Apr 2022 19:18:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 02F2A3858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651000731; bh=GBkJ03fn46IDj7XMOj2evTp+1Wm9pnDSQaqy9d3ZqOA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Z/pcJDUIbacUXr0j9GxVrMZjWeOIDymXNaQ5IHOvKldi/nrfhciWPLVht1HNtwCMu dJgd+nTAEnlGGYLow3VlncLkXTI7vHpBr/UsT7JbTjoAw26xaXZ4piYjWfnFI52ErA YsMtEykJ+3HqVYs1RM/1w+GQp5DlR/S75acCyKps= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by sourceware.org (Postfix) with ESMTPS id ECA4D385801B for ; Tue, 26 Apr 2022 19:15:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECA4D385801B Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-e5e433d66dso20425913fac.5 for ; Tue, 26 Apr 2022 12:15:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GBkJ03fn46IDj7XMOj2evTp+1Wm9pnDSQaqy9d3ZqOA=; b=OUWd61muT8y4ZHR3Pvs+8/TzT4FYY8hXkGhR2yCChWeZPii0IqqM1hFk0ZCxsjVIjC 7SWvzXpNmBe7bal+fjBPBluLnhv5pMJAXamcEy2AVA/d7A4Sd+PlmZwa7E23v8K1rJLw Z+xS1P55kdTuzHa8Q/iDowhhU00xiNsdzT56HwezfgOtLu69kdPLL8hvHv3D8mZqTEth jVl7jJhY+w+wEZSlWJWr8m0oQ83i1naqSUtG2/zH0N8XrdkCcTHciTTI7mNDUbOQ6XRI pjHhqf0om6tQluq93+o1kWBrgyBsMtvhaj9dHP3VQU6y1BVEDwB1GLl0U7KbgSp1ABM3 lH3g== X-Gm-Message-State: AOAM532/Wk+/c8Vn9sO65tGNg2u0zwvRk6uFR5mmhCByfLFqItuW9K8d qmq3W6JN2+WqGxtwaX4nmFNBwl9R8E18CQ== X-Google-Smtp-Source: ABdhPJzYfvwaf0KPGwEYLoAyZHJzdp9kCyMBMCh86aQzuGG6kFUNlyjCSuPZU605zvEa6qdl+PMzFA== X-Received: by 2002:a05:6870:5620:b0:e9:ff1:c8e8 with SMTP id m32-20020a056870562000b000e90ff1c8e8mr7862886oao.8.1651000535873; Tue, 26 Apr 2022 12:15:35 -0700 (PDT) Received: from birita.. ([2804:431:c7ca:4214:745b:d03c:b667:123b]) by smtp.gmail.com with ESMTPSA id 123-20020a4a0181000000b00324a1217e96sm5884129oor.35.2022.04.26.12.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 12:15:35 -0700 (PDT) To: libc-alpha@sourceware.org, Florian Weimer Subject: [PATCH v2 4/4] Assume _LIBC and libc module for libc-lock.h Date: Tue, 26 Apr 2022 16:15:23 -0300 Message-Id: <20220426191523.833171-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220426191523.833171-1-adhemerval.zanella@linaro.org> References: <20220426191523.833171-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The libc-lock.h is not used outside glibc nor with modules different than libc or libc_malloc_debug. Checked on x86_64-linux-gnu. --- sysdeps/mach/libc-lock.h | 9 ------ sysdeps/nptl/libc-lock.h | 67 ++++++---------------------------------- 2 files changed, 10 insertions(+), 66 deletions(-) diff --git a/sysdeps/mach/libc-lock.h b/sysdeps/mach/libc-lock.h index ee38948d1e..bb1a492fa9 100644 --- a/sysdeps/mach/libc-lock.h +++ b/sysdeps/mach/libc-lock.h @@ -19,8 +19,6 @@ #ifndef _LIBC_LOCK_H #define _LIBC_LOCK_H 1 -#ifdef _LIBC - #include #include @@ -38,11 +36,6 @@ extern char __libc_lock_self0[0]; #define __libc_lock_owner_self() \ (__LIBC_NO_TLS () ? (void *)&__libc_lock_self0 : THREAD_SELF) -#else -typedef struct __libc_lock_opaque__ __libc_lock_t; -typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t; -#endif - /* Define a lock variable NAME with storage class CLASS. The lock must be initialized with __libc_lock_init before it can be used (or define it with __libc_lock_define_initialized, below). Use `extern' for CLASS to @@ -215,7 +208,6 @@ struct __libc_once /* Get once control variable. */ #define __libc_once_get(ONCE_CONTROL) ((ONCE_CONTROL).done != 0) -#ifdef _LIBC /* We need portable names for some functions. E.g., when they are used as argument to __libc_cleanup_region_start. */ #define __libc_mutex_unlock __libc_lock_unlock @@ -223,6 +215,5 @@ struct __libc_once /* Hide the definitions which are only supposed to be used inside libc in a separate file. This file is not present in the installation! */ # include -#endif #endif /* libc-lock.h */ diff --git a/sysdeps/nptl/libc-lock.h b/sysdeps/nptl/libc-lock.h index abd84e71b4..5c85a250d7 100644 --- a/sysdeps/nptl/libc-lock.h +++ b/sysdeps/nptl/libc-lock.h @@ -25,11 +25,7 @@ /* Mutex type. */ -#if !IS_IN (libc) && !IS_IN (libc_malloc_debug) -typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t; -#else typedef struct { int lock; int cnt; void *owner; } __libc_lock_recursive_t; -#endif /* Define a lock variable NAME with storage class CLASS. The lock must be initialized with __libc_lock_init before it can be used (or define it @@ -43,68 +39,36 @@ typedef struct { int lock; int cnt; void *owner; } __libc_lock_recursive_t; /* Define an initialized recursive lock variable NAME with storage class CLASS. */ -#if IS_IN (libc) || IS_IN (libc_malloc_debug) -# define __libc_lock_define_initialized_recursive(CLASS, NAME) \ +#define __libc_lock_define_initialized_recursive(CLASS, NAME) \ CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER; -# define _LIBC_LOCK_RECURSIVE_INITIALIZER \ +#define _LIBC_LOCK_RECURSIVE_INITIALIZER \ { LLL_LOCK_INITIALIZER, 0, NULL } -#else -# define __libc_lock_define_initialized_recursive(CLASS,NAME) \ - CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER; -# define _LIBC_LOCK_RECURSIVE_INITIALIZER \ - {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP} -#endif /* Initialize a recursive mutex. */ -#if IS_IN (libc) || IS_IN (libc_malloc_debug) -# define __libc_lock_init_recursive(NAME) \ +#define __libc_lock_init_recursive(NAME) \ ((void) ((NAME) = (__libc_lock_recursive_t) _LIBC_LOCK_RECURSIVE_INITIALIZER)) -#else -# define __libc_lock_init_recursive(NAME) \ - do { \ - if (__pthread_mutex_init != NULL) \ - { \ - pthread_mutexattr_t __attr; \ - __pthread_mutexattr_init (&__attr); \ - __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \ - __pthread_mutex_init (&(NAME).mutex, &__attr); \ - __pthread_mutexattr_destroy (&__attr); \ - } \ - } while (0) -#endif /* Finalize recursive named lock. */ -#if IS_IN (libc) || IS_IN (libc_malloc_debug) -# define __libc_lock_fini_recursive(NAME) ((void) 0) -#else -# define __libc_lock_fini_recursive(NAME) \ - __libc_maybe_call (__pthread_mutex_destroy, (&(NAME).mutex), 0) -#endif +#define __libc_lock_fini_recursive(NAME) ((void) 0) /* Lock the recursive named lock variable. */ -#if IS_IN (libc) || IS_IN (libc_malloc_debug) -# define __libc_lock_lock_recursive(NAME) \ +#define __libc_lock_lock_recursive(NAME) \ do { \ void *self = THREAD_SELF; \ - if (!SINGLE_THREAD_P && (NAME).owner != self) \ + if (!SINGLE_THREAD_P && (NAME).owner != self) \ { \ lll_lock ((NAME).lock, LLL_PRIVATE); \ (NAME).owner = self; \ } \ ++(NAME).cnt; \ } while (0) -#else -# define __libc_lock_lock_recursive(NAME) \ - __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0) -#endif /* Try to lock the recursive named lock variable. */ -#if IS_IN (libc) || IS_IN (libc_malloc_debug) -# define __libc_lock_trylock_recursive(NAME) \ +#define __libc_lock_trylock_recursive(NAME) \ ({ \ int result = 0; \ void *self = THREAD_SELF; \ - if (!SINGLE_THREAD_P && (NAME).owner != self) \ + if (!SINGLE_THREAD_P && (NAME).owner != self) \ { \ if (lll_trylock ((NAME).lock) == 0) \ { \ @@ -118,15 +82,10 @@ typedef struct { int lock; int cnt; void *owner; } __libc_lock_recursive_t; ++(NAME).cnt; \ result; \ }) -#else -# define __libc_lock_trylock_recursive(NAME) \ - __libc_maybe_call (__pthread_mutex_trylock, (&(NAME).mutex), 0) -#endif /* Unlock the recursive named lock variable. */ -#if IS_IN (libc) || IS_IN (libc_malloc_debug) /* We do no error checking here. */ -# define __libc_lock_unlock_recursive(NAME) \ +#define __libc_lock_unlock_recursive(NAME) \ do { \ if (--(NAME).cnt == 0) \ { \ @@ -135,10 +94,6 @@ typedef struct { int lock; int cnt; void *owner; } __libc_lock_recursive_t; lll_unlock ((NAME).lock, LLL_PRIVATE); \ } \ } while (0) -#else -# define __libc_lock_unlock_recursive(NAME) \ - __libc_maybe_call (__pthread_mutex_unlock, (&(NAME).mutex), 0) -#endif /* Put the unwind buffer BUFFER on the per-thread callback stack. The caller must fill BUFFER->__routine and BUFFER->__arg before calling @@ -178,8 +133,6 @@ libc_hidden_proto (__libc_cleanup_pop_restore) /* Hide the definitions which are only supposed to be used inside libc in a separate file. This file is not present in the installation! */ -#ifdef _LIBC -# include "libc-lockP.h" -#endif +#include "libc-lockP.h" #endif /* libc-lock.h */