Re: define_c_func/proc and 64-bit return types

new topic     » goto parent     » topic index » view thread      » older message » newer message
ghaberek said...
jimcbrown said...

I'm not sure if you can with 4.0 .. but 4.1 actually has a C_LONGLONG type and has support for doing this builtin already.

Interesting... There is a C_DWORDLONG in std/dll.e, but it's set the same as C_DOUBLE which AFAIK returns a 64-bit floating point value. I just want a 64-bit int.

--** double 64-bits 
C_DOUBLE  = #03000008, 
--** dwordlong 64-bits 
C_DWORDLONG  = #03000008, 

That's for 4.0, not 4.1

C_DWORDLONG is the wrong constant... but strangely, C_DWORDLONG and C_LONGLONG both point to the same value in my copy of 4.1 ! I'll have to ask Matt about it sometime, when he's around...

In 4.1, C_LONGLONG is set to #03000002 - but that hex constant won't work in 4.0, since support for it is lacking in the backend.

ghaberek said...

Another problem I've run into is a series of functions that take and/or return the following structure by value!

struct x { 
    float a; 
    float b; 
    float c; 
    float d; 
} 

Now, I can pass four floats to the function quite easily, but I'm thinking this 128-bit return value may be a problem for Euphoria. getlost

So at this point I may have two options:

  1. Modify the source of the library to return int64_t and this quad-float structure by reference, then provide my custom-built library instead of the original.

  2. Write a shim library in C that links to the original library, reads the troublesome values and returns a pointer to them.

-Greg

The shim library is better, as it allows users to use your code in places where they can't update or install your modified library and have to use the original library. Also, no need to rebuild the shim library everytime a new version of the original comes out.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu