Re: How to catch integer 64 bit return variable type

new topic     » goto parent     » topic index » view thread      » older message » newer message

Juergen Luethje wrote:
> 
> D. Darmawan wrote: 
myAPIfunc = define_c_func(myDLL, "desired_function", {C_POINTER}, C_LONG)

x = c_func(myAPIfunc, {lpMyVar1})

 
> > 
> > Now, my question is: 
> > How to catch the 64bit integer return value from myAPIfunc and assign it
> > into
> > 'x' variable???
> 
> I see. Unfortunately, for this case I don't have a solution.
> However, if we declare the problem "insoluble", then Matt will solve it. :)

Sure, no pressure, right? :)

My solution would be to either write a wrapper dll, or to call the dll
with something along the lines of fptr.e.  With either method, I'd
return the value to a memory buffer that would be read by something 
like Juergen's peek8 routine.

So a C-based wrapper function might look something like:

void myAPIfuncWrapper( long long * retval, int * api_param ){
    *retval = myAPIfunc(api_param);
}

I found this:
http://www.ecos.sourceware.org/ml/gdb/2000-q1/msg00660.html
2. As far as I can tell, all i386 targets return `long long' values in
   eax (low word) and edx (high word).  This makes sense since this is
   the convention used by the machine instructions themselves.  The
   relevant GCC code suggests that in addition to eax and edx, ecx
   might also be used for 12-byte values (then edx is the "middle"
   word, and ecx the high word).  But since GCC doesn't have a 12-byte
   integer type (would that make sense?) this should never occur.
   However, the full 12-byte range is used for returning extended
   floating-point numbers (`long double').  Right now this is only
   implemented for AIX, Linux and DJGPP, but this should be made more
   general.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu