Wrapping around stdcall

Maarten Lankhorst m.b.lankhorst at gmail.com
Thu Jul 7 11:00:41 CDT 2005


To suppress warnings from my thiscall wrapped stuff, I came up with this
solution, playing around a little with #define's:

#ifdef __i386__  /* thiscall functions are i386-specific */

#ifdef __GNUC__
/* GCC erroneously warns that the newly wrapped function
 * isn't used, lets help it out of it's thinking
 */
#define SUPPRESS_NOTUSED __attribute__((used))
#else
#define SUPPRESS_NOTUSED
#endif /* __GNUC__ */

#define WRAP_THISCALL(type, func, parm) \
    extern type func parm; \
    __ASM_GLOBAL_FUNC( func, \
                      "popl %eax\n\t" \
                      "pushl %ecx\n\t" \
                      "pushl %eax\n\t" \
                      "jmp " __ASM_NAME("__wrapped_" #func) ); \
    SUPPRESS_NOTUSED static type __wrapped_ ## func parm
#else
#define WRAP_THISCALL(functype, function, param) \
    functype function param
#endif

Declaration of function is now like this:
WRAP_THISCALL(HRESULT __stdcall, fnTextSrv_TxSendMessage, (ITextServices
*iface, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT* plresult))
{
....
}

In the vtable I can now just use the function names as I declared them n
the wrap.

Lets hope julliard forgives me.

Maarten



More information about the wine-devel mailing list