|
|
Message-ID: <CAA2zVHoeAQ1b=taOYapqPfCPHtg4dGcj6CVR3==LUTr2wr3RZw@mail.gmail.com>
Date: Wed, 11 Mar 2026 10:49:15 -0400
From: James Y Knight <jyknight@...gle.com>
To: musl@...ts.openwall.com
Cc: Xing Li <lixing@...ngson.cn>, wanghongliang@...ngson.cn
Subject: Re: [PATCH] loongarch64: Add lsx and lasx regset definition
On Wed, Mar 11, 2026 at 12:07 AM Rich Felker <dalias@...c.org> wrote:
>
> On Tue, Sep 10, 2024 at 09:17:57AM +0800, Xing Li wrote:
> > Fix the upstream binutils-gdb building error caused by
> > the lack of lsx and lasx regset definition.
> > ---
> > arch/loongarch64/bits/user.h | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/arch/loongarch64/bits/user.h b/arch/loongarch64/bits/user.h
> > index fd9b7b22..10e1be45 100644
> > --- a/arch/loongarch64/bits/user.h
> > +++ b/arch/loongarch64/bits/user.h
> > @@ -22,3 +22,15 @@ typedef union {
> > float f;
> > } elf_fpreg_t;
> > typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
> > +
> > +typedef union
> > +{
> > + double d[2];
> > + float f[4];
> > +} elf_lsxregset_t[32] __attribute__((__aligned__(16)));
> > +
> > +typedef union
> > +{
> > + double d[4];
> > + float f[8];
> > +} elf_lasxregset_t[32] __attribute__((__aligned__(32)));
> > --
> > 2.27.0
>
> I don't like having the alignment directive bound to the whole type
> like this where it's depending on weird GNUC-isms that can't be
> represented in standard C alignas, but I think it's ok for now and we
> can find a better way to express it later if needed. I know this is
> another patch that distros have been carrying for a long time so I'd
> like to merge it for release.
That code looks weird. Why does it apply the alignment attribute on
the _array_ type, rather than the union type? E.g. why is this not
just:
typedef union
{
double d[2];
float f[4];
} __attribute__((__aligned__(16))) elf_lsxregset_t[32];
And once you have that, it's easy to take it one step further and move
the alignment onto the union field, at which point you can have
standard C code:
typedef union
{
_Alignas(16) double d[2];
_Alignas(16) float f[4];
} elf_lsxregset_t[32];
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.