Windows and calling convention

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Windows and calling convention

Postby marten » Sun Dec 03, 2006 11:45 pm

The more I work with external libraries, the more question do I have. VASmalltalk under Windows does only support the calling convention stdcall.

Lots of libraries (on the market) are compiled using the cdecl calling convention.

stdcall means, that the function being called has to clear the stack. cdecl means, that the caller has to clear the stack. stdcall have both right-to-left parameter passing and they both preserve the same registers for internal usage and the same register for return values.

If now VASmalltalk calls a c-routine it expects, that the function corects the stack. If it calls a cdecl c-routine, the call should work and it means, that some bytes (for parameter ...) are not corrected and I expect, that for each call some bytes are lost on the stack.

The other way around should not work: cdecl expecting functions can not call stdcall compiled functions.

And here now my question (for which I do not have an answer yet - though this problem has been discussed in the internet news group this year): Does VASmalltalk loose some bytes when calling cdecl compiled functions ? Or does VASmalltalk creates a special stack for that external call and throw it away after that call (therefore the lost bytes are meaninfless).

Marten
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Postby tc » Mon Dec 04, 2006 10:44 am

Hi Marten,

The guy would know this is out for a few days but we'll get an answer as soon as possible.

--tc
tc
Moderator
 
Posts: 304
Joined: Tue Oct 17, 2006 7:40 am
Location: Raleigh, NC

Postby marten » Thu Dec 14, 2006 9:08 am

tc wrote:Hi Marten,

The guy would know this is out for a few days but we'll get an answer as soon as possible.

--tc


Any information available ??
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany

Postby wembley » Fri Dec 15, 2006 5:19 am

Marten -

Calling a cdecl entrypoint from Smalltalk will result in leaking memory. I can't positively say that there aren't other negative side-effects of making such a call, but I am unaware of any.

I will suggest to Instantiations that providing cdecl support in PlatformFunctions would be a useful feature in a future release.

Regards, John
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC

Postby marten » Fri Feb 09, 2007 2:49 am

wembley wrote:Marten -

Calling a cdecl entrypoint from Smalltalk will result in leaking memory. I can't positively say that there aren't other negative side-effects of making such a call, but I am unaware of any.

I will suggest to Instantiations that providing cdecl support in PlatformFunctions would be a useful feature in a future release.

Regards, John


Are there any further decisions done in this direction ? After binding REXX to Smalltalk, SQLite to Smalltalk I'm now looking at GTK+, Cairo and zlib and its more or less always the same: cdecl whereever I look at .... and one must write wrapper function for each call to make it correct ....

Marten
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest