Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH8yC8keqOjUwQnbwrDBuMQOhmuscpJ71j0tw0wNZmkJuXUe1g@mail.gmail.com>
Date: Tue, 22 Mar 2022 11:06:41 -0400
From: Jeffrey Walton <noloader@...il.com>
To: musl@...ts.openwall.com
Cc: 王洪亮 <wanghongliang@...ngson.cn>, liuxue@...ngson.cn, 
	lvjianmin@...ngson.cn
Subject: Re: add loongarch64 port

On Tue, Mar 22, 2022 at 8:59 AM Rich Felker <dalias@...c.org> wrote:
> On Tue, Mar 22, 2022 at 11:52:35AM +0800, 王洪亮 wrote:
...
> > +++ b/arch/loongarch64/bits/signal.h
> > @@ -0,0 +1,79 @@
> > +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
> > + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
> > +
> > +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
> > +#define MINSIGSTKSZ 4096
> > +#define SIGSTKSZ 16384
> > +#endif
> > +
> > +typedef unsigned long greg_t, gregset_t[32];
> > +
> > +typedef struct sigcontext {
> > +     unsigned long pc;
> > +     gregset_t gregs;
> > +     unsigned int flags;
> > +     unsigned long extcontext[0] __attribute__((__aligned__(16)));
> > +}mcontext_t;
>
> [0] is not valid, and having a flexible array member here is possibly
> not even useful since I don't think it would be valid to access it via
> uc->uc_mcontext.extcontext[] since the instance of mcontext_t inside
> the ucontext struct does not have FAM space belonging to it, even if
> additional space was allocated past the end of the ucontext_t. In
> other words, I think compilers would be justified in treating attempts
> to access it this way as UB and optimizing them out.

I believe zero-length arrays are legal in C99. I'm not sure how well
it applies here or to Musl on some (older?) platforms.

Microsoft used to use [1] for ANYSIZE_ARRAY. Also see
https://web.archive.org/web/20120209061713/http://blogs.msdn.com/b/oldnewthing/archive/2004/08/26/220873.aspx

Jeff

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.