public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
To: gcc@gcc.gnu.org
Subject: Re: Re: [RFC] Linux system call builtins
Date: Mon, 08 Apr 2024 08:59:12 -0300	[thread overview]
Message-ID: <2852e1ff0081b5fbc3db1c3f1b627e3e@gmail.com> (raw)
In-Reply-To: <CAH6eHdRDNj7HdVC3eP=mLrwauqu6=k7NLEAVy8N-D7qU1WZseg@mail.gmail.com>"

> What's the advantage of the _1, _2 etc. forms?

Now that you mention it... I don't believe there are any.

> The compiler knows how many arguments you're passing,
> why can't there just be one built-in handling all cases?

You're right about that.

When I started working on this I just mirrored the existing
APIs which consist of one function for each possible arity.
I have always wanted a variadic system call function though
so when I saw that GCC had variadic builtins I threw one in.

A builtin doesn't have the overhead of variadic C functions though.
The compiler should be able to generate optimal code depending on
how many arguments it's called with.

It's the best possible interface and strictly superior to anything
libraries can offer.

Would other languages supported by GCC benefit from the other forms?
Perhaps variadic builtins are incompatible with them for some reason?
I can't think of any reason to keep the numbered forms otherwise.

> Your proposal doesn't seem to actually address the problem.
> If using the clone syscall causes problems for glibc by not
> giving glibc a chance to set up TLS etc for the new thread,
> how does making it easier to use the clone syscall help?

I think that problem can never be fully addressed, only worked around.
It seems to be inherent to how standard C libraries are implemented.
The C standards apparently make it impossible to avoid either global
or thread local state. Locales come to mind...

Compiler support for system calls help by eliminating the need for the
system call stub functions traditionally provided by these C libraries.
There's no need to link against the C libraries just for that anymore
and there's also no need to implement it ourselves since the compiler
provides it. The result is it makes it easier to develop freestanding
software targeting Linux.

  reply	other threads:[~2024-04-08 11:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08  9:19 Matheus Afonso Martins Moreira
2024-04-08  9:58 ` Jonathan Wakely
2024-04-08 11:59   ` Matheus Afonso Martins Moreira [this message]
2024-04-08 14:00     ` Jonathan Wakely
2024-04-08 11:24 ` Florian Weimer
2024-04-08 11:44   ` Alexander Monakov
2024-04-08 11:50     ` Florian Weimer
2024-04-08 13:01       ` Alexander Monakov
2024-04-08 13:37   ` Matheus Afonso Martins Moreira
2024-04-08 18:18 ` Paul Iannetta
2024-04-08 18:26   ` Andrew Pinski
2024-04-08 20:01     ` Paul Iannetta
2024-04-08 20:20       ` Paul Koning
2024-04-10  1:48     ` Matheus Afonso Martins Moreira
2024-04-10 13:15       ` Paul Koning
2024-04-10 14:10         ` Matheus Afonso Martins Moreira
2024-04-10  1:26   ` Matheus Afonso Martins Moreira
2024-04-08 20:24 ` Paul Floyd
2024-04-10  2:19   ` Matheus Afonso Martins Moreira
2024-04-09 11:45 ` Szabolcs Nagy
2024-04-10  2:59   ` Matheus Afonso Martins Moreira
2024-04-10 11:04     ` Szabolcs Nagy
2024-04-10 14:00       ` Matheus Afonso Martins Moreira

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=2852e1ff0081b5fbc3db1c3f1b627e3e@gmail.com \
    --to=matheus.a.m.moreira@gmail.com \
    --cc=gcc@gcc.gnu.org \
    /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).