From patchwork Tue Nov 26 14:20:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Adhemerval Zanella (Code Review)" X-Patchwork-Id: 1201079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107395-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gnutoolchain-gerrit.osci.io Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="GWKOoVZL"; 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 47MmKC6n3zz9sPK for ; Wed, 27 Nov 2019 01:20:47 +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:date:from:to:cc:subject:in-reply-to:references :reply-to:mime-version:content-transfer-encoding:content-type :message-id; q=dns; s=default; b=X+PfhXge1cbgKkKzyLUZiPhhPVqe7bv G55kxH8dfON0W0UajGcO9Z78o2GJGlcgDEe2WyiPlmX9g5xeDr/3U6sFq+Omi3Sv b35oFJGPsgbWrfB76s0fy790lQrfTqSFYrzVrgWox0AQcn1dsNq7BWQ8nPCvequK 7C05F2DMnzAo= 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:date:from:to:cc:subject:in-reply-to:references :reply-to:mime-version:content-transfer-encoding:content-type :message-id; s=default; bh=33/pF/MBM5/NxTbHAY5ddD25Cyw=; b=GWKOo VZL1crnFBzbF8j/etfDn9EdF+w2UU2gsDy8ciF9iUBsuuHMjlssGt4P2kMYHzEj4 uVet+ddmBkEuu6ETH9eP3+51j0dvahX5pYHbuvFbQNoso/6Thw4ka3lDKd4jBVnh Elza0GlIvuKpP0c/fArAwgbx2kKUWReReqe78s= Received: (qmail 128383 invoked by alias); 26 Nov 2019 14:20:25 -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 128332 invoked by uid 89); 26 Nov 2019 14:20:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy=3513 X-HELO: mx1.osci.io X-Gerrit-PatchSet: 5 Date: Tue, 26 Nov 2019 09:20:11 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Adhemerval Zanella , libc-alpha@sourceware.org Cc: Florian Weimer Auto-Submitted: auto-generated X-Gerrit-MessageType: merged Subject: [pushed] nptl: Add tests for internal pthread_rwlock_t offsets X-Gerrit-Change-Id: Iccc103d557de13d17e4a3f59a0cad2f4a640c148 X-Gerrit-Change-Number: 516 X-Gerrit-ChangeURL: X-Gerrit-Commit: 48dbce60cfdd328b671aaa9ee0c54ded3246ece9 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, adhemerval.zanella@linaro.org, fweimer@redhat.com, libc-alpha@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191126142011.6327428173@gnutoolchain-gerrit.osci.io> Sourceware to Gerrit sync has submitted this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/516 ...................................................................... nptl: Add tests for internal pthread_rwlock_t offsets This patch new build tests to check for internal fields offsets for internal pthread_rwlock_t definition. Althoug the '__data.__flags' field layout should be preserved due static initializators, the patch also adds tests for the futexes that may be used in a shared memory (although using different libc version in such scenario is not really supported). Checked with a build against all affected ABIs. Change-Id: Iccc103d557de13d17e4a3f59a0cad2f4a640c148 --- M nptl/pthread_rwlock_init.c M sysdeps/aarch64/nptl/pthread-offsets.h M sysdeps/alpha/nptl/pthread-offsets.h M sysdeps/arm/nptl/pthread-offsets.h M sysdeps/csky/nptl/pthread-offsets.h M sysdeps/hppa/nptl/pthread-offsets.h M sysdeps/i386/nptl/pthread-offsets.h M sysdeps/ia64/nptl/pthread-offsets.h M sysdeps/m68k/nptl/pthread-offsets.h M sysdeps/microblaze/nptl/pthread-offsets.h M sysdeps/mips/nptl/pthread-offsets.h M sysdeps/nios2/nptl/pthread-offsets.h M sysdeps/powerpc/nptl/pthread-offsets.h M sysdeps/riscv/nptl/pthread-offsets.h M sysdeps/s390/nptl/pthread-offsets.h M sysdeps/sh/nptl/pthread-offsets.h M sysdeps/sparc/nptl/pthread-offsets.h M sysdeps/x86_64/nptl/pthread-offsets.h 18 files changed, 78 insertions(+), 0 deletions(-) Approvals: Florian Weimer: Looks good to me, approved diff --git a/nptl/pthread_rwlock_init.c b/nptl/pthread_rwlock_init.c index 04f0d40..8813e32 100644 --- a/nptl/pthread_rwlock_init.c +++ b/nptl/pthread_rwlock_init.c @@ -18,6 +18,7 @@ #include "pthreadP.h" #include +#include static const struct pthread_rwlockattr default_rwlockattr = @@ -34,6 +35,13 @@ { ASSERT_TYPE_SIZE (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T); + /* The __flags is the only field where its offset should be checked to + avoid ABI breakage with static initializers. */ + ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__flags, + __PTHREAD_RWLOCK_FLAGS_OFFSET); + ASSERT_PTHREAD_INTERNAL_MEMBER_SIZE (pthread_rwlock_t, __data.__flags, + int); + const struct pthread_rwlockattr *iattr; iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_rwlockattr; diff --git a/sysdeps/aarch64/nptl/pthread-offsets.h b/sysdeps/aarch64/nptl/pthread-offsets.h index 8208f6f..7fe06e0 100644 --- a/sysdeps/aarch64/nptl/pthread-offsets.h +++ b/sysdeps/aarch64/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 16 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 diff --git a/sysdeps/alpha/nptl/pthread-offsets.h b/sysdeps/alpha/nptl/pthread-offsets.h index 8208f6f..7fe06e0 100644 --- a/sysdeps/alpha/nptl/pthread-offsets.h +++ b/sysdeps/alpha/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 16 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 diff --git a/sysdeps/arm/nptl/pthread-offsets.h b/sysdeps/arm/nptl/pthread-offsets.h index e4e775d..e9accba 100644 --- a/sysdeps/arm/nptl/pthread-offsets.h +++ b/sysdeps/arm/nptl/pthread-offsets.h @@ -1 +1,7 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#if __BYTE_ORDER == __BIG_ENDIAN +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 +#endif diff --git a/sysdeps/csky/nptl/pthread-offsets.h b/sysdeps/csky/nptl/pthread-offsets.h index e4e775d..7940d1f 100644 --- a/sysdeps/csky/nptl/pthread-offsets.h +++ b/sysdeps/csky/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 diff --git a/sysdeps/hppa/nptl/pthread-offsets.h b/sysdeps/hppa/nptl/pthread-offsets.h index e4e775d..1c11eff 100644 --- a/sysdeps/hppa/nptl/pthread-offsets.h +++ b/sysdeps/hppa/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 51 diff --git a/sysdeps/i386/nptl/pthread-offsets.h b/sysdeps/i386/nptl/pthread-offsets.h index e4e775d..7940d1f 100644 --- a/sysdeps/i386/nptl/pthread-offsets.h +++ b/sysdeps/i386/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 diff --git a/sysdeps/ia64/nptl/pthread-offsets.h b/sysdeps/ia64/nptl/pthread-offsets.h index 8208f6f..7fe06e0 100644 --- a/sysdeps/ia64/nptl/pthread-offsets.h +++ b/sysdeps/ia64/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 16 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 diff --git a/sysdeps/m68k/nptl/pthread-offsets.h b/sysdeps/m68k/nptl/pthread-offsets.h index e4e775d..4d6696a 100644 --- a/sysdeps/m68k/nptl/pthread-offsets.h +++ b/sysdeps/m68k/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 diff --git a/sysdeps/microblaze/nptl/pthread-offsets.h b/sysdeps/microblaze/nptl/pthread-offsets.h index e4e775d..e9accba 100644 --- a/sysdeps/microblaze/nptl/pthread-offsets.h +++ b/sysdeps/microblaze/nptl/pthread-offsets.h @@ -1 +1,7 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#if __BYTE_ORDER == __BIG_ENDIAN +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 +#endif diff --git a/sysdeps/mips/nptl/pthread-offsets.h b/sysdeps/mips/nptl/pthread-offsets.h index e96d34a..e52b347 100644 --- a/sysdeps/mips/nptl/pthread-offsets.h +++ b/sysdeps/mips/nptl/pthread-offsets.h @@ -3,3 +3,13 @@ #else # define __PTHREAD_MUTEX_KIND_OFFSET 12 #endif + +#if _MIPS_SIM == _ABI64 +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 +#else +# if __BYTE_ORDER == __BIG_ENDIAN +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 +# else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 +# endif +#endif diff --git a/sysdeps/nios2/nptl/pthread-offsets.h b/sysdeps/nios2/nptl/pthread-offsets.h index e4e775d..7940d1f 100644 --- a/sysdeps/nios2/nptl/pthread-offsets.h +++ b/sysdeps/nios2/nptl/pthread-offsets.h @@ -1 +1,3 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 diff --git a/sysdeps/powerpc/nptl/pthread-offsets.h b/sysdeps/powerpc/nptl/pthread-offsets.h index 25b5bf2..9e21121 100644 --- a/sysdeps/powerpc/nptl/pthread-offsets.h +++ b/sysdeps/powerpc/nptl/pthread-offsets.h @@ -5,3 +5,9 @@ #else # define __PTHREAD_MUTEX_KIND_OFFSET 12 #endif + +#if __WORDSIZE == 64 +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 +#endif diff --git a/sysdeps/riscv/nptl/pthread-offsets.h b/sysdeps/riscv/nptl/pthread-offsets.h index 6fc032f..4f14276 100644 --- a/sysdeps/riscv/nptl/pthread-offsets.h +++ b/sysdeps/riscv/nptl/pthread-offsets.h @@ -18,3 +18,5 @@ . */ #define __PTHREAD_MUTEX_KIND_OFFSET 16 + +#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 diff --git a/sysdeps/s390/nptl/pthread-offsets.h b/sysdeps/s390/nptl/pthread-offsets.h index 25b5bf2..9e21121 100644 --- a/sysdeps/s390/nptl/pthread-offsets.h +++ b/sysdeps/s390/nptl/pthread-offsets.h @@ -5,3 +5,9 @@ #else # define __PTHREAD_MUTEX_KIND_OFFSET 12 #endif + +#if __WORDSIZE == 64 +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 +#endif diff --git a/sysdeps/sh/nptl/pthread-offsets.h b/sysdeps/sh/nptl/pthread-offsets.h index e4e775d..e9accba 100644 --- a/sysdeps/sh/nptl/pthread-offsets.h +++ b/sysdeps/sh/nptl/pthread-offsets.h @@ -1 +1,7 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 12 + +#if __BYTE_ORDER == __BIG_ENDIAN +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 +#endif diff --git a/sysdeps/sparc/nptl/pthread-offsets.h b/sysdeps/sparc/nptl/pthread-offsets.h index 25b5bf2..9e21121 100644 --- a/sysdeps/sparc/nptl/pthread-offsets.h +++ b/sysdeps/sparc/nptl/pthread-offsets.h @@ -5,3 +5,9 @@ #else # define __PTHREAD_MUTEX_KIND_OFFSET 12 #endif + +#if __WORDSIZE == 64 +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27 +#endif diff --git a/sysdeps/x86_64/nptl/pthread-offsets.h b/sysdeps/x86_64/nptl/pthread-offsets.h index 8208f6f..a311da4 100644 --- a/sysdeps/x86_64/nptl/pthread-offsets.h +++ b/sysdeps/x86_64/nptl/pthread-offsets.h @@ -1 +1,7 @@ #define __PTHREAD_MUTEX_KIND_OFFSET 16 + +#ifdef __ILP32__ +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 40 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 +#endif