From patchwork Thu Oct 26 17:14:25 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: 117249 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1014866qgn; Thu, 26 Oct 2017 10:14:50 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T5rqc6yCC/NCxQdvkanJgcQt3Nhg3ylpZWV5FlW41S6Jhvnihoj3w0uZ2ZJuQ9UzDCfILc X-Received: by 10.98.218.83 with SMTP id w19mr6014010pfl.287.1509038090088; Thu, 26 Oct 2017 10:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509038090; cv=none; d=google.com; s=arc-20160816; b=RZ6x9girSKU8xnxYQHWD64yETKs8/D6MH8IZUvqgyg3MszQpO2fd3qGp6sKNsmVCEl ag8FsIoFoLRmRaCjn0Iczq6Tw3oKW447mu2cs4z1oILIL0ExKwV/NAGYKm6uliw7t+tC Kk9GUkuGD7fswljVNd4pifksGF3aIU1smrfldmiE3mZb+Vy5BrzIMvtXu70Yh1SZc5E/ lfue8S9fJ5ZDZbaSsfQqk5t5pXOrP5kJAHSu4NrowvzzKOkZ0z9l18/oOFoT70gqUqO9 HF+2w49DQCZwPQpMfooBgs827iZy9DUUBQ/keU4pa1nDPD3v+ao6jIACzW6O34YIFGoD 22sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=x0cYc7Glkh+8wo6TuBj0bSAK5SkMvNeNLSwjT6CqsjQ=; b=bQBPFltXjUiAvzJsHMiiEkCcY1FHX3c1FS8kcRr0DjMDArZlpYYgqU0YR+42tcONx1 qVie7la/VMEps4Axw1hIIrsnnuKHQm8fSv2yKIZRk1YGp5mYyiCm074x3q3qBbNa1J3Y TRU8U4syg1YtbB8ZHUnoyMTAnILaqEMmBgAVsMPdYC8BE+V4eYg/uBaE8xQOi/mqOlyQ cnW5dqPKZ/EnPVADidHBTuFdZ9M44kCb/DIda5hqwWF7bTejCHDa2jn51jH49V9+ld/0 fz9QZp3+AiqAIoKSUyyRVZ6ODorX/tXeeXqLSr90JI3fZO6UmKjheW1kMWsFz2Fo0SSG 6Vtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CUl8cQm5; spf=pass (google.com: domain of libc-alpha-return-86395-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86395-patch=linaro.org@sourceware.org; dmarc=fail (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 q75si3933293pfj.449.2017.10.26.10.14.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 10:14:50 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86395-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=CUl8cQm5; spf=pass (google.com: domain of libc-alpha-return-86395-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86395-patch=linaro.org@sourceware.org; dmarc=fail (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; q=dns; s= default; b=mr1DyhiT48jxF4FEVkpYWFRv1SbRFH1FcUTr3HVb7T1s6NLgCQ63D O3rAKO12Npx/WWcZ0h8XQ+xtoSVoTeqFfzkMk0AGfrKOTRk5UmumNO4XsVPmiZvK Ffn4ymoJivAqNFuon8U7D6R+Fgf05WjAOb0HSoyOHR1NqBpmeK7hkM= 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; s=default; bh=FKQoyjVV5mdF/t6Kjq7Y6/NMkTI=; b=CUl8cQm5pPJOzeUeEY+TeWKoUK8k AETMtbeO2SVFCRPocCRNogK/7uVRFEqv0zORSRyT4EiFqRnYKutqA1wFI2HwSwNe jo23FlZJxpQYOOxfd7SPVifogP6hVymg+ST4/cVe1P7Xh0IJrliLFLC4I6vI2D+/ fNHst2AGiH301sc= Received: (qmail 2204 invoked by alias); 26 Oct 2017 17:14:39 -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 1779 invoked by uid 89); 26 Oct 2017 17:14:38 -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=Hx-spam-relays-external:209.85.216.195, H*RU:209.85.216.195 X-HELO: mail-qt0-f195.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; bh=x0cYc7Glkh+8wo6TuBj0bSAK5SkMvNeNLSwjT6CqsjQ=; b=Nlf0U3OwqKTR88mU61Okd0HGelXp3/RBn90DpvaTDpvekSMgdIGO3onHAXOkSZrObj ak3caBiOhr4jASwt2rh+dMDCsgHrRoubT9AibeH3ErhzWJSEaDw67bo9X0RO4Ng19XW0 rvDacm19shP16m7VuK+tVUYA5XFUrcdKSehUN0StDmgMOI9b1oniGe5Bbes2cxstqai+ Lu/YBg7LRGYImkJykELTpxrCa0AcT7fjZP0SVw7059qC3GrwcfA4+Mw+olMVric25gRU /XhmXv/NwOSMnU+k54wcGx7btnNWhqxnzeBOFDD8oWvgRzZp278QYf29eL7Byrfmx3i1 BD3w== X-Gm-Message-State: AMCzsaVRxd14uCESAVCP4knM7w9mjR8QjkyrW2zAy1nb+2W6Vak1Q98E tbRN74uUBrTKOKX5h8LRt2xR02FwE60= X-Received: by 10.200.35.42 with SMTP id a39mr38125413qta.9.1509038073931; Thu, 26 Oct 2017 10:14:33 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 1/3] nptl: Add tests for internal pthread_mutex_t offsets Date: Thu, 26 Oct 2017 15:14:25 -0200 Message-Id: <1509038067-18532-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Move _Static_asserts tests from external tests to library build time. --- This patch adds a new build test to check for internal fields offsets for user visible internal field. Although currently the only field which is statically initialized to a non zero value is pthread_mutex_t.__data.__kind value, the tests also check the offset of __kind, __spins, __elision (if supported), and __list internal member. A 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). Signed-off-by: Adhemerval Zanella * nptl/pthreadP.h (ASSERT_PTHREAD_STRING, ASSERT_PTHREAD_INTERNAL_OFFSET): New macro. * nptl/pthread_mutex_init.c (__pthread_mutex_init): Add build time checks for internal pthread_mutex_t offsets. * sysdeps/aarch64/nptl/pthread-offsets.h (__PTHREAD_MUTEX_NUSERS_OFFSET, __PTHREAD_MUTEX_KIND_OFFSET, __PTHREAD_MUTEX_SPINS_OFFSET, __PTHREAD_MUTEX_ELISION_OFFSET, __PTHREAD_MUTEX_LIST_OFFSET): New macro. * 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 | 26 ++++++++++++++++++++++++++ nptl/pthreadP.h | 6 ++++++ nptl/pthread_mutex_init.c | 13 +++++++++++++ sysdeps/aarch64/nptl/pthread-offsets.h | 5 +++++ sysdeps/alpha/nptl/pthread-offsets.h | 5 +++++ sysdeps/arm/nptl/pthread-offsets.h | 5 +++++ sysdeps/hppa/nptl/pthread-offsets.h | 5 +++++ sysdeps/i386/nptl/pthread-offsets.h | 5 +++++ sysdeps/ia64/nptl/pthread-offsets.h | 5 +++++ sysdeps/m68k/nptl/pthread-offsets.h | 5 +++++ sysdeps/microblaze/nptl/pthread-offsets.h | 5 +++++ sysdeps/mips/nptl/pthread-offsets.h | 13 +++++++++++++ sysdeps/nios2/nptl/pthread-offsets.h | 5 +++++ sysdeps/powerpc/nptl/pthread-offsets.h | 15 +++++++++++++++ sysdeps/s390/nptl/pthread-offsets.h | 15 +++++++++++++++ sysdeps/sh/nptl/pthread-offsets.h | 5 +++++ sysdeps/sparc/nptl/pthread-offsets.h | 15 +++++++++++++++ sysdeps/tile/nptl/pthread-offsets.h | 15 +++++++++++++++ sysdeps/x86_64/nptl/pthread-offsets.h | 5 +++++ 19 files changed, 173 insertions(+) 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 -- 2.7.4 diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index dbf46b0..444bbd9 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -639,4 +639,10 @@ check_stacksize_attr (size_t st) return EINVAL; } +#define ASSERT_PTHREAD_STRING(x) __STRING (x) +#define ASSERT_PTHREAD_INTERNAL_OFFSET(__type, __member, __offset) \ + _Static_assert (offsetof (__type, __member) == __offset, \ + "offset of " #__member " field of " #__type " != " \ + ASSERT_PTHREAD_STRING (__offset)) + #endif /* pthreadP.h */ diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index 6f2fc80..e1f911b 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -23,6 +23,7 @@ #include #include "pthreadP.h" #include +#include #include @@ -58,6 +59,18 @@ __pthread_mutex_init (pthread_mutex_t *mutex, const struct pthread_mutexattr *imutexattr; assert (sizeof (pthread_mutex_t) <= __SIZEOF_PTHREAD_MUTEX_T); + ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__nusers, + __PTHREAD_MUTEX_NUSERS_OFFSET); + ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__kind, + __PTHREAD_MUTEX_KIND_OFFSET); + ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__spins, + __PTHREAD_MUTEX_SPINS_OFFSET); +#if __PTHREAD_MUTEX_LOCK_ELISION + ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__elision, + __PTHREAD_MUTEX_ELISION_OFFSET); +#endif + ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__list, + __PTHREAD_MUTEX_LIST_OFFSET); imutexattr = ((const struct pthread_mutexattr *) mutexattr ?: &default_mutexattr); diff --git a/sysdeps/aarch64/nptl/pthread-offsets.h b/sysdeps/aarch64/nptl/pthread-offsets.h new file mode 100644 index 0000000..16c6b0d --- /dev/null +++ b/sysdeps/aarch64/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +#define __PTHREAD_MUTEX_KIND_OFFSET 16 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 24 diff --git a/sysdeps/alpha/nptl/pthread-offsets.h b/sysdeps/alpha/nptl/pthread-offsets.h new file mode 100644 index 0000000..16c6b0d --- /dev/null +++ b/sysdeps/alpha/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +#define __PTHREAD_MUTEX_KIND_OFFSET 16 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 24 diff --git a/sysdeps/arm/nptl/pthread-offsets.h b/sysdeps/arm/nptl/pthread-offsets.h new file mode 100644 index 0000000..9617354 --- /dev/null +++ b/sysdeps/arm/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +#define __PTHREAD_MUTEX_KIND_OFFSET 12 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 20 diff --git a/sysdeps/hppa/nptl/pthread-offsets.h b/sysdeps/hppa/nptl/pthread-offsets.h new file mode 100644 index 0000000..8ae01b9 --- /dev/null +++ b/sysdeps/hppa/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 32 +#define __PTHREAD_MUTEX_KIND_OFFSET 12 +#define __PTHREAD_MUTEX_SPINS_OFFSET 36 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 36 diff --git a/sysdeps/i386/nptl/pthread-offsets.h b/sysdeps/i386/nptl/pthread-offsets.h new file mode 100644 index 0000000..9617354 --- /dev/null +++ b/sysdeps/i386/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +#define __PTHREAD_MUTEX_KIND_OFFSET 12 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 20 diff --git a/sysdeps/ia64/nptl/pthread-offsets.h b/sysdeps/ia64/nptl/pthread-offsets.h new file mode 100644 index 0000000..16c6b0d --- /dev/null +++ b/sysdeps/ia64/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +#define __PTHREAD_MUTEX_KIND_OFFSET 16 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 24 diff --git a/sysdeps/m68k/nptl/pthread-offsets.h b/sysdeps/m68k/nptl/pthread-offsets.h new file mode 100644 index 0000000..9617354 --- /dev/null +++ b/sysdeps/m68k/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +#define __PTHREAD_MUTEX_KIND_OFFSET 12 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 20 diff --git a/sysdeps/microblaze/nptl/pthread-offsets.h b/sysdeps/microblaze/nptl/pthread-offsets.h new file mode 100644 index 0000000..9617354 --- /dev/null +++ b/sysdeps/microblaze/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +#define __PTHREAD_MUTEX_KIND_OFFSET 12 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 20 diff --git a/sysdeps/mips/nptl/pthread-offsets.h b/sysdeps/mips/nptl/pthread-offsets.h new file mode 100644 index 0000000..0ac3eda --- /dev/null +++ b/sysdeps/mips/nptl/pthread-offsets.h @@ -0,0 +1,13 @@ +#if _MIPS_SIM == _ABI64 +# define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 24 +#else +# define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 20 +#endif diff --git a/sysdeps/nios2/nptl/pthread-offsets.h b/sysdeps/nios2/nptl/pthread-offsets.h new file mode 100644 index 0000000..9617354 --- /dev/null +++ b/sysdeps/nios2/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +#define __PTHREAD_MUTEX_KIND_OFFSET 12 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 20 diff --git a/sysdeps/powerpc/nptl/pthread-offsets.h b/sysdeps/powerpc/nptl/pthread-offsets.h new file mode 100644 index 0000000..bdda1f1 --- /dev/null +++ b/sysdeps/powerpc/nptl/pthread-offsets.h @@ -0,0 +1,15 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 24 +#else +# define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 20 +#endif diff --git a/sysdeps/s390/nptl/pthread-offsets.h b/sysdeps/s390/nptl/pthread-offsets.h new file mode 100644 index 0000000..bdda1f1 --- /dev/null +++ b/sysdeps/s390/nptl/pthread-offsets.h @@ -0,0 +1,15 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 24 +#else +# define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 20 +#endif diff --git a/sysdeps/sh/nptl/pthread-offsets.h b/sysdeps/sh/nptl/pthread-offsets.h new file mode 100644 index 0000000..9617354 --- /dev/null +++ b/sysdeps/sh/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +#define __PTHREAD_MUTEX_KIND_OFFSET 12 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 20 diff --git a/sysdeps/sparc/nptl/pthread-offsets.h b/sysdeps/sparc/nptl/pthread-offsets.h new file mode 100644 index 0000000..bdda1f1 --- /dev/null +++ b/sysdeps/sparc/nptl/pthread-offsets.h @@ -0,0 +1,15 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 24 +#else +# define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 20 +#endif diff --git a/sysdeps/tile/nptl/pthread-offsets.h b/sysdeps/tile/nptl/pthread-offsets.h new file mode 100644 index 0000000..bdda1f1 --- /dev/null +++ b/sysdeps/tile/nptl/pthread-offsets.h @@ -0,0 +1,15 @@ +#include + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 24 +#else +# define __PTHREAD_MUTEX_NUSERS_OFFSET 16 +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +# define __PTHREAD_MUTEX_SPINS_OFFSET 20 +# define __PTHREAD_MUTEX_ELISION_OFFSET 22 +# define __PTHREAD_MUTEX_LIST_OFFSET 20 +#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..16c6b0d --- /dev/null +++ b/sysdeps/x86_64/nptl/pthread-offsets.h @@ -0,0 +1,5 @@ +#define __PTHREAD_MUTEX_NUSERS_OFFSET 12 +#define __PTHREAD_MUTEX_KIND_OFFSET 16 +#define __PTHREAD_MUTEX_SPINS_OFFSET 20 +#define __PTHREAD_MUTEX_ELISION_OFFSET 22 +#define __PTHREAD_MUTEX_LIST_OFFSET 24 From patchwork Thu Oct 26 17:14:26 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: 117250 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1015063qgn; Thu, 26 Oct 2017 10:15:01 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RsHbmj7LH6goFNnFxOwu95xE5ayIRLvlm6eKW7BkzdXoUgp8dLFO22lkb6mxdPGKgxL0NF X-Received: by 10.101.68.133 with SMTP id l5mr5577846pgq.332.1509038101045; Thu, 26 Oct 2017 10:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509038101; cv=none; d=google.com; s=arc-20160816; b=qXqlS6wtaE6HTET7qnHhOvI0PBBr7FdOX/f4fnoLNh0GxKofFFasvG5xE2Wv4hz9BF QGNWrQ4NXqx7X7Q686zCelvqyB9yR8ZEKNQ92mjqHFl9OJcC+YnDklEoMhmTNCkxp73c Z0sXhSsnajzku7G/uPSgeGXC2padVSYYJ1CAY3XpTHZfxe3B2viEgzrYQqNc0HGpTb5V da7KHJASP0i9BBPjr3guQz/c6NEmTGosCqYsh5ybjItTFwoFTOdQpAL5xgr3QEBEPQBC QPNanuueVvNrNigFifzjIZ+aVfVUfiAhHLdSlUBoOv2dXFp0kF6UNkbNDphXNoVcZjeJ i7lA== 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:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=2OpYuSCL/1Ap7HeYtygqa+COGXly3DXRWDRQ/kFcONs=; b=0TJyJ5Ekg6L/ptINLSJB/K5kA3AX0d1uvXULamCCVS/ldgGCeXZQ/tqPjSyTYiNxj0 glQzQDsL1E8MDmBuH/nkWjfqJBKmEe18ui1B+zfYsthAoY4wzOTMii25NrG7C6QyZqN5 WgAvQZmB4uw1uYKQRZMAfCMh7Q/F48UVFmwNzkxfEfsLRQ/2/DbVPoxjMk4qPa7gBE0o rNt1FSa1iAoIaPv2NypB76xEqfJxsGvLafU5UVDC2HPi9YsHKrjpEIaOUeIy9tPXZheu AN6DP/96ZTA8cm6D/z2DVwnzq1pgcle1CWNtI508H2g4e/iO4ynZyrLaQZNP+N1b6gGt lVeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Yz9oPwfy; spf=pass (google.com: domain of libc-alpha-return-86396-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86396-patch=linaro.org@sourceware.org; dmarc=fail (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 d10si3579285pgo.497.2017.10.26.10.15.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 10:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86396-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=Yz9oPwfy; spf=pass (google.com: domain of libc-alpha-return-86396-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86396-patch=linaro.org@sourceware.org; dmarc=fail (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=pPjlNFGC3mxWKdtKE+bEVAwslyYnhZk ngi6CNbRnb+hh9bpPvatn4dO/BVe1PZDWKyMZIYDgwkuGUVey0TZLZremkZGRCHy rA8s/TyInrMrryqIPfwq7ErCO1xnFROEIx5Ma1puW5N1GdcclVxo7hNJmQmJNwOj 2u8D5LXMsA0I= 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=GfM3Dj5VzWQPbRhyvvy+Z4whDmo=; b=Yz9oP wfyAfllk+s/oyAY9K16KYz2jikPaqgyMilC87VgDWz52ybWoTufHPH1auLiFq2nf 39eUAMln/nvop2iLRb0ap4b6BVxtKgfygP5HQvtcomXkm1ZgAi/y+tI1P//QIXl7 ioRqavWG/TMWw1QMKAJYWxfX1UV11lbnTGfOi0= Received: (qmail 3017 invoked by alias); 26 Oct 2017 17:14:43 -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 2918 invoked by uid 89); 26 Oct 2017 17:14:42 -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=2210 X-HELO: mail-qt0-f193.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=2OpYuSCL/1Ap7HeYtygqa+COGXly3DXRWDRQ/kFcONs=; b=l42fsPDWh6izDnz39hWui3HMTHImSZbIAYoTzxLCu/k60k5lhwdCdjmjv/EiwLYO5Y EEmX2R16COQdsGLepM+K5fmXbalHyNDjb7aRdSkyF3kG1Ykon3vbW3HiakapYM9mIMAT b2yyG9E7qAM0DX5BTp/dqo+0Np7ejgT2LcVLKOQX4MLSz6KEtgjCODi7EkPT6bQTPvjf 3UOQrJswxiAxQXyvcFPSttM1NB6mGcTm4vp+rU5cAzZR7l5arwDYE1tPWLywCOlBhbUg 36OeA1GS0vbLwK5TjT4h84+xK2NkTGKDafM8yU+Z7YGaNF2UE/6nzyUTeMHyfC7WFYBe Ex8w== X-Gm-Message-State: AMCzsaUq2ZT6RNS3m7PkZ8+ldmX7920oRDxNtPfInfMvlzGRilfwdINP epIImjVqERBSCshHxWOqaYlq/pOOZU8= X-Received: by 10.200.57.86 with SMTP id t22mr38124257qtb.117.1509038075611; Thu, 26 Oct 2017 10:14:35 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 2/3] nptl: Change tst-typesizes to _Static_assert Date: Thu, 26 Oct 2017 15:14:26 -0200 Message-Id: <1509038067-18532-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509038067-18532-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509038067-18532-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Move _Static_asserts tests from nptl/tst-typesizes.c to library build time and remove redundant types sizes asserts. --- Instead of rely on runtime check to assure correct pthread types size a better strategy would use _Static_assert to trigger an error on build time (and thus allowing to check to potentially ABI breakage on cross-compiling make check). This patch moves nptl/tst-typesizes.c to libpthread build time on each specific initialization routine and also remove some runtime redundant asserts for the same type sizes. 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). Signed-off-by: Adhemerval Zanella * nptl/pthreadP.h (ASSERT_TYPE_SIZE, ASSERT_PTHREAD_INTERNAL_SIZE): New macros. * nptl/pthread_attr_init.c (__pthread_mutex_init): Add build time checks for expected input type size. * nptl/pthread_barrier_init.c (__pthread_barrier_init): Likewise. * nptl/pthread_barrierattr_init.c (pthread_barrierattr_init): Likewise. * nptl/pthread_cond_init.c (__pthread_cond_init): Likewise. * nptl/pthread_condattr_init.c (__pthread_condattr_init): Likewise. * nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise. * nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likewise. * nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Likewise. * nptl/pthread_rwlockattr_init.c (pthread_rwlockattr_init): Likewise. * nptl/sem_init.c (__new_sem_init, __old_sem_init): Likewise * nptl/pthread_attr_destroy.c (__pthread_attr_destroy): Remove superflous runtime assert check. * nptl/pthread_attr_getaffinity.c (__pthread_attr_getaffinity_new): Likewise. * nptl/pthread_attr_getdetachstate.c (__pthread_attr_getdetachstate): Likewise. * nptl/pthread_attr_getguardsize.c (pthread_attr_getguardsize): Likewise. * nptl/pthread_attr_getinheritsched.c (__pthread_attr_getinheritsched): Likewise. * nptl/pthread_attr_getschedparam.c (__pthread_attr_getschedparam): Likewise. * nptl/pthread_attr_getschedpolicy.c (__pthread_attr_getschedpolicy): Likewise. * nptl/pthread_attr_getscope.c (__pthread_attr_getscope): Likewise. * nptl/pthread_attr_getstack.c (__pthread_attr_getstack): Likewise. * nptl/pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr): Likewise. * nptl/pthread_attr_getstacksize.c (__pthread_attr_getstacksize): Likewise. * nptl/pthread_attr_setaffinity.c (__pthread_attr_setaffinity_new): Likewise. * nptl/pthread_attr_setdetachstate.c (__pthread_attr_setdetachstate): Likewise. * nptl/pthread_attr_setguardsize.c (pthread_attr_setguardsize): Likewise. * nptl/pthread_attr_setinheritsched.c (__pthread_attr_setinheritsched): Likewise. * nptl/pthread_attr_setschedparam.c (__pthread_attr_setschedparam): Likewise. * nptl/pthread_attr_setschedpolicy.c (__pthread_attr_setschedpolicy): Likewise. * nptl/pthread_attr_setscope.c (__pthread_attr_setscope): Likewise. * nptl/pthread_attr_setstack.c (__pthread_attr_setstack, __old_pthread_attr_setstack): Likewise. * nptl/pthread_attr_setstackaddr.c (__pthread_attr_setstackaddr): Likewise. * nptl/pthread_attr_setstacksize.c (__pthread_attr_setstacksize): Likewise. * nptl/pthread_getattr_default_np.c (pthread_getattr_default_np): Likewise. * nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise. * nptl/pthread_setattr_default_np.c (pthread_setattr_default_np): Likewise. * nptl/tst-typesizes.c: Remove file. --- ChangeLog | 60 +++++++++++++++++++++++ nptl/pthreadP.h | 8 ++++ nptl/pthread_attr_destroy.c | 2 - nptl/pthread_attr_getaffinity.c | 2 - nptl/pthread_attr_getdetachstate.c | 2 - nptl/pthread_attr_getguardsize.c | 2 - nptl/pthread_attr_getinheritsched.c | 2 - nptl/pthread_attr_getschedparam.c | 2 - nptl/pthread_attr_getschedpolicy.c | 2 - nptl/pthread_attr_getscope.c | 2 - nptl/pthread_attr_getstack.c | 2 - nptl/pthread_attr_getstackaddr.c | 2 - nptl/pthread_attr_getstacksize.c | 2 - nptl/pthread_attr_init.c | 5 +- nptl/pthread_attr_setaffinity.c | 2 - nptl/pthread_attr_setdetachstate.c | 2 - nptl/pthread_attr_setguardsize.c | 2 - nptl/pthread_attr_setinheritsched.c | 2 - nptl/pthread_attr_setschedparam.c | 2 - nptl/pthread_attr_setschedpolicy.c | 2 - nptl/pthread_attr_setscope.c | 2 - nptl/pthread_attr_setstack.c | 3 -- nptl/pthread_attr_setstackaddr.c | 2 - nptl/pthread_attr_setstacksize.c | 3 -- nptl/pthread_barrier_init.c | 4 ++ nptl/pthread_barrierattr_init.c | 4 ++ nptl/pthread_cond_init.c | 2 + nptl/pthread_condattr_init.c | 4 ++ nptl/pthread_getattr_default_np.c | 2 - nptl/pthread_mutex_init.c | 2 + nptl/pthread_mutex_lock.c | 2 - nptl/pthread_mutexattr_init.c | 4 ++ nptl/pthread_rwlock_init.c | 2 + nptl/pthread_rwlockattr_init.c | 4 ++ nptl/pthread_setattr_default_np.c | 2 - nptl/sem_init.c | 4 ++ nptl/tst-typesizes.c | 95 ------------------------------------- 37 files changed, 101 insertions(+), 147 deletions(-) delete mode 100644 nptl/tst-typesizes.c -- 2.7.4 diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 444bbd9..bbc55fb 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -639,6 +639,14 @@ check_stacksize_attr (size_t st) return EINVAL; } +#define ASSERT_TYPE_SIZE(__type, __size) \ + _Static_assert (sizeof (__type) == __size, \ + "sizeof (" #__type ") != " #__size) + +#define ASSERT_PTHREAD_INTERNAL_SIZE(__type, __internal) \ + _Static_assert (sizeof ((__type *) 0)->__size >= sizeof (__internal), \ + "sizeof (" #__type ".__size) > sizeof (" #__internal ")") + #define ASSERT_PTHREAD_STRING(x) __STRING (x) #define ASSERT_PTHREAD_INTERNAL_OFFSET(__type, __member, __offset) \ _Static_assert (offsetof (__type, __member) == __offset, \ diff --git a/nptl/pthread_attr_destroy.c b/nptl/pthread_attr_destroy.c index a9ce51e..cdcdb4a 100644 --- a/nptl/pthread_attr_destroy.c +++ b/nptl/pthread_attr_destroy.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include @@ -28,7 +27,6 @@ __pthread_attr_destroy (pthread_attr_t *attr) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) diff --git a/nptl/pthread_attr_getaffinity.c b/nptl/pthread_attr_getaffinity.c index b9d041a..57ab56d 100644 --- a/nptl/pthread_attr_getaffinity.c +++ b/nptl/pthread_attr_getaffinity.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include @@ -32,7 +31,6 @@ __pthread_attr_getaffinity_new (const pthread_attr_t *attr, size_t cpusetsize, { const struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (const struct pthread_attr *) attr; if (iattr->cpuset != NULL) diff --git a/nptl/pthread_attr_getdetachstate.c b/nptl/pthread_attr_getdetachstate.c index 803a553..0246ca8 100644 --- a/nptl/pthread_attr_getdetachstate.c +++ b/nptl/pthread_attr_getdetachstate.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -25,7 +24,6 @@ __pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; *detachstate = (iattr->flags & ATTR_FLAG_DETACHSTATE diff --git a/nptl/pthread_attr_getguardsize.c b/nptl/pthread_attr_getguardsize.c index b71be6c..d6e01c7 100644 --- a/nptl/pthread_attr_getguardsize.c +++ b/nptl/pthread_attr_getguardsize.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -25,7 +24,6 @@ pthread_attr_getguardsize (const pthread_attr_t *attr, size_t *guardsize) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; *guardsize = iattr->guardsize; diff --git a/nptl/pthread_attr_getinheritsched.c b/nptl/pthread_attr_getinheritsched.c index 2dec230..1dc00ce 100644 --- a/nptl/pthread_attr_getinheritsched.c +++ b/nptl/pthread_attr_getinheritsched.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -25,7 +24,6 @@ __pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inherit) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Store the current values. */ diff --git a/nptl/pthread_attr_getschedparam.c b/nptl/pthread_attr_getschedparam.c index 34f9408..86d0709 100644 --- a/nptl/pthread_attr_getschedparam.c +++ b/nptl/pthread_attr_getschedparam.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include "pthreadP.h" @@ -27,7 +26,6 @@ __pthread_attr_getschedparam (const pthread_attr_t *attr, { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Copy the current values. */ diff --git a/nptl/pthread_attr_getschedpolicy.c b/nptl/pthread_attr_getschedpolicy.c index 65ed417..f9f69be 100644 --- a/nptl/pthread_attr_getschedpolicy.c +++ b/nptl/pthread_attr_getschedpolicy.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -25,7 +24,6 @@ __pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Store the current values. */ diff --git a/nptl/pthread_attr_getscope.c b/nptl/pthread_attr_getscope.c index 7b36d6a..ba5b5e3 100644 --- a/nptl/pthread_attr_getscope.c +++ b/nptl/pthread_attr_getscope.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -25,7 +24,6 @@ __pthread_attr_getscope (const pthread_attr_t *attr, int *scope) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Store the current values. */ diff --git a/nptl/pthread_attr_getstack.c b/nptl/pthread_attr_getstack.c index 79c78c6..9a80bfe 100644 --- a/nptl/pthread_attr_getstack.c +++ b/nptl/pthread_attr_getstack.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -26,7 +25,6 @@ __pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr, { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Store the result. */ diff --git a/nptl/pthread_attr_getstackaddr.c b/nptl/pthread_attr_getstackaddr.c index 69f0a7d..ef1a633 100644 --- a/nptl/pthread_attr_getstackaddr.c +++ b/nptl/pthread_attr_getstackaddr.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include "pthreadP.h" @@ -26,7 +25,6 @@ __pthread_attr_getstackaddr (const pthread_attr_t *attr, void **stackaddr) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Some code assumes this function to work even if no stack address diff --git a/nptl/pthread_attr_getstacksize.c b/nptl/pthread_attr_getstacksize.c index 9f24d4d..d9893cd 100644 --- a/nptl/pthread_attr_getstacksize.c +++ b/nptl/pthread_attr_getstacksize.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -25,7 +24,6 @@ __pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *stacksize) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; size_t size = iattr->stacksize; diff --git a/nptl/pthread_attr_init.c b/nptl/pthread_attr_init.c index 77998ea..eceaf85 100644 --- a/nptl/pthread_attr_init.c +++ b/nptl/pthread_attr_init.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include @@ -34,12 +33,14 @@ __pthread_attr_init_2_1 (pthread_attr_t *attr) { struct pthread_attr *iattr; + ASSERT_TYPE_SIZE (pthread_attr_t, __SIZEOF_PTHREAD_ATTR_T); + ASSERT_PTHREAD_INTERNAL_SIZE (pthread_attr_t, struct pthread_attr); + /* Many elements are initialized to zero so let us do it all at once. This also takes care of clearing the bytes which are not internally used. */ memset (attr, '\0', __SIZEOF_PTHREAD_ATTR_T); - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Default guard size specified by the standard. */ diff --git a/nptl/pthread_attr_setaffinity.c b/nptl/pthread_attr_setaffinity.c index 497512e..f684496 100644 --- a/nptl/pthread_attr_setaffinity.c +++ b/nptl/pthread_attr_setaffinity.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include @@ -31,7 +30,6 @@ __pthread_attr_setaffinity_new (pthread_attr_t *attr, size_t cpusetsize, { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; if (cpuset == NULL || cpusetsize == 0) diff --git a/nptl/pthread_attr_setdetachstate.c b/nptl/pthread_attr_setdetachstate.c index c6fb1bf..2659ce7 100644 --- a/nptl/pthread_attr_setdetachstate.c +++ b/nptl/pthread_attr_setdetachstate.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include "pthreadP.h" @@ -26,7 +25,6 @@ __pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid values. */ diff --git a/nptl/pthread_attr_setguardsize.c b/nptl/pthread_attr_setguardsize.c index 3927793..108b4a5 100644 --- a/nptl/pthread_attr_setguardsize.c +++ b/nptl/pthread_attr_setguardsize.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include "pthreadP.h" @@ -25,7 +24,6 @@ pthread_attr_setguardsize (pthread_attr_t *attr, size_t guardsize) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Note that we don't round the value here. The standard requires diff --git a/nptl/pthread_attr_setinheritsched.c b/nptl/pthread_attr_setinheritsched.c index 69a6335..97aeb8d 100644 --- a/nptl/pthread_attr_setinheritsched.c +++ b/nptl/pthread_attr_setinheritsched.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include "pthreadP.h" @@ -26,7 +25,6 @@ __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid values. */ diff --git a/nptl/pthread_attr_setschedparam.c b/nptl/pthread_attr_setschedparam.c index e38d1d8..3eef9ad 100644 --- a/nptl/pthread_attr_setschedparam.c +++ b/nptl/pthread_attr_setschedparam.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include "pthreadP.h" @@ -26,7 +25,6 @@ int __pthread_attr_setschedparam (pthread_attr_t *attr, const struct sched_param *param) { - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); struct pthread_attr *iattr = (struct pthread_attr *) attr; int ret = check_sched_priority_attr (param->sched_priority, diff --git a/nptl/pthread_attr_setschedpolicy.c b/nptl/pthread_attr_setschedpolicy.c index 868696d..4f7c9b0 100644 --- a/nptl/pthread_attr_setschedpolicy.c +++ b/nptl/pthread_attr_setschedpolicy.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include "pthreadP.h" @@ -26,7 +25,6 @@ __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid values. */ diff --git a/nptl/pthread_attr_setscope.c b/nptl/pthread_attr_setscope.c index e0fd1dd..bca0ffb 100644 --- a/nptl/pthread_attr_setscope.c +++ b/nptl/pthread_attr_setscope.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include "pthreadP.h" @@ -26,7 +25,6 @@ __pthread_attr_setscope (pthread_attr_t *attr, int scope) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid values. */ diff --git a/nptl/pthread_attr_setstack.c b/nptl/pthread_attr_setstack.c index e4f8b29..cb558f5 100644 --- a/nptl/pthread_attr_setstack.c +++ b/nptl/pthread_attr_setstack.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include "pthreadP.h" @@ -33,7 +32,6 @@ __pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid sizes. */ @@ -71,7 +69,6 @@ __old_pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid sizes. */ diff --git a/nptl/pthread_attr_setstackaddr.c b/nptl/pthread_attr_setstackaddr.c index ac16f94..78370d8 100644 --- a/nptl/pthread_attr_setstackaddr.c +++ b/nptl/pthread_attr_setstackaddr.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include "pthreadP.h" @@ -30,7 +29,6 @@ __pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr) EXTRA_PARAM_CHECKS; #endif - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; iattr->stackaddr = stackaddr; diff --git a/nptl/pthread_attr_setstacksize.c b/nptl/pthread_attr_setstacksize.c index 4c0abac..ed8999f 100644 --- a/nptl/pthread_attr_setstacksize.c +++ b/nptl/pthread_attr_setstacksize.c @@ -16,7 +16,6 @@ License along with the GNU C Library; if not, see . */ -#include #include #include #include "pthreadP.h" @@ -31,7 +30,6 @@ __pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid sizes. */ @@ -58,7 +56,6 @@ __old_pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) { struct pthread_attr *iattr; - assert (sizeof (*attr) >= sizeof (struct pthread_attr)); iattr = (struct pthread_attr *) attr; /* Catch invalid sizes. */ diff --git a/nptl/pthread_barrier_init.c b/nptl/pthread_barrier_init.c index 9c851fb..bdbd10c 100644 --- a/nptl/pthread_barrier_init.c +++ b/nptl/pthread_barrier_init.c @@ -32,6 +32,10 @@ int __pthread_barrier_init (pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) { + ASSERT_TYPE_SIZE (pthread_barrier_t, __SIZEOF_PTHREAD_BARRIER_T); + ASSERT_PTHREAD_INTERNAL_SIZE (pthread_barrier_t, + struct pthread_barrier); + struct pthread_barrier *ibarrier; /* XXX EINVAL is not specified by POSIX as a possible error code for COUNT diff --git a/nptl/pthread_barrierattr_init.c b/nptl/pthread_barrierattr_init.c index 796652e..81a6f5c 100644 --- a/nptl/pthread_barrierattr_init.c +++ b/nptl/pthread_barrierattr_init.c @@ -22,6 +22,10 @@ int pthread_barrierattr_init (pthread_barrierattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_barrierattr_t, __SIZEOF_PTHREAD_BARRIERATTR_T); + ASSERT_PTHREAD_INTERNAL_SIZE (pthread_barrierattr_t, + struct pthread_barrierattr); + ((struct pthread_barrierattr *) attr)->pshared = PTHREAD_PROCESS_PRIVATE; return 0; diff --git a/nptl/pthread_cond_init.c b/nptl/pthread_cond_init.c index 0387f00..d23cdb1 100644 --- a/nptl/pthread_cond_init.c +++ b/nptl/pthread_cond_init.c @@ -26,6 +26,8 @@ int __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *cond_attr) { + ASSERT_TYPE_SIZE (pthread_cond_t, __SIZEOF_PTHREAD_COND_T); + struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr; memset (cond, 0, sizeof (pthread_cond_t)); diff --git a/nptl/pthread_condattr_init.c b/nptl/pthread_condattr_init.c index 47bcc8b..0896abe 100644 --- a/nptl/pthread_condattr_init.c +++ b/nptl/pthread_condattr_init.c @@ -23,6 +23,10 @@ int __pthread_condattr_init (pthread_condattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_condattr_t, __SIZEOF_PTHREAD_CONDATTR_T); + ASSERT_PTHREAD_INTERNAL_SIZE (pthread_condattr_t, + struct pthread_condattr); + struct pthread_condattr *iattr = (struct pthread_condattr *) attr; /* Default is not pshared and CLOCK_REALTIME. */ iattr-> value = CLOCK_REALTIME << 1; diff --git a/nptl/pthread_getattr_default_np.c b/nptl/pthread_getattr_default_np.c index 771c06b..3357b73 100644 --- a/nptl/pthread_getattr_default_np.c +++ b/nptl/pthread_getattr_default_np.c @@ -19,14 +19,12 @@ #include #include #include -#include int pthread_getattr_default_np (pthread_attr_t *out) { struct pthread_attr *real_out; - assert (sizeof (*out) >= sizeof (struct pthread_attr)); real_out = (struct pthread_attr *) out; lll_lock (__default_pthread_attr_lock, LLL_PRIVATE); diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index e1f911b..8ab7b1d 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -58,6 +58,8 @@ __pthread_mutex_init (pthread_mutex_t *mutex, { const struct pthread_mutexattr *imutexattr; + ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T); + assert (sizeof (pthread_mutex_t) <= __SIZEOF_PTHREAD_MUTEX_T); ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__nusers, __PTHREAD_MUTEX_NUSERS_OFFSET); diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 7f8254b..1acbe43 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -62,8 +62,6 @@ static int __pthread_mutex_lock_full (pthread_mutex_t *mutex) int __pthread_mutex_lock (pthread_mutex_t *mutex) { - assert (sizeof (mutex->__size) >= sizeof (mutex->__data)); - unsigned int type = PTHREAD_MUTEX_TYPE_ELISION (mutex); LIBC_PROBE (mutex_entry, 1, mutex); diff --git a/nptl/pthread_mutexattr_init.c b/nptl/pthread_mutexattr_init.c index dcad522..63ade02 100644 --- a/nptl/pthread_mutexattr_init.c +++ b/nptl/pthread_mutexattr_init.c @@ -23,6 +23,10 @@ int __pthread_mutexattr_init (pthread_mutexattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T); + ASSERT_PTHREAD_INTERNAL_SIZE (pthread_mutexattr_t, + struct pthread_mutexattr); + if (sizeof (struct pthread_mutexattr) != sizeof (pthread_mutexattr_t)) memset (attr, '\0', sizeof (*attr)); diff --git a/nptl/pthread_rwlock_init.c b/nptl/pthread_rwlock_init.c index 764ba11..c64e49f 100644 --- a/nptl/pthread_rwlock_init.c +++ b/nptl/pthread_rwlock_init.c @@ -32,6 +32,8 @@ int __pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T); + const struct pthread_rwlockattr *iattr; iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_rwlockattr; diff --git a/nptl/pthread_rwlockattr_init.c b/nptl/pthread_rwlockattr_init.c index 8d90647..32a33cd 100644 --- a/nptl/pthread_rwlockattr_init.c +++ b/nptl/pthread_rwlockattr_init.c @@ -22,6 +22,10 @@ int pthread_rwlockattr_init (pthread_rwlockattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_rwlockattr_t, __SIZEOF_PTHREAD_RWLOCKATTR_T); + ASSERT_PTHREAD_INTERNAL_SIZE (pthread_rwlockattr_t, + struct pthread_rwlockattr); + struct pthread_rwlockattr *iattr; iattr = (struct pthread_rwlockattr *) attr; diff --git a/nptl/pthread_setattr_default_np.c b/nptl/pthread_setattr_default_np.c index dd1b6fc..2fb787d 100644 --- a/nptl/pthread_setattr_default_np.c +++ b/nptl/pthread_setattr_default_np.c @@ -19,7 +19,6 @@ #include #include #include -#include #include @@ -30,7 +29,6 @@ pthread_setattr_default_np (const pthread_attr_t *in) struct pthread_attr attrs; int ret; - assert (sizeof (*in) >= sizeof (struct pthread_attr)); real_in = (struct pthread_attr *) in; /* Catch invalid values. */ diff --git a/nptl/sem_init.c b/nptl/sem_init.c index b9b839c..87cadeb 100644 --- a/nptl/sem_init.c +++ b/nptl/sem_init.c @@ -27,6 +27,8 @@ int __new_sem_init (sem_t *sem, int pshared, unsigned int value) { + ASSERT_PTHREAD_INTERNAL_SIZE (sem_t, struct new_sem); + /* Parameter sanity check. */ if (__glibc_unlikely (value > SEM_VALUE_MAX)) { @@ -68,6 +70,8 @@ int attribute_compat_text_section __old_sem_init (sem_t *sem, int pshared, unsigned int value) { + ASSERT_PTHREAD_INTERNAL_SIZE (sem_t, struct new_sem); + /* Parameter sanity check. */ if (__glibc_unlikely (value > SEM_VALUE_MAX)) { diff --git a/nptl/tst-typesizes.c b/nptl/tst-typesizes.c deleted file mode 100644 index 78ed773..0000000 --- a/nptl/tst-typesizes.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 2005-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2005. - - 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 - -static const struct -{ - const char *name; - size_t expected; - size_t is; -} types[] = - { -#define T(t, c) \ - { #t, c, sizeof (t) } - T (pthread_attr_t, __SIZEOF_PTHREAD_ATTR_T), - T (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T), - T (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T), - T (pthread_cond_t, __SIZEOF_PTHREAD_COND_T), - T (pthread_condattr_t, __SIZEOF_PTHREAD_CONDATTR_T), - T (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T), - T (pthread_rwlockattr_t, __SIZEOF_PTHREAD_RWLOCKATTR_T), - T (pthread_barrier_t, __SIZEOF_PTHREAD_BARRIER_T), - T (pthread_barrierattr_t, __SIZEOF_PTHREAD_BARRIERATTR_T) - }; - -static int -do_test (void) -{ - int result = 0; - -#define TEST_TYPE(name) \ - printf ("%s: ", #name); \ - if (sizeof (name) != sizeof (((name *) 0)->__size)) \ - { \ - printf ("expected %zu, is %zu\n", \ - sizeof (((name *) 0)->__size), sizeof (name)); \ - result = 1; \ - } \ - else \ - puts ("OK") - - TEST_TYPE (pthread_mutex_t); - TEST_TYPE (pthread_cond_t); - TEST_TYPE (pthread_rwlock_t); - -#define TEST_TYPE2(name, internal) \ - printf ("%s: ", #name); \ - if (sizeof (((name *) 0)->__size) < sizeof (internal)) \ - { \ - printf ("expected %zu, is %zu\n", \ - sizeof (((name *) 0)->__size), sizeof (internal)); \ - result = 1; \ - } \ - else \ - puts ("OK") - - TEST_TYPE2 (pthread_attr_t, struct pthread_attr); - TEST_TYPE2 (pthread_mutexattr_t, struct pthread_mutexattr); - TEST_TYPE2 (pthread_condattr_t, struct pthread_condattr); - TEST_TYPE2 (pthread_rwlockattr_t, struct pthread_rwlockattr); - TEST_TYPE2 (pthread_barrier_t, struct pthread_barrier); - TEST_TYPE2 (pthread_barrierattr_t, struct pthread_barrierattr); - TEST_TYPE2 (sem_t, struct new_sem); - TEST_TYPE2 (sem_t, struct old_sem); - - for (size_t i = 0; i < sizeof (types) / sizeof (types[0]); ++i) - if (types[i].expected != types[i].is) - { - printf ("%s: expected %zu, is %zu\n", - types[i].name, types[i].expected, types[i].is); - result = 1; - } - - return result; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" From patchwork Thu Oct 26 17:14:27 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: 117251 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1015398qgn; Thu, 26 Oct 2017 10:15:17 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qn+R+KxscWPw/KvN9aFh7qZx6WmgZcO/4R+BMd7jE3zjqoDQ1A/1+w24JXhEi6jOSpgOWB X-Received: by 10.99.109.79 with SMTP id i76mr5702519pgc.134.1509038117782; Thu, 26 Oct 2017 10:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509038117; cv=none; d=google.com; s=arc-20160816; b=TdJA478LnAbYPEYAzlIwNUoGCj49tnzNzFuIX7fWcmzo2q5B1QyOnITKF8P/IoQ+DX HZ5Is8odL1SSUB8BUIXtrm395QiZo8iC5RCOvOduT3iqrvA/vbJcChxx/54AqHy/Rv+h FQ1BZzcvXPWlbUP+KXjOv7kEHsYaldwu4R6rcXSzPK79PouoiHdxRMYcHrjPeg246CjR JUdkamwoW1ThJSc2lTlwJ1Nn7EOz99K8t1IkRui6m2K3nrQJOA6vDp8ofO1Rn6T44Aej W3ES8JYnOYh8mC25qrBhvtE7YUOV6j39/nP9KZhXIATNg14ageTnq1K2yXlTLUEKdLuc UG0w== 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:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=tj0ZSEhRMm/GNm3r5fQN/cnvF6Wm0Lve3ZyRjXc78dM=; b=fOKchKJbmZ5QZpHoNc7q+AG1p5ilYrsRGVy8IzF6E7z2b/apb3nx7Vwv3R29bm6awd omOXvLAuydNT4qXT9Yv/QSxP+2zNfB+aX/ViAuUflMt/Agrxj5ArkKEelaTl9uqWgC1d XoeN3ZdeU8QYyuASz117q/ugRBzEQt0mTbtsLnmaL6YdS0/l6eL7lliwR7eUCNyy/vsN ynr1tOIieDrPq6OYxZBCuADOXZXmNeTmexkJVoYHGMU9IP4t2XLFNnvGIuKQ2S5ABxG4 MNjNNanndaqlAAGqcBHjPbQ84auuxqkyF2Jqd9L3JqROtlXP+nlJ3ewgcKW6wyw+3YqN 2cvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Oa7ctDM1; spf=pass (google.com: domain of libc-alpha-return-86397-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86397-patch=linaro.org@sourceware.org; dmarc=fail (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 q190si3603708pga.462.2017.10.26.10.15.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Oct 2017 10:15:17 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86397-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=Oa7ctDM1; spf=pass (google.com: domain of libc-alpha-return-86397-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86397-patch=linaro.org@sourceware.org; dmarc=fail (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=dC+HEQZhlXGTnzruP61U3d8E8OeGwFt q/8GDQTaCi0TIUqrH//e5+Z5koHY8lejHKUlvLoZmLCtTjyamqJo1Dmk17yjGjO6 LW4WBqVSaCJFmxm34WKPbZMP8gaV3wlDpdXV8WdiV+rj0vshXE3lLLvFf3UWTvSF UH1j4h0ZS7GU= 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=4QJyRa8Laq/dl7opEPnUJIxWqbo=; b=Oa7ct DM1Ph63lusxsu+CK+731Y484/QnAuWUDhcBIBJeUtd08Tayj3Waz/xFEGBcA8idP nT0BUIjky0lMRnK33lx77SsaB1e51LtX4LCpZ/eFjtEdQ1XRx/bOJk//30wnjgtV ryQXqfYE/ozGQlqskFDdoX/aREzajfLzS4ymBU= Received: (qmail 3114 invoked by alias); 26 Oct 2017 17:14:43 -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 2996 invoked by uid 89); 26 Oct 2017 17:14:43 -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= X-HELO: mail-qk0-f196.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=tj0ZSEhRMm/GNm3r5fQN/cnvF6Wm0Lve3ZyRjXc78dM=; b=LmAHyCk9Tv/Ajlw/Guj+M0vQ2qxRD+9PncxkoPjmnOfNbUgAE53cw9sLbiu2JXUscL uMM+kI9dr5iWv8icq7Uch9W3dEQmQv69hrhZOgcBz7ecID/lvTtlafJ4qasOvMBKZLBW rG4lCwigKNXcndFNyHqqlNnSnIQrQ70+0c5XDeGYBWskraFz+I+aHInD15aMofqlLqdu ahNkk2u59Cxcq16kSsgD9+LkHUQVbLa27Wzp7fxj6g5SMKub+lkH332luttatLQJqPau DwO5BBeh5tjzlNVG88fZv6coY55gdvuIcGZ5Lks5Rg+YZn7zCsY1vc3WdCWhUMGaGqpf kR+g== X-Gm-Message-State: AMCzsaW3Njxi+JVrtK0oOg7lZTY/aLsONXaKKdXB3sd24rPBgeioX3tV JC45fO9YRQt2RTxS/cRR7eUHlbVyBL8= X-Received: by 10.55.3.130 with SMTP id 124mr9661632qkd.42.1509038077200; Thu, 26 Oct 2017 10:14:37 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 3/3] nptl: Define __PTHREAD_MUTEX_{NUSERS_AFTER_KIND, USE_UNION} Date: Thu, 26 Oct 2017 15:14:27 -0200 Message-Id: <1509038067-18532-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509038067-18532-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509038067-18532-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Fixed __nusers placement for __PTHREAD_MUTEX_NUSERS_AFTER_KIND. - Fixed typos. --- This patch adds two new internal defines to set the internal pthread_mutex_t layout required by the supported ABIS: 1. __PTHREAD_MUTEX_NUSERS_AFTER_KIND which control whether to define __nusers fields before or after __kind. The preferred value for is 0 for new ports and it sets __nusers before __kind. 2. __PTHREAD_MUTEX_USE_UNION which control whether internal __spins and __list members will be place inside an union for linuxthreads compatibility. The preferred value is 0 for ports and it sets to not use an union to define both fields. It fixes the wrong offsets value for __kind value on x86_64-linux-gnu-x32. Checked with a make check run-built-tests=no on all afected ABIs. Signed-off-by: Adhemerval Zanella [BZ #22298] * nptl/allocatestack.c (allocate_stack): Check if __PTHREAD_MUTEX_HAVE_PREV is non-zero, instead if __PTHREAD_MUTEX_HAVE_PREV is defined. * nptl/descr.h (pthread): Likewise. * nptl/nptl-init.c (__pthread_initialize_minimal_internal): Likewise. * nptl/pthread_create.c (START_THREAD_DEFN): Likewise. * sysdeps/nptl/fork.c (__libc_fork): Likewise. * sysdeps/nptl/pthread.h (PTHREAD_MUTEX_INITIALIZER): Likewise. * sysdeps/nptl/bits/thread-shared-types.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. (__pthread_internal_list): Check __PTHREAD_MUTEX_USE_UNION instead of __WORDSIZE for internal layout. (__pthread_mutex_s): Check __PTHREAD_MUTEX_NUSERS_AFTER_KIND instead of __WORDSIZE for internal __nusers layout and __PTHREAD_MUTEX_USE_UNION instead of __WORDSIZE whether to use an union for __spins and __list fields. (__PTHREAD_MUTEX_HAVE_PREV): Define also for __PTHREAD_MUTEX_USE_UNION case. * sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/alpha/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/arm/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/hppa/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/ia64/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/m68k/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/mips/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/nios2/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/s390/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/sh/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/sparc/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/tile/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. * sysdeps/x86/nptl/bits/pthreadtypes-arch.h (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New defines. --- ChangeLog | 67 ++++++++++++++++++++++++ nptl/allocatestack.c | 2 +- nptl/descr.h | 2 +- nptl/nptl-init.c | 2 +- nptl/pthread_create.c | 4 +- sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/alpha/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/arm/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/hppa/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/ia64/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/m68k/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/mips/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/nios2/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/nptl/bits/thread-shared-types.h | 32 +++++++++-- sysdeps/nptl/fork.c | 2 +- sysdeps/nptl/pthread.h | 2 +- sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/s390/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/sh/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/sparc/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/tile/nptl/bits/pthreadtypes-arch.h | 2 + sysdeps/x86/nptl/bits/pthreadtypes-arch.h | 7 +++ 23 files changed, 136 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/ChangeLog b/ChangeLog index 09e25be..203f014 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,72 @@ 2017-10-25 Adhemerval Zanella + [BZ #22298] + * nptl/allocatestack.c (allocate_stack): Check if + __PTHREAD_MUTEX_HAVE_PREV is non-zero, instead if + __PTHREAD_MUTEX_HAVE_PREV is defined. + * nptl/descr.h (pthread): Likewise. + * nptl/nptl-init.c (__pthread_initialize_minimal_internal): + Likewise. + * nptl/pthread_create.c (START_THREAD_DEFN): Likewise. + * sysdeps/nptl/fork.c (__libc_fork): Likewise. + * sysdeps/nptl/pthread.h (PTHREAD_MUTEX_INITIALIZER): Likewise. + * sysdeps/nptl/bits/thread-shared-types.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + (__pthread_internal_list): Check __PTHREAD_MUTEX_USE_UNION instead + of __WORDSIZE for internal layout. + (__pthread_mutex_s): Check __PTHREAD_MUTEX_NUSERS_AFTER_KIND instead + of __WORDSIZE for internal __nusers layout and __PTHREAD_MUTEX_USE_UNION + instead of __WORDSIZE whether to use an union for __spins and __list + fields. + (__PTHREAD_MUTEX_HAVE_PREV): Define also for __PTHREAD_MUTEX_USE_UNION + case. + * sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/alpha/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/arm/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/hppa/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/ia64/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/m68k/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/mips/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/nios2/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/s390/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/sh/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/sparc/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/tile/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * sysdeps/x86/nptl/bits/pthreadtypes-arch.h + (__PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): New + defines. + * nptl/pthreadP.h (ASSERT_TYPE_SIZE, ASSERT_PTHREAD_INTERNAL_SIZE): New macros. * nptl/pthread_attr_init.c (__pthread_mutex_init): Add build time diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index ad9add8..1cc7893 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -753,7 +753,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, - offsetof (pthread_mutex_t, __data.__list.__next)); pd->robust_head.list_op_pending = NULL; -#ifdef __PTHREAD_MUTEX_HAVE_PREV +#if __PTHREAD_MUTEX_HAVE_PREV pd->robust_prev = &pd->robust_head; #endif pd->robust_head.list = &pd->robust_head; diff --git a/nptl/descr.h b/nptl/descr.h index c5ad0c8..c83b17b 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -169,7 +169,7 @@ struct pthread pid_t pid_ununsed; /* List of robust mutexes the thread is holding. */ -#ifdef __PTHREAD_MUTEX_HAVE_PREV +#if __PTHREAD_MUTEX_HAVE_PREV void *robust_prev; struct robust_list_head robust_head; diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 2921607..869e926 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -297,7 +297,7 @@ __pthread_initialize_minimal_internal (void) /* Initialize the robust mutex data. */ { -#ifdef __PTHREAD_MUTEX_HAVE_PREV +#if __PTHREAD_MUTEX_HAVE_PREV pd->robust_prev = &pd->robust_head; #endif pd->robust_head.list = &pd->robust_head; diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 992331e..51ae60d 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -518,7 +518,7 @@ START_THREAD_DEFN #ifndef __ASSUME_SET_ROBUST_LIST /* If this thread has any robust mutexes locked, handle them now. */ -# ifdef __PTHREAD_MUTEX_HAVE_PREV +# if __PTHREAD_MUTEX_HAVE_PREV void *robust = pd->robust_head.list; # else __pthread_slist_t *robust = pd->robust_list.__next; @@ -536,7 +536,7 @@ START_THREAD_DEFN __list.__next)); robust = *((void **) robust); -# ifdef __PTHREAD_MUTEX_HAVE_PREV +# if __PTHREAD_MUTEX_HAVE_PREV this->__list.__prev = NULL; # endif this->__list.__next = NULL; diff --git a/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h b/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h index d13a75d..9ab23d0 100644 --- a/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h @@ -45,6 +45,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0 +#define __PTHREAD_MUTEX_USE_UNION 0 #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h b/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h index b6f6cb1..429df10 100644 --- a/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h @@ -33,6 +33,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0 +#define __PTHREAD_MUTEX_USE_UNION 0 #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/arm/nptl/bits/pthreadtypes-arch.h b/sysdeps/arm/nptl/bits/pthreadtypes-arch.h index 3f9eca4..3911c81 100644 --- a/sysdeps/arm/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/arm/nptl/bits/pthreadtypes-arch.h @@ -34,6 +34,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1 +#define __PTHREAD_MUTEX_USE_UNION 1 #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h b/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h index c158562..865a14e 100644 --- a/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h @@ -48,6 +48,8 @@ pthread_mutex_t is larger than Linuxthreads. */ #define __PTHREAD_COMPAT_PADDING_END int __reserved[2]; #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1 +#define __PTHREAD_MUTEX_USE_UNION 1 #define __LOCK_ALIGNMENT __attribute__ ((__aligned__(16))) #define __ONCE_ALIGNMENT diff --git a/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h b/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h index 631cb33..2a3bc75 100644 --- a/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h @@ -33,6 +33,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0 +#define __PTHREAD_MUTEX_USE_UNION 0 #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h b/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h index 845b9e6..966cc75 100644 --- a/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h @@ -35,6 +35,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1 +#define __PTHREAD_MUTEX_USE_UNION 1 #define __LOCK_ALIGNMENT __attribute__ ((__aligned__ (4))) #define __ONCE_ALIGNMENT __attribute__ ((__aligned__ (4))) diff --git a/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h b/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h index d687e2c..e44f2dc 100644 --- a/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h @@ -35,6 +35,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1 +#define __PTHREAD_MUTEX_USE_UNION 1 #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/mips/nptl/bits/pthreadtypes-arch.h b/sysdeps/mips/nptl/bits/pthreadtypes-arch.h index 6aa1bda..f03389a 100644 --- a/sysdeps/mips/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/mips/nptl/bits/pthreadtypes-arch.h @@ -42,6 +42,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (_MIPS_SIM != _ABI64) +#define __PTHREAD_MUTEX_USE_UNION (_MIPS_SIM != _ABI64) #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h b/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h index e2732f9..83f8684 100644 --- a/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h @@ -35,6 +35,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1 +#define __PTHREAD_MUTEX_USE_UNION 1 #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/nptl/bits/thread-shared-types.h b/sysdeps/nptl/bits/thread-shared-types.h index 68b82b6..da4358a 100644 --- a/sysdeps/nptl/bits/thread-shared-types.h +++ b/sysdeps/nptl/bits/thread-shared-types.h @@ -42,6 +42,25 @@ the internal structure. __PTHREAD_MUTEX_LOCK_ELISION - 1 if the architecture supports lock elision or 0 otherwise. + __PTHREAD_MUTEX_NUSERS_AFTER_KIND - control where to put __nusers. The + preferred value for new architectures + is 0. + __PTHREAD_MUTEX_USE_UNION - control whether internal __spins and + __list will be place inside a union for + linuxthreads compatibility. + The preferred value for new architectures + is 0. + + For a new port the preferred values for the required defines are: + + #define __PTHREAD_COMPAT_PADDING_MID + #define __PTHREAD_COMPAT_PADDING_END + #define __PTHREAD_MUTEX_LOCK_ELISION 0 + #define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0 + #define __PTHREAD_MUTEX_USE_UNION 0 + + __PTHREAD_MUTEX_LOCK_ELISION can be set to 1 if the hardware plans to + eventually support lock elision using transactional memory. The additional macro defines any constraint for the lock alignment inside the thread structures: @@ -59,7 +78,7 @@ /* Common definition of pthread_mutex_t. */ -#if __WORDSIZE == 64 +#if !__PTHREAD_MUTEX_USE_UNION typedef struct __pthread_internal_list { struct __pthread_internal_list *__prev; @@ -74,7 +93,7 @@ typedef struct __pthread_internal_slist /* Lock elision support. */ #if __PTHREAD_MUTEX_LOCK_ELISION -# if __WORDSIZE == 64 +# if !__PTHREAD_MUTEX_USE_UNION # define __PTHREAD_SPINS_DATA \ short __spins; \ short __elision @@ -101,24 +120,27 @@ struct __pthread_mutex_s int __lock __LOCK_ALIGNMENT; unsigned int __count; int __owner; -#if __WORDSIZE == 64 +#if !__PTHREAD_MUTEX_NUSERS_AFTER_KIND unsigned int __nusers; #endif /* KIND must stay at this position in the structure to maintain binary compatibility with static initializers. */ int __kind; __PTHREAD_COMPAT_PADDING_MID -#if __WORDSIZE == 64 +#if __PTHREAD_MUTEX_NUSERS_AFTER_KIND + unsigned int __nusers; +#endif +#if !__PTHREAD_MUTEX_USE_UNION __PTHREAD_SPINS_DATA; __pthread_list_t __list; # define __PTHREAD_MUTEX_HAVE_PREV 1 #else - unsigned int __nusers; __extension__ union { __PTHREAD_SPINS_DATA; __pthread_slist_t __list; }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 #endif __PTHREAD_COMPAT_PADDING_END }; diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c index 4bb87e2..48676c2 100644 --- a/sysdeps/nptl/fork.c +++ b/sysdeps/nptl/fork.c @@ -166,7 +166,7 @@ __libc_fork (void) inherit the correct value from the parent. We do not need to clear the pending operation because it must have been zero when fork was called. */ -# ifdef __PTHREAD_MUTEX_HAVE_PREV +# if __PTHREAD_MUTEX_HAVE_PREV self->robust_prev = &self->robust_head; # endif self->robust_head.list = &self->robust_head; diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h index 632ea7b..2b2b386 100644 --- a/sysdeps/nptl/pthread.h +++ b/sysdeps/nptl/pthread.h @@ -83,7 +83,7 @@ enum #endif -#ifdef __PTHREAD_MUTEX_HAVE_PREV +#if __PTHREAD_MUTEX_HAVE_PREV # define PTHREAD_MUTEX_INITIALIZER \ { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } } # ifdef __USE_GNU diff --git a/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h b/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h index f29119b..8158cb5 100644 --- a/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h @@ -42,6 +42,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 1 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64) +#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64) #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/s390/nptl/bits/pthreadtypes-arch.h b/sysdeps/s390/nptl/bits/pthreadtypes-arch.h index 3a9ac57..1ae2773 100644 --- a/sysdeps/s390/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/s390/nptl/bits/pthreadtypes-arch.h @@ -45,6 +45,8 @@ #else #define __PTHREAD_MUTEX_LOCK_ELISION 0 #endif +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64) +#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64) #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/sh/nptl/bits/pthreadtypes-arch.h b/sysdeps/sh/nptl/bits/pthreadtypes-arch.h index b2615fe..e707751 100644 --- a/sysdeps/sh/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/sh/nptl/bits/pthreadtypes-arch.h @@ -34,6 +34,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1 +#define __PTHREAD_MUTEX_USE_UNION 1 #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h b/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h index 1e188cf..0f96f37 100644 --- a/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h @@ -43,6 +43,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64) +#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64) #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/tile/nptl/bits/pthreadtypes-arch.h b/sysdeps/tile/nptl/bits/pthreadtypes-arch.h index 145ee42..054474f 100644 --- a/sysdeps/tile/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/tile/nptl/bits/pthreadtypes-arch.h @@ -43,6 +43,8 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64) +#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64) #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT diff --git a/sysdeps/x86/nptl/bits/pthreadtypes-arch.h b/sysdeps/x86/nptl/bits/pthreadtypes-arch.h index fd86806..74d5f6d 100644 --- a/sysdeps/x86/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/x86/nptl/bits/pthreadtypes-arch.h @@ -51,6 +51,13 @@ #define __PTHREAD_COMPAT_PADDING_MID #define __PTHREAD_COMPAT_PADDING_END #define __PTHREAD_MUTEX_LOCK_ELISION 1 +#ifdef __x86_64__ +# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0 +# define __PTHREAD_MUTEX_USE_UNION 0 +#else +# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1 +# define __PTHREAD_MUTEX_USE_UNION 1 +#endif #define __LOCK_ALIGNMENT #define __ONCE_ALIGNMENT