Re: ver 4.0 calling convention information ?

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

I need to know the following:

Is there more than one TYPE of routine_id returned from Euphoria ?
If so what creates each TYPE and when is it used ?

I need to know the calling conventions and who is responsible for
cleaning the stack for the following routines.

            Euphoria call type     routine receiving call\\  
CALL_FUNC  ( std or cdecl call ) ( clean stack for return ? )\\   
C_FUNC     ( std or cdecl call ) ( clean stack for return ? )\\  
CALL       ( std or cdecl call ) ( clean stack for return ? )\\   

There are two kinds of routine_ids, one returned by routine_id() and used by call_func() and call_proc(), and the other returned by define_c_func() and define_c_proc() and used by c_func() and c_proc().

You shouldn't need to worry about calling conventions here, but if you're curious the calling convention used by call_func() and call_proc() is euphoria specific. (The C backend stores the parameters and return value into special internal values and keeps track as it jumps around the IL code.) c_func() and c_proc() can use either STDCALL or C_DECL, which convention is used depends on a flag that is attached to the routine_id() returned by define_c_func() and define_c_proc() (you can force C_DECL on windows by prepending the function name with a '+').

Finally, you can call call_back() (with a routine_id() routine id) to get an address that is callable by call(). Likewise, you can use define_c_var() in place of either define_c_func() or define_c_proc() to get an address that can then be passed to call().

If using call(), you have to worry about calling convention. call_back() wraps tthe euphoria routine_id() with special code that assumes the C_DECL calling convention.

As to whether or not you need to clean the stack, that depends on STDCALL vs C_DECL. (The euphoria internal calling convention has no stack per-see to speak of that would need cleaning up.)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu