From patchwork Mon Oct 16 20:44:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 826508 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-85911-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Acso4S2U"; 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 3yG9LD0ZwJz9s76 for ; Tue, 17 Oct 2017 07:44:51 +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=WYay2vrwiMRxopmMACXDj9rYnAim9uU eSN92M4yLFuzKoIlj4SWlq/CrUZvC7PvMR03KHQaBT1mOB5Huk6JBBlcJSEI6duR PMJ01lA7G+DgIND1VTT9R6/5Lp6JP+zeLCxDiYoKPOgcnrtGbmw9tr7gCXLCa24o APmi6Vfi/nH4= 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=MDm6mG4RAZRt4OeFyOw6LjI2/6U=; b=Acso4 S2UOL6JicM0QjsKeGK5wu9RAkEpXFO1eonVgyQivbHEYqEy2HCxzzyD9OgWfkGiz 7RdVMzt1Z0db6lIUjASe9qoaWMngKdx3ksvbMeDfhy2COW3pa5HeNq6/sFC5atSM c+oDob3jnD4aefukToc0Yf093ZFnRTvb/OfVqo= Received: (qmail 129633 invoked by alias); 16 Oct 2017 20:44:27 -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 129574 invoked by uid 89); 16 Oct 2017 20:44:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No 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, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=(unknown) X-HELO: mail-qk0-f177.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=SxY9o0lFmGDWsEgBdEcj2E20+ZACfqk092HBREZXF4c=; b=gSixvUTogAoD1kApklohDil8NaE9ZYX8eRA2fQxxta5ix8IE2FbDCsKVlErk0JpXBA DYYAnUffVwH2xb8Ps+gaUEFC7+9UXJwS5s7jaR1Rr1K2CpLcgg/ZXdnJmeWlGLS2QDOx I5azUTu/IOVOsatzZtlcYvxM90rUmY65nbbJXSIoz6gs3BZ+rBG5e38cQ0C9LPfRORQX rAv+jfP5dzPxntAKLQAF+uuu6dbmK5e0ZCmf8P4MlkmObX1BqSkdi27mqS08vPP2+/T3 I9PNyuQ32vNEMAcqDvzDtHIbpnKZV1uHf3B/1Rj2tT1uS3HwY+5pS7niawGV5oN7ry/D lGAg== X-Gm-Message-State: AMCzsaViIE2vRGDw9vZrNA26nfqYZbiTrtXMQtX64y/EwlHLiOoRuyZS ejQObmXyq48VVn9BkA32RJJa8YUmXkY= X-Google-Smtp-Source: ABhQp+Rd0Hy2fl1hzU1n+nUU+kNAeqbFYmqVSwCH7smK+Ez+FEjwnRFrrU/EcInuPvXxBAC3ZB1Adg== X-Received: by 10.55.137.198 with SMTP id l189mr16559355qkd.169.1508186663110; Mon, 16 Oct 2017 13:44:23 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/3] nptl: Add tests for internal pthread_mutex_t offsets Date: Mon, 16 Oct 2017 18:44:13 -0200 Message-Id: <1508186653-24430-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1508186653-24430-1-git-send-email-adhemerval.zanella@linaro.org> References: <1508186653-24430-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds a new build test to check for internal fields offsets uses on pthread_mutex_t static initialization macros (PTHREAD_MUTEX_INITIALIZER, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, and PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP). Currently the only field which is statically initialized to a non zero/null value is pthread_mutex_t.__data.__kind value. A new internal header (pthread-offset.h) is added to each major ABI with the reference value. Checked on x86_64-linux-gnu and with a build check for all affected ABIs (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf, hppa-linux-gnu, i686-linux-gnu, ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu, mips64-linux-gnu, mips64-n32-linux-gnu, mips-linux-gnu, powerpc64le-linux-gnu, powerpc-linux-gnu, s390-linux-gnu, s390x-linux-gnu, sh4-linux-gnu, sparc64-linux-gnu, sparcv9-linux-gnu, tilegx-linux-gnu, tilegx-linux-gnu-x32, tilepro-linux-gnu, x86_64-linux-gnu, and x86_64-linux-x32). * nptl/Makefile (tests-internal): Add tst-offsets. * nptl/tst-offsets.c: New file. * sysdeps/aarch64/nptl/pthread-offsets.h: Likewise. * sysdeps/alpha/nptl/pthread-offsets.h: Likewise. * sysdeps/arm/nptl/pthread-offsets.h: Likewise. * sysdeps/hppa/nptl/pthread-offsets.h: Likewise. * sysdeps/i386/nptl/pthread-offsets.h: Likewise. * sysdeps/ia64/nptl/pthread-offsets.h: Likewise. * sysdeps/m68k/nptl/pthread-offsets.h: Likewise. * sysdeps/microblaze/nptl/pthread-offsets.h: Likewise. * sysdeps/mips/nptl/pthread-offsets.h: Likewise. * sysdeps/nios2/nptl/pthread-offsets.h: Likewise. * sysdeps/powerpc/nptl/pthread-offsets.h: Likewise. * sysdeps/s390/nptl/pthread-offsets.h: Likewise. * sysdeps/sh/nptl/pthread-offsets.h: Likewise. * sysdeps/sparc/nptl/pthread-offsets.h: Likewise. * sysdeps/tile/nptl/pthread-offsets.h: Likewise. * sysdeps/x86_64/nptl/pthread-offsets.h: Likewise. --- ChangeLog | 19 ++++++++++++++ nptl/Makefile | 2 +- nptl/tst-offsets.c | 41 +++++++++++++++++++++++++++++++ sysdeps/aarch64/nptl/pthread-offsets.h | 1 + sysdeps/alpha/nptl/pthread-offsets.h | 1 + sysdeps/arm/nptl/pthread-offsets.h | 1 + sysdeps/hppa/nptl/pthread-offsets.h | 1 + sysdeps/i386/nptl/pthread-offsets.h | 1 + sysdeps/ia64/nptl/pthread-offsets.h | 1 + sysdeps/m68k/nptl/pthread-offsets.h | 1 + sysdeps/microblaze/nptl/pthread-offsets.h | 1 + sysdeps/mips/nptl/pthread-offsets.h | 5 ++++ sysdeps/nios2/nptl/pthread-offsets.h | 1 + sysdeps/powerpc/nptl/pthread-offsets.h | 7 ++++++ sysdeps/s390/nptl/pthread-offsets.h | 7 ++++++ sysdeps/sh/nptl/pthread-offsets.h | 1 + sysdeps/sparc/nptl/pthread-offsets.h | 7 ++++++ sysdeps/tile/nptl/pthread-offsets.h | 7 ++++++ sysdeps/x86_64/nptl/pthread-offsets.h | 1 + 19 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 nptl/tst-offsets.c create mode 100644 sysdeps/aarch64/nptl/pthread-offsets.h create mode 100644 sysdeps/alpha/nptl/pthread-offsets.h create mode 100644 sysdeps/arm/nptl/pthread-offsets.h create mode 100644 sysdeps/hppa/nptl/pthread-offsets.h create mode 100644 sysdeps/i386/nptl/pthread-offsets.h create mode 100644 sysdeps/ia64/nptl/pthread-offsets.h create mode 100644 sysdeps/m68k/nptl/pthread-offsets.h create mode 100644 sysdeps/microblaze/nptl/pthread-offsets.h create mode 100644 sysdeps/mips/nptl/pthread-offsets.h create mode 100644 sysdeps/nios2/nptl/pthread-offsets.h create mode 100644 sysdeps/powerpc/nptl/pthread-offsets.h create mode 100644 sysdeps/s390/nptl/pthread-offsets.h create mode 100644 sysdeps/sh/nptl/pthread-offsets.h create mode 100644 sysdeps/sparc/nptl/pthread-offsets.h create mode 100644 sysdeps/tile/nptl/pthread-offsets.h create mode 100644 sysdeps/x86_64/nptl/pthread-offsets.h diff --git a/nptl/Makefile b/nptl/Makefile index d819349..7492b06 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -304,7 +304,7 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \ tst-thread_local1 tst-mutex-errorcheck tst-robust10 \ tst-robust-fork tst-create-detached tst-memstream -tests-internal := tst-typesizes \ +tests-internal := tst-typesizes tst-offsets \ tst-rwlock19 tst-rwlock20 \ tst-sem11 tst-sem12 tst-sem13 \ tst-barrier5 tst-signal7 tst-mutex8 tst-mutex8-static \ diff --git a/nptl/tst-offsets.c b/nptl/tst-offsets.c new file mode 100644 index 0000000..1aa8a0e --- /dev/null +++ b/nptl/tst-offsets.c @@ -0,0 +1,41 @@ +/* Check pthread internal offsets. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include + +#define STR_HELPER(x) #x +#define STR(x) STR_HELPER(x) + +static int +do_test (void) +{ + /* Check if internal fields in pthread_mutex_t used by static initializers + have the expected offset. */ + _Static_assert (offsetof (pthread_mutex_t, __data.__kind) == + __PTHREAD_MUTEX_KIND_OFFSET, + "offset of __kind field != " + STR (__PTHREAD_MUTEX_KIND_OFFSET)); + + return 0; +} + +#include diff --git a/sysdeps/aarch64/nptl/pthread-offsets.h b/sysdeps/aarch64/nptl/pthread-offsets.h new file mode 100644 index 0000000..aaca502 --- /dev/null +++ b/sysdeps/aarch64/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 16 diff --git a/sysdeps/alpha/nptl/pthread-offsets.h b/sysdeps/alpha/nptl/pthread-offsets.h new file mode 100644 index 0000000..aaca502 --- /dev/null +++ b/sysdeps/alpha/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 16 diff --git a/sysdeps/arm/nptl/pthread-offsets.h b/sysdeps/arm/nptl/pthread-offsets.h new file mode 100644 index 0000000..235677f --- /dev/null +++ b/sysdeps/arm/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 12 diff --git a/sysdeps/hppa/nptl/pthread-offsets.h b/sysdeps/hppa/nptl/pthread-offsets.h new file mode 100644 index 0000000..235677f --- /dev/null +++ b/sysdeps/hppa/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 12 diff --git a/sysdeps/i386/nptl/pthread-offsets.h b/sysdeps/i386/nptl/pthread-offsets.h new file mode 100644 index 0000000..235677f --- /dev/null +++ b/sysdeps/i386/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 12 diff --git a/sysdeps/ia64/nptl/pthread-offsets.h b/sysdeps/ia64/nptl/pthread-offsets.h new file mode 100644 index 0000000..aaca502 --- /dev/null +++ b/sysdeps/ia64/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 16 diff --git a/sysdeps/m68k/nptl/pthread-offsets.h b/sysdeps/m68k/nptl/pthread-offsets.h new file mode 100644 index 0000000..235677f --- /dev/null +++ b/sysdeps/m68k/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 12 diff --git a/sysdeps/microblaze/nptl/pthread-offsets.h b/sysdeps/microblaze/nptl/pthread-offsets.h new file mode 100644 index 0000000..235677f --- /dev/null +++ b/sysdeps/microblaze/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 12 diff --git a/sysdeps/mips/nptl/pthread-offsets.h b/sysdeps/mips/nptl/pthread-offsets.h new file mode 100644 index 0000000..6dd3dea --- /dev/null +++ b/sysdeps/mips/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#if _MIPS_SIM == _ABI64 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +#else +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +#endif diff --git a/sysdeps/nios2/nptl/pthread-offsets.h b/sysdeps/nios2/nptl/pthread-offsets.h new file mode 100644 index 0000000..235677f --- /dev/null +++ b/sysdeps/nios2/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 12 diff --git a/sysdeps/powerpc/nptl/pthread-offsets.h b/sysdeps/powerpc/nptl/pthread-offsets.h new file mode 100644 index 0000000..f88961b --- /dev/null +++ b/sysdeps/powerpc/nptl/pthread-offsets.h @@ -0,0 +1,7 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +#else +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +#endif diff --git a/sysdeps/s390/nptl/pthread-offsets.h b/sysdeps/s390/nptl/pthread-offsets.h new file mode 100644 index 0000000..f88961b --- /dev/null +++ b/sysdeps/s390/nptl/pthread-offsets.h @@ -0,0 +1,7 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +#else +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +#endif diff --git a/sysdeps/sh/nptl/pthread-offsets.h b/sysdeps/sh/nptl/pthread-offsets.h new file mode 100644 index 0000000..235677f --- /dev/null +++ b/sysdeps/sh/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 12 diff --git a/sysdeps/sparc/nptl/pthread-offsets.h b/sysdeps/sparc/nptl/pthread-offsets.h new file mode 100644 index 0000000..f88961b --- /dev/null +++ b/sysdeps/sparc/nptl/pthread-offsets.h @@ -0,0 +1,7 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +#else +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +#endif diff --git a/sysdeps/tile/nptl/pthread-offsets.h b/sysdeps/tile/nptl/pthread-offsets.h new file mode 100644 index 0000000..f88961b --- /dev/null +++ b/sysdeps/tile/nptl/pthread-offsets.h @@ -0,0 +1,7 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +#else +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +#endif diff --git a/sysdeps/x86_64/nptl/pthread-offsets.h b/sysdeps/x86_64/nptl/pthread-offsets.h new file mode 100644 index 0000000..aaca502 --- /dev/null +++ b/sysdeps/x86_64/nptl/pthread-offsets.h @@ -0,0 +1 @@ +#define __PTHREAD_MUTEX_KIND_OFFSET 16