From patchwork Fri Dec 29 14:58:35 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: 122937 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4784768qgn; Fri, 29 Dec 2017 06:59:24 -0800 (PST) X-Google-Smtp-Source: ACJfBovDLPypQOnj4oU4NgEgQ7+n/xjZBDyzQ27nc4mQjd9dAtahylc8VuSbZ+gR4nt9qrYtOmab X-Received: by 10.101.81.2 with SMTP id f2mr6247845pgq.199.1514559564521; Fri, 29 Dec 2017 06:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514559564; cv=none; d=google.com; s=arc-20160816; b=lBdswLQQbAbB3w+81+Ext7EF1j5T/y+ESo0rOBJSIcB68QRxpNpflIguZ/jJHfmd+x gdaWVf7EBQ1RsnHrr10TXR+VD9ZY9r4GuCIjSlOCUCR/U1AD1gp8r8e6nx3EBgAwQpQw We5Jh0KyeQH9HmGkJ/yixc7MfRh5T7A+4jEZftzKyvg/G0YRJRFvt6ve3niQMWFQb3aC eYTjb5K/PzrpCI3ip7313VRmIcJy/8hJbYqWx9SkB8XLyvruqWaleapz6zH24C62U0Hp CxsOpT/1d27azWCQDp4wvI06qzlgjU64+XTDvZAOunTrLNbNytbcZjihMUG6Y12gs+Xp UTQQ== 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=3h7d2x1uKDRQ+s0lc91mcqbHW38faD549kibeO1DIKA=; b=UJaIBCbwtP4pfczrWQKHhlxzs8m/Jna7X6AoPvhfguN9bLmkMA5Pyqr9GqhYsgjJ93 A8UvT0XlPhn0KHKWUQxOIX8Nk19ZY5LXhszBv/t3gsbu6+GtdIeYc8fzswLl91q3j0Bs oFtJCu9U/xQpLWbXvFcxETx0YY4+n406rxZeavnEorTuUTJYXBAi6c/srzJ7biNIiibD Ypn3v+v5fWb3ZwZNqNKMSHZFFrbP4lgFz7mh2esc6FXTuNeyRwDYjK7XjfL0Lyq3h9CK SsMxMQHnjrRdB53iQWtW59VDMKimPagQFD03GzW1bm08LqAQ/1VOIg8w1s9zeOTQtKwm FrKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=YzwFUQq1; spf=pass (google.com: domain of libc-alpha-return-88666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88666-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 s17si28279338plp.176.2017.12.29.06.59.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Dec 2017 06:59:24 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-88666-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=YzwFUQq1; spf=pass (google.com: domain of libc-alpha-return-88666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88666-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=gP7cSiltB1C3XFZABkHH4waBWA727fo66S/VQgloVxjeZ+qgSi2uK MZ1OP7DFklfhP4NxfQu4GBRHcaKEHaXdasstFoEfKowmKHpQs4GPqVltHuKudvmJ Vkg5R70/CbYuuqDgTZOGsF4lEyCsmfWIkdJpW0Q4kISe1vJqdWV/ig= 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=gC2Z9Ot6jIgvASauLw0cxyK80HU=; b=YzwFUQq10T6ULJ42WjZ/twdX48/6 Il5vEdWLOPsgE0ofqDcl3DnrWfh3G4GJeUS7WlFqPJVC8OizbZwlP6lX6yw2eXIn AWtBRqgXDyVQgL5j9hniLQrBDUqAGw2z8V6hw3wJQaS4cRa2GH/ycHp0y7DTHX3B v3UN4PZwsAUtppM= Received: (qmail 52853 invoked by alias); 29 Dec 2017 14:58:56 -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 52792 invoked by uid 89); 29 Dec 2017 14:58:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=linuxgnu, linux-gnu 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; bh=3h7d2x1uKDRQ+s0lc91mcqbHW38faD549kibeO1DIKA=; b=TwYe0tGlLBsBhmRBLD184e6aHc+nQXuI186vmvg1ebNn/jLJNwS0GgW0HEqC32+n+p 2TU68C2KIpU6X3E/V9rmEMjiefCi5AvV+UeowhEcdzhJHPivcCzvOpNGkVsugX1diCKc T/5kgrW9o5XK0bQ4cwB2FEnOduOMPU2tuvPAb78TvJPAZiyqnME1hpQFfSUYSt6//f5W z8/o+lNWhXhRerjVld5QBAu4gEruQU500K+2RstiihL3D6da8yiVuQC1YEX3b2FBn+s0 S7KH1olEc/V/bHtWnCagRaXgr51Vcy7S3G3cQys8aIAjWVUvHCsiNpSyODHyhkgYINRz dQ8A== X-Gm-Message-State: AKGB3mK2K4dnjND+yHXpRGegMJLVXjRBAnYhGnFaRtkcuLuVRL5aP2/N u4NfV3GeazAZCOiQHa0OIwzzS6d9zJs= X-Received: by 10.55.9.149 with SMTP id 143mr25656284qkj.320.1514559526212; Fri, 29 Dec 2017 06:58:46 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/5] nptl: Add mutex-internal.h Date: Fri, 29 Dec 2017 12:58:35 -0200 Message-Id: <1514559519-13167-1-git-send-email-adhemerval.zanella@linaro.org> The current way of adding different flags and place a common definition at sysdeps/nptl/bits/thread-shared-types.h for internal pthread_mutex_t struct is not really the simpler option for new ports: it requires some misleading flags that shouldn't be defined any way (__PTHREAD_COMPAT_PADDING_MID and __PTHREAD_COMPAT_PADDING_END), it gives an option used solely for linuxthread compat mode that removes the possibility of using adaptive robust mutexes (__PTHREAD_MUTEX_USE_UNION), and add a flag (__PTHREAD_MUTEX_NUSERS_AFTER_KIND) that only exists for compatibility reason. Instead this patch adds a new architecture define header meant for internal pthread_mutex_t type (__pthread_mutex_s) layout definition. The idea is to simplify new ports inclusion by providing a default generic interface. The definions for __pthread_mutex_s internal layout compat mode (__PTHREAD_COMPAT_PADDING_MID, __PTHREAD_COMPAT_PADDING_END, __PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION) are removed and the internal pthread type (__pthread_mutex_s) is move from pthreadtypes-arch.h to mutex-internal.h. Also the static intialization macro for pthread_mutex_t is set to use an arch defined on (__PTHREAD_MUTEX_INITIALIZER) which simplifies its implementation. The default pthread_mutex_t layout differs from current ports with: 1. The internal layout is the same for both 32 bits and 64 bits. 2. The __spins and __list is not an union for 32 bits. It allows adaptive mutexes to work with robust attribute. Current code does not support for 32 bits it due mutex struct size limitation for compatibility with linuxthreads. 3. It uses a double linked list for robust internal list. It allows faster insertion and removals at the cost of slight more memory usage. Checked with a build on affected abis (alpha-linux-gnu, armv7-linux-gnueabihf, hppa-linux-gnu, ia64-linux-gnu, i686-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu, nios2-linux-gnu, powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sh4-linux-gnu, sparc{v9,64}-linux-gnu, tile{pro,gx64}-linux-gnu, x86_64-linux-gnu). * posix/Makefile (headers): Add mutex-internal.h. * sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h (__PTHREAD_COMPAT_PADDING_MID, __PTHREAD_COMPAT_PADDING_END, __PTHREAD_MUTEX_LOCK_ELISION, __PTHREAD_MUTEX_NUSERS_AFTER_KIND, __PTHREAD_MUTEX_USE_UNION): Move to mutex-interal.h. * sysdeps/alpha/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/arm/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/hppa/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/ia64/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/m68k/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/nios2/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/s390/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/sh/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/sparc/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/tile/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/x86/nptl/bits/pthreadtypes-arch.h: Likewise. * sysdeps/arm/nptl/bits/mutex-internal.h: New file. * sysdeps/hppa/nptl/bits/mutex-internal.h: Likewise. * sysdeps/m68k/nptl/bits/mutex-internal.h: Likewise. * sysdeps/microblaze/nptl/bits/mutex-internal.h: Likewise. * sysdeps/mips/nptl/bits/mutex-internal.h: Likewise. * sysdeps/nios2/nptl/bits/mutex-internal.h: Likewise. * sysdeps/nptl/bits/mutex-internal.h: Likewise. * sysdeps/powerpc/nptl/bits/mutex-internal.h: Likewise. * sysdeps/s390/nptl/bits/mutex-internal.h: Likewise. * sysdeps/sh/nptl/bits/mutex-internal.h: Likewise. * sysdeps/sparc/nptl/bits/mutex-internal.h: Likewise. * sysdeps/tile/nptl/bits/mutex-internal.h: Likewise. * sysdeps/x86/nptl/bits/mutex-internal.h: Likewise. * sysdeps/nptl/bits/thread-shared-types.h: Include mutex-internal.h. * sysdeps/nptl/pthread.h (PTHREAD_MUTEX_INITIALIZER, PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP): Implement based on arch specific __PTHREAD_MUTEX_INITIALIZER macro. * sysdeps/unix/sysv/linux/hppa/pthread.h: Likewise. Signed-off-by: Adhemerval Zanella --- ChangeLog | 41 ++++++++ posix/Makefile | 1 + sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/alpha/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/arm/nptl/bits/mutex-internal.h | 44 +++++++++ sysdeps/arm/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/hppa/nptl/bits/mutex-internal.h | 54 +++++++++++ sysdeps/hppa/nptl/bits/pthreadtypes-arch.h | 11 --- sysdeps/ia64/nptl/bits/mutex-internal.h | 41 ++++++++ sysdeps/ia64/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/m68k/nptl/bits/mutex-internal.h | 44 +++++++++ sysdeps/m68k/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/microblaze/nptl/bits/mutex-internal.h | 43 +++++++++ sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/mips/nptl/bits/mutex-internal.h | 58 ++++++++++++ sysdeps/nios2/nptl/bits/mutex-internal.h | 44 +++++++++ sysdeps/nios2/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/nptl/bits/mutex-internal.h | 43 +++++++++ sysdeps/nptl/bits/thread-shared-types.h | 116 ++++++----------------- sysdeps/nptl/pthread.h | 33 ++----- sysdeps/powerpc/nptl/bits/mutex-internal.h | 64 +++++++++++++ sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/s390/nptl/bits/mutex-internal.h | 65 +++++++++++++ sysdeps/s390/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/sh/nptl/bits/mutex-internal.h | 43 +++++++++ sysdeps/sh/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/sparc/nptl/bits/mutex-internal.h | 59 ++++++++++++ sysdeps/sparc/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/tile/nptl/bits/mutex-internal.h | 57 +++++++++++ sysdeps/tile/nptl/bits/pthreadtypes-arch.h | 7 -- sysdeps/unix/sysv/linux/hppa/pthread.h | 11 +-- sysdeps/x86/nptl/bits/mutex-internal.h | 65 +++++++++++++ sysdeps/x86/nptl/bits/pthreadtypes-arch.h | 12 --- 33 files changed, 806 insertions(+), 227 deletions(-) create mode 100644 sysdeps/arm/nptl/bits/mutex-internal.h create mode 100644 sysdeps/hppa/nptl/bits/mutex-internal.h create mode 100644 sysdeps/ia64/nptl/bits/mutex-internal.h create mode 100644 sysdeps/m68k/nptl/bits/mutex-internal.h create mode 100644 sysdeps/microblaze/nptl/bits/mutex-internal.h create mode 100644 sysdeps/mips/nptl/bits/mutex-internal.h create mode 100644 sysdeps/nios2/nptl/bits/mutex-internal.h create mode 100644 sysdeps/nptl/bits/mutex-internal.h create mode 100644 sysdeps/powerpc/nptl/bits/mutex-internal.h create mode 100644 sysdeps/s390/nptl/bits/mutex-internal.h create mode 100644 sysdeps/sh/nptl/bits/mutex-internal.h create mode 100644 sysdeps/sparc/nptl/bits/mutex-internal.h create mode 100644 sysdeps/tile/nptl/bits/mutex-internal.h create mode 100644 sysdeps/x86/nptl/bits/mutex-internal.h -- 2.7.4 diff --git a/posix/Makefile b/posix/Makefile index e34b108..f52a5e0 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -27,6 +27,7 @@ headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \ getopt.h bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \ bits/types.h bits/typesizes.h bits/pthreadtypes.h \ bits/pthreadtypes-arch.h bits/thread-shared-types.h \ + bits/mutex-internal.h \ bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \ bits/local_lim.h tar.h bits/utsname.h bits/confname.h \ bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \ diff --git a/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h b/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h index 9ab23d0..7cf45f0 100644 --- a/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h @@ -41,13 +41,6 @@ #define __SIZEOF_PTHREAD_COND_T 48 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 -/* Definitions for internal mutex struct. */ -#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 429df10..0d6d7e6 100644 --- a/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h @@ -29,13 +29,6 @@ #define __SIZEOF_PTHREAD_BARRIER_T 32 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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/mutex-internal.h b/sysdeps/arm/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..fc00ebf --- /dev/null +++ b/sysdeps/arm/nptl/bits/mutex-internal.h @@ -0,0 +1,44 @@ +/* ARM internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +}; + +#define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_HAVE_PREV 0 + +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } + +#endif diff --git a/sysdeps/arm/nptl/bits/pthreadtypes-arch.h b/sysdeps/arm/nptl/bits/pthreadtypes-arch.h index 3911c81..ffd8de3 100644 --- a/sysdeps/arm/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/arm/nptl/bits/pthreadtypes-arch.h @@ -30,13 +30,6 @@ #define __SIZEOF_PTHREAD_BARRIER_T 20 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Data structure for mutex handling. */ -#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/mutex-internal.h b/sysdeps/hppa/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..3368375 --- /dev/null +++ b/sysdeps/hppa/nptl/bits/mutex-internal.h @@ -0,0 +1,54 @@ +/* HPPA internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock __LOCK_ALIGNMENT; + unsigned int __count; + int __owner; + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; + /* The old 4-word 16-byte aligned lock. This is initalized + to all ones by the Linuxthreads PTHREAD_MUTEX_INITIALIZER. + Unused in NPTL. */ + int __glibc_compat_padding[4]; + /* In the old structure there are 4 words left due to alignment. + In NPTL two words are used. */ + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; + /* Two more words are left before the NPTL + pthread_mutex_t is larger than Linuxthreads. */ + int __glibc_reserved1; + int __glibc_reserved2; +}; + +#define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_HAVE_PREV 0 + +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, { 0, 0, 0, 0 }, 0, { 0 }, 0, 0 + +#endif diff --git a/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h b/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h index 865a14e..cf9399d 100644 --- a/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h @@ -40,17 +40,6 @@ #define __SIZEOF_PTHREAD_RWLOCK_T 64 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 -/* The old 4-word 16-byte aligned lock. This is initalized - to all ones by the Linuxthreads PTHREAD_MUTEX_INITIALIZER. - Unused in NPTL. */ -#define __PTHREAD_COMPAT_PADDING_MID int __compat_padding[4]; -/* Two more words are left before the NPTL - 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/mutex-internal.h b/sysdeps/ia64/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..aef672d --- /dev/null +++ b/sysdeps/ia64/nptl/bits/mutex-internal.h @@ -0,0 +1,41 @@ +/* Default internal mutex struct definitions. ia64 version. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; + unsigned int __nusers; + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; + int __spins; + __pthread_list_t __list; +}; + +#define __PTHREAD_MUTEX_HAVE_PREV 1 +#define __PTHREAD_MUTEX_LOCK_ELISION 0 + +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, { 0, 0 } + +#endif diff --git a/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h b/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h index 2a3bc75..42c71af 100644 --- a/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h @@ -29,13 +29,6 @@ #define __SIZEOF_PTHREAD_BARRIER_T 32 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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/mutex-internal.h b/sysdeps/m68k/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..ebfd0ab --- /dev/null +++ b/sysdeps/m68k/nptl/bits/mutex-internal.h @@ -0,0 +1,44 @@ +/* m68k internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock __LOCK_ALIGNMENT; + unsigned int __count; + int __owner; + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +}; + +#define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_HAVE_PREV 0 + +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } + +#endif diff --git a/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h b/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h index 966cc75..7ff98fe 100644 --- a/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h @@ -31,13 +31,6 @@ #define __SIZEOF_PTHREAD_BARRIER_T 20 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Data structure for mutex handling. */ -#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/mutex-internal.h b/sysdeps/microblaze/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..98fda1a --- /dev/null +++ b/sysdeps/microblaze/nptl/bits/mutex-internal.h @@ -0,0 +1,43 @@ +/* Microblaze internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +}; +#define __PTHREAD_MUTEX_HAVE_PREV 0 +#define __PTHREAD_MUTEX_LOCK_ELISION 0 + +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } + +#endif diff --git a/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h b/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h index e44f2dc..b69feaa 100644 --- a/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h @@ -31,13 +31,6 @@ # define __SIZEOF_PTHREAD_BARRIER_T 20 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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/mutex-internal.h b/sysdeps/mips/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..f76a19a --- /dev/null +++ b/sysdeps/mips/nptl/bits/mutex-internal.h @@ -0,0 +1,58 @@ +/* MIPS internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; +#if _MIPS_SIM == _ABI64 + unsigned int __nusers; +#endif + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; +#if _MIPS_SIM == _ABI64 + int __spins; + __pthread_list_t __list; +# define __PTHREAD_MUTEX_HAVE_PREV 1 +#else + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 +#endif +}; + +#define __PTHREAD_MUTEX_LOCK_ELISION 0 + +#if _MIPS_SIM == _ABI64 +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, { 0, 0 } +#else +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } +#endif + +#endif diff --git a/sysdeps/nios2/nptl/bits/mutex-internal.h b/sysdeps/nios2/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..5b53f07 --- /dev/null +++ b/sysdeps/nios2/nptl/bits/mutex-internal.h @@ -0,0 +1,44 @@ +/* NIOS2 internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +}; + +#define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_HAVE_PREV 0 + +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } + +#endif diff --git a/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h b/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h index 83f8684..18ea235 100644 --- a/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/nios2/nptl/bits/pthreadtypes-arch.h @@ -31,13 +31,6 @@ #define __SIZEOF_PTHREAD_BARRIER_T 20 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Data structure for mutex handling. */ -#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/mutex-internal.h b/sysdeps/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..ca938e7 --- /dev/null +++ b/sysdeps/nptl/bits/mutex-internal.h @@ -0,0 +1,43 @@ +/* Default internal mutex struct definitions. Linux version. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +/* This is the default defines for the 'struct __pthread_mutex_s' layout, + used for POSIX pthread_mutex_t definition. New ports are expected to + used the default layout. The struct will have size of 32 on LP32 and + 40 on LP64. */ + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; + unsigned int __nusers; + int __kind; + int __spins; + __pthread_list_t __list; +}; + +#define __PTHREAD_MUTEX_HAVE_PREV 1 +#define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, { 0, 0 } + +#endif diff --git a/sysdeps/nptl/bits/thread-shared-types.h b/sysdeps/nptl/bits/thread-shared-types.h index da4358a..5bfd54e 100644 --- a/sysdeps/nptl/bits/thread-shared-types.h +++ b/sysdeps/nptl/bits/thread-shared-types.h @@ -32,36 +32,6 @@ __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. - Also, the following macros must be define for internal pthread_mutex_t - struct definitions (struct __pthread_mutex_s): - - __PTHREAD_COMPAT_PADDING_MID - any additional members after 'kind' - and before '__spin' (for 64 bits) or - '__nusers' (for 32 bits). - __PTHREAD_COMPAT_PADDING_END - any additional members at the end of - 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: @@ -72,78 +42,46 @@ __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. And finally the internal pthread_rwlock_t (struct __pthread_rwlock_arch_t) - must be defined. - */ + must be defined. */ + #include + /* Common definition of pthread_mutex_t. */ -#if !__PTHREAD_MUTEX_USE_UNION typedef struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __pthread_list_t; -#else + typedef struct __pthread_internal_slist { struct __pthread_internal_slist *__next; } __pthread_slist_t; -#endif - -/* Lock elision support. */ -#if __PTHREAD_MUTEX_LOCK_ELISION -# if !__PTHREAD_MUTEX_USE_UNION -# define __PTHREAD_SPINS_DATA \ - short __spins; \ - short __elision -# define __PTHREAD_SPINS 0, 0 -# else -# define __PTHREAD_SPINS_DATA \ - struct \ - { \ - short __espins; \ - short __eelision; \ - } __elision_data -# define __PTHREAD_SPINS { 0, 0 } -# define __spins __elision_data.__espins -# define __elision __elision_data.__eelision -# endif -#else -# define __PTHREAD_SPINS_DATA int __spins -/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER. */ -# define __PTHREAD_SPINS 0 -#endif - -struct __pthread_mutex_s -{ - int __lock __LOCK_ALIGNMENT; - unsigned int __count; - int __owner; -#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 __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 - __extension__ union - { - __PTHREAD_SPINS_DATA; - __pthread_slist_t __list; - }; -# define __PTHREAD_MUTEX_HAVE_PREV 0 -#endif - __PTHREAD_COMPAT_PADDING_END -}; + +/* Arch-specific mutex definitions. A generic implementation is provided + by sysdeps/nptl/bits/mutex-internal.h. If required, an architecture + can override it by defining: + + 1. struct __pthread_mutex_s (used on pthread_mutex_t definition). It + should contain at least the internal members defined in the generic + version. + + 2. __PTHREAD_MUTEX_HAVE_PREV to either 1 if __pthread_mutex_s defines + the double-linked list __pthread_internal_list, or 0 if it uses + the single-linked list __pthread_internal_slist. They are used on + robust mutex implementation and the double-linked trades memory + usage for a faster insertion and removal. + + 3. __PTHREAD_MUTEX_LOCK_ELISION to either 1 if architecture supports + hardware lock elision and actually uses the __elision member or + 0 otherwise. + + 4. __PTHREAD_MUTEX_INITIALIZER macro used for static initialization. + It should initialize the mutex internal type. */ + +#include /* Common definition of pthread_cond_t. */ diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h index 787ac6e..d4a0aa8 100644 --- a/sysdeps/nptl/pthread.h +++ b/sysdeps/nptl/pthread.h @@ -84,30 +84,15 @@ enum #endif -#if __PTHREAD_MUTEX_HAVE_PREV -# define PTHREAD_MUTEX_INITIALIZER \ - { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } } -# ifdef __USE_GNU -# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } } -# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } } -# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } } - -# endif -#else -# define PTHREAD_MUTEX_INITIALIZER \ - { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } } -# ifdef __USE_GNU -# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } } -# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } } -# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } } - -# endif +#define PTHREAD_MUTEX_INITIALIZER \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_DEFAULT) } } +#ifdef __USE_GNU +# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_RECURSIVE_NP) } } +# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ERRORCHECK_NP) } } +# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ADAPTIVE_NP) } } #endif diff --git a/sysdeps/powerpc/nptl/bits/mutex-internal.h b/sysdeps/powerpc/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..0485a44 --- /dev/null +++ b/sysdeps/powerpc/nptl/bits/mutex-internal.h @@ -0,0 +1,64 @@ +/* PowerPC internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; +#if __WORDSIZE == 64 + unsigned int __nusers; +#endif + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; +#if __WORDSIZE == 64 + short __spins; + short __elision; + __pthread_list_t __list; +# define __PTHREAD_MUTEX_HAVE_PREV 1 +#else + unsigned int __nusers; + __extension__ union + { + struct + { + short __espins; + short __elision; +# define __spins __elision_data.__espins +# define __elision __elision_data.__elision + } __elision_data; + __pthread_slist_t __list; + }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 +#endif +}; +#define __PTHREAD_MUTEX_LOCK_ELISION 1 + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, 0, { 0, 0 } +#else +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { { 0, 0 } } +#endif + +#endif diff --git a/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h b/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h index 8158cb5..3a1680a 100644 --- a/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h @@ -38,13 +38,6 @@ #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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/mutex-internal.h b/sysdeps/s390/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..f3549bd --- /dev/null +++ b/sysdeps/s390/nptl/bits/mutex-internal.h @@ -0,0 +1,65 @@ +/* S390 internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; +#if __WORDSIZE == 64 + unsigned int __nusers; +#endif + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; +#if __WORDSIZE == 64 + short __spins; + short __elision; + __pthread_list_t __list; +# define __PTHREAD_MUTEX_HAVE_PREV 1 +#else + unsigned int __nusers; + __extension__ union + { + struct + { + short __espins; + short __elision; + } _d; +# define __spins _d.__espins +# define __elision _d.__elision + __pthread_slist_t __list; + }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 +#endif +}; + +#define __PTHREAD_MUTEX_LOCK_ELISION 1 + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, 0, { 0, 0 } +#else +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { { 0, 0 } } +#endif + +#endif diff --git a/sysdeps/s390/nptl/bits/pthreadtypes-arch.h b/sysdeps/s390/nptl/bits/pthreadtypes-arch.h index fd15931..6ff0f12 100644 --- a/sysdeps/s390/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/s390/nptl/bits/pthreadtypes-arch.h @@ -37,13 +37,6 @@ #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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/sh/nptl/bits/mutex-internal.h b/sysdeps/sh/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..83acf27 --- /dev/null +++ b/sysdeps/sh/nptl/bits/mutex-internal.h @@ -0,0 +1,43 @@ +/* SH internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +}; +#define __PTHREAD_MUTEX_LOCK_ELISION 0 +#define __PTHREAD_MUTEX_HAVE_PREV 0 + +#define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } + +#endif diff --git a/sysdeps/sh/nptl/bits/pthreadtypes-arch.h b/sysdeps/sh/nptl/bits/pthreadtypes-arch.h index e707751..ca28010 100644 --- a/sysdeps/sh/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/sh/nptl/bits/pthreadtypes-arch.h @@ -30,13 +30,6 @@ #define __SIZEOF_PTHREAD_BARRIER_T 20 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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/mutex-internal.h b/sysdeps/sparc/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..265a067 --- /dev/null +++ b/sysdeps/sparc/nptl/bits/mutex-internal.h @@ -0,0 +1,59 @@ +/* SPARC internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; +#if __WORDSIZE == 64 + unsigned int __nusers; +#endif + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; +#if __WORDSIZE == 64 + int __spins; + __pthread_list_t __list; +# define __PTHREAD_MUTEX_HAVE_PREV 1 +#else + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 +#endif +}; + +#define __PTHREAD_MUTEX_LOCK_ELISION 0 + + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, { 0, 0 } +#else +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } +#endif + +#endif diff --git a/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h b/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h index 0f96f37..92f1ae2 100644 --- a/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/sparc/nptl/bits/pthreadtypes-arch.h @@ -39,13 +39,6 @@ #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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/mutex-internal.h b/sysdeps/tile/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..253873d --- /dev/null +++ b/sysdeps/tile/nptl/bits/mutex-internal.h @@ -0,0 +1,57 @@ +/* Microblaze internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; +#if __WORDSIZE == 64 + unsigned int __nusers; +#endif + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; +#if __WORDSIZE == 64 + int __spins; + __pthread_list_t __list; +# define __PTHREAD_MUTEX_HAVE_PREV 1 +#else + unsigned int __nusers; + __extension__ union + { + int __spins; + __pthread_slist_t __list; + }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 +#endif +}; +#define __PTHREAD_MUTEX_LOCK_ELISION 0 + +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, { 0, 0 } +#else +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { 0 } +#endif + +#endif diff --git a/sysdeps/tile/nptl/bits/pthreadtypes-arch.h b/sysdeps/tile/nptl/bits/pthreadtypes-arch.h index 054474f..fef6176 100644 --- a/sysdeps/tile/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/tile/nptl/bits/pthreadtypes-arch.h @@ -39,13 +39,6 @@ #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Data structure for mutex handling. */ -#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/unix/sysv/linux/hppa/pthread.h b/sysdeps/unix/sysv/linux/hppa/pthread.h index 3d69ddc..4f01670 100644 --- a/sysdeps/unix/sysv/linux/hppa/pthread.h +++ b/sysdeps/unix/sysv/linux/hppa/pthread.h @@ -85,17 +85,14 @@ enum #define PTHREAD_MUTEX_INITIALIZER \ - { { 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, { __PTHREAD_SPINS }, { 0, 0 } } } + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_DEFAULT) } } #ifdef __USE_GNU # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, { 0, 0, 0, 0 }, 0, \ - { __PTHREAD_SPINS }, { 0, 0 } } } + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_RECURSIVE_NP) } } # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, { 0, 0, 0, 0 }, 0, \ - { __PTHREAD_SPINS }, { 0, 0 } } } + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ERRORCHECK_NP) } } # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ - { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, { 0, 0, 0, 0 }, 0, \ - { __PTHREAD_SPINS }, { 0, 0 } } } + { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ADAPTIVE_NP) } } #endif diff --git a/sysdeps/x86/nptl/bits/mutex-internal.h b/sysdeps/x86/nptl/bits/mutex-internal.h new file mode 100644 index 0000000..4f54d4d --- /dev/null +++ b/sysdeps/x86/nptl/bits/mutex-internal.h @@ -0,0 +1,65 @@ +/* x86 internal mutex struct definitions. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _THREAD_MUTEX_INTERNAL_H +#define _THREAD_MUTEX_INTERNAL_H 1 + +struct __pthread_mutex_s +{ + int __lock; + unsigned int __count; + int __owner; +#ifdef __x86_64__ + unsigned int __nusers; +#endif + /* KIND must stay at this position in the structure to maintain + binary compatibility with static initializers. */ + int __kind; +#ifdef __x86_64__ + short __spins; + short __elision; + __pthread_list_t __list; +# define __PTHREAD_MUTEX_HAVE_PREV 1 +#else + unsigned int __nusers; + __extension__ union + { + struct + { + short __espins; + short __elision; +# define __spins __elision_data.__espins +# define __elision __elision_data.__elision +# define __PTHREAD_SPINS { 0, 0 } + } __elision_data; + __pthread_slist_t __list; + }; +# define __PTHREAD_MUTEX_HAVE_PREV 0 +#endif +}; +#define __PTHREAD_MUTEX_LOCK_ELISION 0 + +#ifdef __x86_64__ +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, 0, __kind, 0, 0, { 0, 0 } +#else +# define __PTHREAD_MUTEX_INITIALIZER(__kind) \ + 0, 0, 0, __kind, 0, { { 0, 0 } } +#endif + +#endif diff --git a/sysdeps/x86/nptl/bits/pthreadtypes-arch.h b/sysdeps/x86/nptl/bits/pthreadtypes-arch.h index 74d5f6d..a2c209b 100644 --- a/sysdeps/x86/nptl/bits/pthreadtypes-arch.h +++ b/sysdeps/x86/nptl/bits/pthreadtypes-arch.h @@ -47,18 +47,6 @@ #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4 -/* Definitions for internal mutex struct. */ -#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