Wrapping around stdcall

Marcus Meissner marcus at jet.franken.de
Tue Jul 5 15:49:23 CDT 2005


On Tue, Jul 05, 2005 at 10:16:08PM +0200, Felix Nawothnig wrote:
> Marcus Meissner wrote:
> >>I wonder how I can do this cleaner (Meaning no compiler warnings without
> >>ugly hacks). Also I would like to know how to call a function like
> >>__thiscall_fnTextSrv_TxSendMessage, because some methods I need are
> >>implemented in windows' stdcall. And I would like to know wether
> >>include/textserv.h needs to be adjusted now that I know they are not 
> >>WINAPI.
> >Adding "thiscall" to gcc would perhaps help in the long run ... :/ Fun fun 
> >fun...
> 
> Considering that gcc already knows regparm and we just need regparm(1) 
> with ecx instead eax hacking in "thiscall" for C code shouldn't be too 
> hard I think.
> 
> But since this would be a very Wine-specific hack I doubt it would get 
> into GCC. The right way would probably to extend the regparm attribute 
> to allow specifying arbitrary registers...

On second thought... What about abusing the "regparm(3)" attribute for this.

It gets eax, edx, ecx, stackparam1, stackparam2, ...

So what about using a construct like this (cloaked in some macros)?

#define THISCALL0(name,this) __thiscall_#name(int unused_eax,int unused_edx, void *this)
#define THISCALL1(name,this,p1) __thiscall_#name(int unused_eax,int unused_edx, void *this, int p1)

---------compile with gcc -S to check assembler ------------
extern void g(int);

__attribute__((__regparm__(3),__stdcall__))
void f(int unused_eax,int unused_edx, int this, int p1, int p2, int p3)
{
	g(this);
	g(p1);
	g(p2);
	g(p3);
}
---------compile with gcc -S to check assembler ------------

Evil, yes.

Ciao, Marcus



More information about the wine-devel mailing list