This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Problems using builtin_apply...


I am attempting to use the GCC extensions
builtin_apply_args
builtin_apply
builtin_return

The function that I am trying to call is located in a DLL which uses that
stdcall calling convention. So I have written the following code.

void * native;
int arg_size;
int result;

int __stdcall function(int, int, int);

int __stdcall function(int a,int b,int c)
{
  void * args = NULL;
  void * result = NULL;

  args = __builtin_apply_args();
  result = __builtin_apply( native, args, arg_size);
  __builtin_return (result);
}

void callFunction(void * funcAddress, int size);
{
  native = funcAddress;
  arg_size = size;
  result = function( 10, 20, 30 );
}

When I examine the stack wihtin function I see the following stack:

Address : value
---------------
1297768 : 10
1297772 : 20
1297776 : 30
1297780 : 268567121

as I expect. The arguments are in the right places, and the return address
is below them. However when I look at the stack within the DLL function I
see the following:

Address : value     : comment
-----------------------------
1297548 : 1297564   : Address of where stack top SHOULD be
1297552 : 1297768   : Address of where stack top USED to be
1297556 : 12        : The value of arg_size
1297560 : 268564995 : A return address
1297564 : 10        : The stack values.
1297568 : 20
1297572 : 30

If I pass less than 12 to the function I do not get a call into the DLL.
If I pass more than 12 the only thing that changes is the number 12 in the
second stack.

Any suggestions on what I am doing wrong, or how to procede?

Thanks,
Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]