From: Latchesar Ionkov <lucho@gmx.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] calling function with (variable number of) parameters
Date: Wed, 20 Jun 2001 14:23:59 -0400 [thread overview]
Message-ID: <20010620142359.A1367@gmx.net> (raw)
In-Reply-To: <3B30C7C8.6A412F9E@null.net>; from DAGwyn@null.net on Wed, Jun 20, 2001 at 04:30:21PM +0000
On Wed, Jun 20, 2001 at 04:30:21PM +0000, Douglas A. Gwyn said:
> Latchesar Ionkov wrote:
> > I am trying to write a function
> > int callf(void *f, int nargs, int *args)
> > f is a pointer to a function of a type
> > int f(int, int, int, ..., int)
>
> No, it isn't; at least, not as you have declared callf.
>
> Also, that is not a proper variadic declaration for the type of f.
> I think what you mean is that the actual function definition uses
> a *fixed* number of arguments, different for different values of
> f, and you're hoping that the passed nargs happens to be
> consistent with the function that the passed f points to.
You understood what I meant, which was the purpose of the two pseudo
declarations.
> > callf should copy nargs number of ints from args to the stack and call f,
> > and then return f's return value.
>
> > Is this possible with Plan9 C calling convention? ...
> > Do I miss something? Any ideas how to implement it?
>
> It's an abuse of C under any linkage convention.
I know, but that knowledge doesn't help me.
> > Unfortunately I don't have any control on the requirements or the way f gets
> > its parameters. If there is no way to do it for any number of args, I'll
> > limit nargs (and hope nobody will write function with more than 15
> > arguments) and will modify SP with a constant value.
>
> That will probably be your best bet.
> Other solutions would require changes to the interface.
The interface is called JNI and I can't change it.
Lucho
next prev parent reply other threads:[~2001-06-20 18:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-20 14:11 Latchesar Ionkov
2001-06-20 16:30 ` Douglas A. Gwyn
2001-06-20 18:23 ` Latchesar Ionkov [this message]
2001-06-20 19:51 rog
2001-06-20 19:54 ` Latchesar Ionkov
2001-06-21 12:39 ` Douglas A. Gwyn
2001-06-21 13:48 ` Latchesar Ionkov
2001-06-21 14:13 ` Dan Cross
2001-06-21 14:33 rog
2001-06-21 15:16 ` Dan Cross
2001-06-21 15:17 ` Latchesar Ionkov
2001-06-29 22:11 ` Boyd Roberts
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=20010620142359.A1367@gmx.net \
--to=lucho@gmx.net \
--cc=9fans@cse.psu.edu \
/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 NNTP newsgroup(s).