public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Anthony Green <green@moxielogic.com>
To: libffi-discuss <libffi-discuss@sourceware.org>
Subject: Change in libffi behaviour -- large struct args
Date: Sat, 28 May 2022 09:40:15 -0400	[thread overview]
Message-ID: <CACxje5_m_6U0UyQYeo7p6+TRtybAE7LdovUUTvP6yGH0QV6YEw@mail.gmail.com> (raw)

As has been discussed in various github PRs recently, I'd like to
change libffi's behaviour regarding large struct arguments.

When passing a struct by value, most (all?) ABI definitions ask that
you try to fit structs up to a certain size into registers, and if
they are too large, make a copy and pass them on the stack.
Libffi's current behaviour is to fit small structs in registers, but
then if something is too large, pass it by reference, leaving it as an
exercise for the user to make their own copies.   Many libffi users,
like cpython, do this special work themselves.   I don't like this
because it exposes this ABI detail, the threshold for struct sizes, to
the libffi caller.   Libffi should be making this copy itself.

The struct_by_value_big.c test checks for this, and most ports fail
today   Changing this behaviour won't introduce regressions for libffi
users, and eventually they will be able to remove their special
handling of large struct args.

AG

             reply	other threads:[~2022-05-28 13:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-28 13:40 Anthony Green [this message]
2022-05-28 15:38 ` dancol
2022-05-28 15:50   ` Anthony Green
2022-05-29 14:09 ` Anthony Green
2022-05-31 15:53 ` DJ Delorie
2022-05-31 16:47   ` dancol
2022-05-31 16:55     ` Kaz Kylheku
2022-05-31 18:59   ` Anthony Green
2022-05-31 23:16     ` DJ Delorie

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=CACxje5_m_6U0UyQYeo7p6+TRtybAE7LdovUUTvP6yGH0QV6YEw@mail.gmail.com \
    --to=green@moxielogic.com \
    --cc=libffi-discuss@sourceware.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).