From: Martin Uecker <ma.uecker@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Martin Uecker via Libffi-discuss <libffi-discuss@sourceware.org>,
Anthony Green <green@moxielogic.com>
Subject: Re: wide function pointer type
Date: Wed, 20 Oct 2021 11:21:06 +0200 [thread overview]
Message-ID: <1f0500640675adfdc4c911987f68f307b2993407.camel@gmail.com> (raw)
In-Reply-To: <878ryoxdsn.fsf@oldenburg.str.redhat.com>
Am Mittwoch, den 20.10.2021, 11:10 +0200 schrieb Florian Weimer:
> * Martin Uecker:
>
> > One (of several) use cases is for language interoperability.
> >
> > A common problem is to pass a function of a high-level
> > language as a callback to an C API. This now often
> > requires special boiler plate code for each case and
> > there is no automatic way to do this. The fundamental
> > problem is that the C type can not express that a data
> > pointer belongs to a function pointer.
> >
> > void foo(
> > void (cb1)(void* data, int a), void* data1,
> > void* other_data);
> >
> > Here a human (and maybe also a machine) could guess
> > that data1 belongs to cb1 but not other_data. But
> > it is not clear and in more complicated cases
> > even less so.
> >
> > void foo(void (_Wide cb1)(int a), void* other_data);
> >
> >
> > With the new type that would be unambiguous (and
> > wrappers could then often be created automatically).
> > At least for the C API one would also expect ABI
> > stability.
>
> I don't expect a lot of uptake for this. One problem is the suggested
> aggregate representation of wide function pointers. It's not exactly
> common for non-C implementations to implement those aspects of the
> platform C ABI.
Can you explain what you mean by this? Usually non-C
implementations build on C ABI, so if the C ABI is
extended the extension is then available to them.
I would expect a lot of update (in the long run) because
there is now a 1:1 mapping for a function pointer
type in other languages to the function type in C.
> For many targets, even C and C++ compilers do not
> always agree completely on the finer points.
Unfortunately, e.g. atomics. But the goal and intention
is interoperability.
> Passing code and data pointer in separate arguments is
> much more robust, and safely within the
> interoperable ABI subset.
It is not my experience that the void pointer based
APIs are robust and safe.
> Perhaps a set of standard attributes to describe the explicit closure
> argument would be useful, though.
I also thought about this (and this could be added
too) but this does not solve all problems.
Martin
next prev parent reply other threads:[~2021-10-20 9:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-10 11:32 Martin Uecker
2021-10-17 23:35 ` Anthony Green
2021-10-18 5:33 ` Martin Uecker
2021-10-18 5:58 ` Martin Uecker
2021-10-18 7:36 ` Florian Weimer
2021-10-18 7:56 ` Martin Uecker
2021-10-19 9:22 ` Florian Weimer
2021-10-19 9:43 ` Martin Uecker
2021-10-19 10:15 ` Florian Weimer
2021-10-19 12:13 ` Martin Uecker
2021-10-20 8:24 ` Kaz Kylheku (libffi)
2021-10-20 18:52 ` Martin Uecker
2021-10-20 9:10 ` Florian Weimer
2021-10-20 9:21 ` Martin Uecker [this message]
2021-10-20 9:27 ` Florian Weimer
2021-10-20 17:27 ` Kaz Kylheku (libffi)
2021-10-21 9:48 ` Florian Weimer
2021-10-10 17:01 Kaz Kylheku (libffi)
2021-10-10 17:44 ` Martin Uecker
2021-10-10 17:49 ` Daniel Colascione
2021-10-10 18:05 ` Martin Uecker
2021-10-10 18:17 ` Daniel Colascione
2021-10-10 18:47 ` Martin Uecker
2021-10-10 18:57 ` Daniel Colascione
2021-10-10 19:24 ` Martin Uecker
2021-10-16 8:08 ` Jarkko Hietaniemi
2021-10-16 9:35 ` Jarkko Hietaniemi
2021-10-10 18:31 ` Kaz Kylheku (libffi)
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=1f0500640675adfdc4c911987f68f307b2993407.camel@gmail.com \
--to=ma.uecker@gmail.com \
--cc=fweimer@redhat.com \
--cc=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).