Custom stack to call C function
Moritz Warning
moritzwarning at web.de
Sun Jun 20 04:01:51 PDT 2010
Hi,
I need to call a C function from D.
No problem so far, but here is the catch:
The function signature is only known at runtime.
There is the void* pointer to the C-function
and void* pointers to the argument values + value size.
Now I need to build up the call stack myself.
How can it be done (maybe without assembler?).
Here is a first try, but D puts the length and pointer of part2
onto the stack as well.
uint part1; //C vararg functions need a least one fixed argument
ubyte[64] part2;
...
auto fp = cast(extern(C) void(uint x, ...)) func_ptr;
fp(part1, part2);
More information about the Digitalmars-d
mailing list