Message ID | 25ef7709e4468a35cc42607cfc0f233d4cec3c25.1591201405.git.alistair.francis@wdc.com |
---|---|
State | Committed |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0AA5388C01D; Wed, 3 Jun 2020 16:34:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0AA5388C01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1591202073; bh=uBNr24lfPhGK5wbUn3rV7Krb/DmwzJwPeBCP4E7pVtU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=inp2u9XPqaV7M4+oKLim+VQcvBBFTyBHK+ABWG+Ea/LBGPdzrREHo9YEtkQ75TTbh At+SfoSCookYq0bWmE2w5oNXzuMgxW4hIs+1G+NPYl4GwJ7XOASRXeDhmSOF+r/Bf4 lxLyqUWIE6v3L2ADPUev2zo8ANqUD+zqgo2l5Fzs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by sourceware.org (Postfix) with ESMTPS id 094EB388C028 for <libc-alpha@sourceware.org>; Wed, 3 Jun 2020 16:34:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 094EB388C028 IronPort-SDR: ljvDujMtswCMvu+k94b2Q/piZq3RrnCt7HJcFTBiuAuzoSdgP3zsCYNy03KjlqCQQtBL2AE4rl uatwpeEAJN0lz6d4V0OBC/idcIOHQI45I9UZWTZZEvVfXjdB9Nyg83S/dNYb5fzsI0n50sLCXc 23rNTfoK7YLMbFXL1dCpz0hlyZXLgbVlz8EC5b++0G9Ro5MNV2KiGwE8t/JmgqOPxiaWXKFMdx HoCc/bJrhG/Z0k0kL4LcGSOeiVHeiCfisRLWjCSS1p42vbN/TOwE+ln90gXpUfCwqwwZ251q2z mMs= X-IronPort-AV: E=Sophos;i="5.73,468,1583164800"; d="scan'208";a="143452268" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Jun 2020 00:34:30 +0800 IronPort-SDR: kBTpdtEX0I3B8o7MV/C/j3zEz0iLG+ekdZx3PoSEj3JZT7PbUPfA6PzV042dg+GGkx2U9v4orJ sWXu67DDhcnPGpzewE2r/o0ocAPhEVHq0= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2020 09:24:08 -0700 IronPort-SDR: OOr0Eiwr5hqOg+nfyrkoN/LFeoy287QMjdyFrybiv0Zi6qXYPgM1F1B0BZVdf1LYe0jvWEfF9e uwvl+FLSz65Q== WDCIronportException: Internal Received: from cne220230.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.57.144]) by uls-op-cesaip02.wdc.com with ESMTP; 03 Jun 2020 09:34:29 -0700 To: libc-alpha@sourceware.org Subject: [PATCH v2 07/18] RISC-V: nptl: update default pthread-offsets.h Date: Wed, 3 Jun 2020 09:25:44 -0700 Message-Id: <25ef7709e4468a35cc42607cfc0f233d4cec3c25.1591201405.git.alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <cover.1591201405.git.alistair.francis@wdc.com> References: <cover.1591201405.git.alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-15.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <http://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Alistair Francis via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Alistair Francis <alistair.francis@wdc.com> Cc: alistair.francis@wdc.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
glibc port for 32-bit RISC-V (RV32)
|
|
Commit Message
Alistair Francis
June 3, 2020, 4:25 p.m. UTC
Update the RISC-V pthread-offsets.h values to support RV32. --- sysdeps/riscv/nptl/pthread-offsets.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Comments
On Wed, 3 Jun 2020, Alistair Francis via Libc-alpha wrote: > diff --git a/sysdeps/riscv/nptl/pthread-offsets.h b/sysdeps/riscv/nptl/pthread-offsets.h > index 31f0587bec..a85c752a1f 100644 > --- a/sysdeps/riscv/nptl/pthread-offsets.h > +++ b/sysdeps/riscv/nptl/pthread-offsets.h > @@ -1,3 +1,12 @@ > -#define __PTHREAD_MUTEX_KIND_OFFSET 16 > +#if __WORDSIZE == 64 > +# define __PTHREAD_MUTEX_KIND_OFFSET 16 > +#else > +# define __PTHREAD_MUTEX_KIND_OFFSET 12 > +#endif OK, we have: typedef union { struct __pthread_mutex_s __data; char __size[__SIZEOF_PTHREAD_MUTEX_T]; long int __align; } pthread_mutex_t; and then: struct __pthread_mutex_s { int __lock __LOCK_ALIGNMENT; unsigned int __count; int __owner; #if __WORDSIZE == 64 unsigned int __nusers; #endif int __kind; #if __WORDSIZE != 64 unsigned int __nusers; #endif which means the `__nusers' and `__kind' members are swapped between 64-bit and 32-bit hosts. Which I find kind of weird (what for?), but the offset of `__kind' changes accordingly and the values are correct. > -#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 > + > +#if __WORDSIZE == 64 > +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 > +#else > +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 > +#endif Likewise (as from 09/18): typedef union { struct __pthread_rwlock_arch_t __data; char __size[__SIZEOF_PTHREAD_RWLOCK_T]; long int __align; } pthread_rwlock_t; and: struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; #if __riscv_xlen == 64 int __cur_writer; int __shared; unsigned long int __pad1; unsigned long int __pad2; unsigned int __flags; #else # if __BYTE_ORDER == __BIG_ENDIAN unsigned char __pad1; unsigned char __pad2; unsigned char __shared; unsigned char __flags; # else unsigned char __flags; unsigned char __shared; unsigned char __pad1; unsigned char __pad2; # endif int __cur_writer; #endif }; so here we have 48 for RV64, 24 for RV32/LE, and 27 for RV/BE, meaning that your change is wrong. Please fix that. Also I think this change makes no sense at this point or indeed on its own as there's been no RV32 support added to <bits/struct_rwlock.h> as at this commit yet, meaning that the offsets would become inconsistent. Please fold it into 09/18. Maciej
On 08/07/2020 21:14, Maciej W. Rozycki via Libc-alpha wrote: > On Wed, 3 Jun 2020, Alistair Francis via Libc-alpha wrote: > >> diff --git a/sysdeps/riscv/nptl/pthread-offsets.h b/sysdeps/riscv/nptl/pthread-offsets.h >> index 31f0587bec..a85c752a1f 100644 >> --- a/sysdeps/riscv/nptl/pthread-offsets.h >> +++ b/sysdeps/riscv/nptl/pthread-offsets.h >> @@ -1,3 +1,12 @@ >> -#define __PTHREAD_MUTEX_KIND_OFFSET 16 >> +#if __WORDSIZE == 64 >> +# define __PTHREAD_MUTEX_KIND_OFFSET 16 >> +#else >> +# define __PTHREAD_MUTEX_KIND_OFFSET 12 >> +#endif > > OK, we have: > > typedef union > { > struct __pthread_mutex_s __data; > char __size[__SIZEOF_PTHREAD_MUTEX_T]; > long int __align; > } pthread_mutex_t; > > and then: > > struct __pthread_mutex_s > { > int __lock __LOCK_ALIGNMENT; > unsigned int __count; > int __owner; > #if __WORDSIZE == 64 > unsigned int __nusers; > #endif > int __kind; > #if __WORDSIZE != 64 > unsigned int __nusers; > #endif > > which means the `__nusers' and `__kind' members are swapped between 64-bit > and 32-bit hosts. Which I find kind of weird (what for?), but the offset > of `__kind' changes accordingly and the values are correct. The default __pthread_mutex_s was modeled from how other architectures has done so we use the common ground as default (and avoid having to create even more arch specific struct_mutex.h). I don't exactly why each port has used this specific layout though. > >> -#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 >> + >> +#if __WORDSIZE == 64 >> +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 >> +#else >> +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 >> +#endif > > Likewise (as from 09/18): > > typedef union > { > struct __pthread_rwlock_arch_t __data; > char __size[__SIZEOF_PTHREAD_RWLOCK_T]; > long int __align; > } pthread_rwlock_t; > > and: > > struct __pthread_rwlock_arch_t > { > unsigned int __readers; > unsigned int __writers; > unsigned int __wrphase_futex; > unsigned int __writers_futex; > unsigned int __pad3; > unsigned int __pad4; > #if __riscv_xlen == 64 > int __cur_writer; > int __shared; > unsigned long int __pad1; > unsigned long int __pad2; > unsigned int __flags; > #else > # if __BYTE_ORDER == __BIG_ENDIAN > unsigned char __pad1; > unsigned char __pad2; > unsigned char __shared; > unsigned char __flags; > # else > unsigned char __flags; > unsigned char __shared; > unsigned char __pad1; > unsigned char __pad2; > # endif > int __cur_writer; > #endif > }; > > so here we have 48 for RV64, 24 for RV32/LE, and 27 for RV/BE, meaning > that your change is wrong. Please fix that. This raises a flags because the wrong __PTHREAD_RWLOCK_FLAGS_OFFSET should generate a build failure at pthread_rwlock_init.c. > > Also I think this change makes no sense at this point or indeed on its > own as there's been no RV32 support added to <bits/struct_rwlock.h> as at > this commit yet, meaning that the offsets would become inconsistent. > Please fold it into 09/18. > > Maciej >
[Added cc's back.] On Thu, 9 Jul 2020, Adhemerval Zanella via Libc-alpha wrote: > > so here we have 48 for RV64, 24 for RV32/LE, and 27 for RV/BE, meaning > > that your change is wrong. Please fix that. > > This raises a flags because the wrong __PTHREAD_RWLOCK_FLAGS_OFFSET should > generate a build failure at pthread_rwlock_init.c. Possibly no one has ever built this code BE; I haven't. Now that I looked into it again I think GCC currently has no option for the big endianness with the RISC-V target, so maybe we can leave it as it is under your observation that a build failure is expected to happen here if someone tries it once/if we have such support in the compiler. Maciej
On Wed, Jul 8, 2020 at 5:14 PM Maciej W. Rozycki via Libc-alpha <libc-alpha@sourceware.org> wrote: > > On Wed, 3 Jun 2020, Alistair Francis via Libc-alpha wrote: > > > diff --git a/sysdeps/riscv/nptl/pthread-offsets.h b/sysdeps/riscv/nptl/pthread-offsets.h > > index 31f0587bec..a85c752a1f 100644 > > --- a/sysdeps/riscv/nptl/pthread-offsets.h > > +++ b/sysdeps/riscv/nptl/pthread-offsets.h > > @@ -1,3 +1,12 @@ > > -#define __PTHREAD_MUTEX_KIND_OFFSET 16 > > +#if __WORDSIZE == 64 > > +# define __PTHREAD_MUTEX_KIND_OFFSET 16 > > +#else > > +# define __PTHREAD_MUTEX_KIND_OFFSET 12 > > +#endif > > OK, we have: > > typedef union > { > struct __pthread_mutex_s __data; > char __size[__SIZEOF_PTHREAD_MUTEX_T]; > long int __align; > } pthread_mutex_t; > > and then: > > struct __pthread_mutex_s > { > int __lock __LOCK_ALIGNMENT; > unsigned int __count; > int __owner; > #if __WORDSIZE == 64 > unsigned int __nusers; > #endif > int __kind; > #if __WORDSIZE != 64 > unsigned int __nusers; > #endif > > which means the `__nusers' and `__kind' members are swapped between 64-bit > and 32-bit hosts. Which I find kind of weird (what for?), but the offset > of `__kind' changes accordingly and the values are correct. Great > > > -#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 > > + > > +#if __WORDSIZE == 64 > > +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 > > +#else > > +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 > > +#endif > > Likewise (as from 09/18): > > typedef union > { > struct __pthread_rwlock_arch_t __data; > char __size[__SIZEOF_PTHREAD_RWLOCK_T]; > long int __align; > } pthread_rwlock_t; > > and: > > struct __pthread_rwlock_arch_t > { > unsigned int __readers; > unsigned int __writers; > unsigned int __wrphase_futex; > unsigned int __writers_futex; > unsigned int __pad3; > unsigned int __pad4; > #if __riscv_xlen == 64 > int __cur_writer; > int __shared; > unsigned long int __pad1; > unsigned long int __pad2; > unsigned int __flags; > #else > # if __BYTE_ORDER == __BIG_ENDIAN > unsigned char __pad1; > unsigned char __pad2; > unsigned char __shared; > unsigned char __flags; > # else > unsigned char __flags; > unsigned char __shared; > unsigned char __pad1; > unsigned char __pad2; > # endif > int __cur_writer; > #endif > }; > > so here we have 48 for RV64, 24 for RV32/LE, and 27 for RV/BE, meaning > that your change is wrong. Please fix that. I have fixed the BE offset, although I don't think we actually support BE. > > Also I think this change makes no sense at this point or indeed on its > own as there's been no RV32 support added to <bits/struct_rwlock.h> as at > this commit yet, meaning that the offsets would become inconsistent. > Please fold it into 09/18. Done. Alistair > > Maciej
diff --git a/sysdeps/riscv/nptl/pthread-offsets.h b/sysdeps/riscv/nptl/pthread-offsets.h index 31f0587bec..a85c752a1f 100644 --- a/sysdeps/riscv/nptl/pthread-offsets.h +++ b/sysdeps/riscv/nptl/pthread-offsets.h @@ -1,3 +1,12 @@ -#define __PTHREAD_MUTEX_KIND_OFFSET 16 +#if __WORDSIZE == 64 +# define __PTHREAD_MUTEX_KIND_OFFSET 16 +#else +# define __PTHREAD_MUTEX_KIND_OFFSET 12 +#endif -#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 + +#if __WORDSIZE == 64 +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48 +#else +# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24 +#endif