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 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