public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: caiyinyu <caiyinyu@loongson.cn>, libc-alpha@sourceware.org
Cc: "Xi Ruoyao" <xry111@xry111.site>,
	lixing@loongson.cn, wuxiaotian@loongson.cn,
	王洪虎 <wanghonghu@loongson.cn>
Subject: Re: [PATCH] LoongArch: Ensure consistency with kernel by using union for struct members in mcontext_t and ucontext_t.
Date: Thu, 6 Apr 2023 12:02:28 +0100	[thread overview]
Message-ID: <ZC6mxCuIiAy2doPy@arm.com> (raw)
In-Reply-To: <3dd3e520-b5f0-beee-86f3-965a5d3c9dc6@loongson.cn>

The 04/06/2023 17:59, caiyinyu wrote:
> 在 2023/4/5 上午1:38, Szabolcs Nagy 写道:
> > The 04/03/2023 20:01, caiyinyu wrote:
> > > During the construction of the LoongArch Alpine system,
> > > we found that there is an inconsistency in the member
> > > names of mcontext_t and ucontext_t between musl and glibc,
> > > which can cause compilation errors. After testing, we decided
> > > to use union to keep these member names consistency.
> > there is no musl api compat requirement at the moment (the musl
> > loongarch port is not committed yet so surely that can be
> > changed to be consistent).
> 
> 
> We want to ensure that the structure member names in mcontext_t are
> 
> consistent with the kernel (like other architectures)
> 
> before submitting LoongArch musl (Currently under development) to the
> upstream community.
> 
> This will allow for consistency in the structure member names
> 
> across musl, glibc, and the kernel for related structures.
> 
> 
> > there is an api difference between glibc and linux uapi headers.
> > i personally don't think this is an issue. (the c abi must match
> > but struct sigcontext and mcontext_t are not used interchangably
> > in code. the c++ mangling abi is different even after your patch)
> 
> 
> I am currently facing some confusion.
> 
> As far as I know, in C++, the member names of a struct or union are not
> subject to mangling.

sorry i did not mean to say you are breaking c++ abi compared to
the current glibc code, but that the linux sigcontext struct has
different c++ abi even if the field names are the same (because
sigcontext vs mcontext_t struct tag).

this tells me that you cannot use those two types interchangably
in c++ library apis anyway and i would expect that the two types
don't get confused in source code, so the field names don't need
to be consistent (of course it's nicer if they are the same).

one minor issue is that in principle this is a posix api and the
header is supposed to work with any c99 compiler, but unnamed
union and struct members are not c99. in practice i don't think
this is an issue: all loongarch c compilers will support it
and glibc already relies on extensions (like attribute aligned).

i'm not against the patch, but to me the commit message implied
the change was because of musl, while it is for being more
consistent with linux uapi and other targets.

      reply	other threads:[~2023-04-06 11:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 12:01 caiyinyu
2023-04-04 17:38 ` Szabolcs Nagy
2023-04-06  9:59   ` caiyinyu
2023-04-06 11:02     ` Szabolcs Nagy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZC6mxCuIiAy2doPy@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=caiyinyu@loongson.cn \
    --cc=libc-alpha@sourceware.org \
    --cc=lixing@loongson.cn \
    --cc=wanghonghu@loongson.cn \
    --cc=wuxiaotian@loongson.cn \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).