public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* wide function pointer type
@ 2021-10-10 11:32 Martin Uecker
  2021-10-17 23:35 ` Anthony Green
  0 siblings, 1 reply; 28+ messages in thread
From: Martin Uecker @ 2021-10-10 11:32 UTC (permalink / raw)
  To: libffi-discuss



Hi all,

I will propose a wide function pointer type (actually
a wide function type) to WG14 for C23 as a common 
type for callbacks, closures, which now require an
additional void pointer argument in C APIs. This
is intended to be compatible with ABIs with now
use a static chain register.

An early draft can be found here:

http://wwwuser.gwdg.de/~muecker1/wide_v4.pdf


I thought you might be interested and I would love
to hear your feedback.

Martin




^ permalink raw reply	[flat|nested] 28+ messages in thread
* Re: wide function pointer type
@ 2021-10-10 17:01 Kaz Kylheku (libffi)
  2021-10-10 17:44 ` Martin Uecker
  0 siblings, 1 reply; 28+ messages in thread
From: Kaz Kylheku (libffi) @ 2021-10-10 17:01 UTC (permalink / raw)
  To: Martin Uecker; +Cc: libffi-discuss

On 2021-10-10 04:32, Martin Uecker via Libffi-discuss wrote:
> Hi all,
> 
> I will propose a wide function pointer type (actually
> a wide function type) to WG14 for C23 as a common
> type for callbacks, closures, which now require an
> additional void pointer argument in C APIs. This
> is intended to be compatible with ABIs with now
> use a static chain register.

Opposed. There is nothing wrong with separate arguments
for function pointer and context.

Higher level languages that interface C or are built on C
do not agree on an exact representation for closures;
it's not a good idea to second guess them. Many languages
are perfectly able, in their implementations, to represent
function callable objects of all sorts using ordinary
pointer-sized reference values. What those values refer to
varies quite a bit.

Callback mechanisms are often bound to OOP-style objects
rather than closures. The same context pointer is
associated with more than one callback.

The context argument has the right flexibility to cover
all the situations that arise.

In some library API's, the object pointer is registered
separately, and then other functions implicitly use it
when invoking callbacks, so it doesn't have to be passed
any more.

Sometimes there are multiple callbacks, but one context
pointer, passed in one call:

   initiate_operation(arg, callback_context,
                      get_data_fn, progress_fn);

Should there be a triple wide pointer just to roll three
arguments into one?


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2021-10-21  9:48 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-10 11:32 wide function pointer type 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
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)

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).