On Saturday 19 July 2003 12:51 am, Ross Paterson wrote:
Could the meaning of stdcall be broadened to "the standard calling convention for libraries on the native system", i.e. pascal on Win32 (as now) and ccall on Unix? It would save a lot of fuss for interfaces to portable libraries.
If I understand you correctly:
1) Even on Win32, a function defined with type:
rty foo(argtys)
should be called using stdcall.
I don't think that's true. The default calling convention on Windows is still ccall (known as __cdecl to the C compiler), it's just that cross-DLL calls are normally done using the __stdcall calling convention. On Windows, functions in the C runtime are called using the __cdecl calling convention. I just tested this by checking the assembly generated for calling malloc(). Although __stdcall is used more often than __cdecl for library calls on Windows, it doesn't seem to be used exclusively (someone correct me if I'm wrong). So I'd say that specifying a "default" calling convention which maps to stdcall on Windows and ccall on Unix is probably a bad idea. You've just got to know which one to use on Windows - this is the job for a tool which checks the FFI decls against the prototypes. Cheers, Simon
On Tue, Jul 22, 2003 at 12:15:44PM +0100, Simon Marlow wrote:
[Windows uses both __cdecl and __stdcall]
So I'd say that specifying a "default" calling convention which maps to stdcall on Windows and ccall on Unix is probably a bad idea. You've just got to know which one to use on Windows - this is the job for a tool which checks the FFI decls against the prototypes.
The proposal was to have this in addition to ccall. This convention is currently called CALLCONV in the network, GLUT and OpenGL packages, with hacks to turn it into ccall or stdcall. I think it makes sense to regularize it as stdcall.
Dnia wto 22. lipca 2003 13:52, Ross Paterson napisał:
The proposal was to have this in addition to ccall. This convention is currently called CALLCONV in the network, GLUT and OpenGL packages, with hacks to turn it into ccall or stdcall. I think it makes sense to regularize it as stdcall.
In gcc on Unix you can declare a function as "stdcall" and it will change the calling convention accordingly. I don't know of any library that uses it, but this shows that "stdcall" is used as a name of this particular calling convention for ix86 even on Unix. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/
well, for one, you might actually want to link against some pascal libraries on unix. and hence need stdcall. although, that would probably require other FFI extensions anyway. Another case where it might be useful is that it is not unheard of to link against windows DLLs on unix. that is how mplayer is able to use windows codecs to play video for instance. John On Tue, Jul 22, 2003 at 02:02:18PM +0200, Marcin 'Qrczak' Kowalczyk wrote:
Dnia wto 22. lipca 2003 13:52, Ross Paterson napisał:
The proposal was to have this in addition to ccall. This convention is currently called CALLCONV in the network, GLUT and OpenGL packages, with hacks to turn it into ccall or stdcall. I think it makes sense to regularize it as stdcall.
In gcc on Unix you can declare a function as "stdcall" and it will change the calling convention accordingly. I don't know of any library that uses it, but this shows that "stdcall" is used as a name of this particular calling convention for ix86 even on Unix.
-- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/
_______________________________________________ FFI mailing list FFI@haskell.org http://www.haskell.org/mailman/listinfo/ffi
-- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - john@foo.net ---------------------------------------------------------------------------
On Tue, Jul 22, 2003 at 02:02:18PM +0200, Marcin 'Qrczak' Kowalczyk wrote:
Dnia wto 22. lipca 2003 13:52, Ross Paterson napisa?:
The proposal was to have this in addition to ccall. This convention is currently called CALLCONV in the network, GLUT and OpenGL packages, with hacks to turn it into ccall or stdcall. I think it makes sense to regularize it as stdcall.
In gcc on Unix you can declare a function as "stdcall" and it will change the calling convention accordingly. I don't know of any library that uses it, but this shows that "stdcall" is used as a name of this particular calling convention for ix86 even on Unix.
OK, so the thing I want shouldn't be called stdcall, but it would be useful (and is already being used).
On Tuesday 22 July 2003 3:20 pm, Ross Paterson wrote:
OK, so the thing I want shouldn't be called stdcall, but it would be useful (and is already being used).
Yes to both. Especially so if any other platform has two commonly used calling convention. -- Alastair
participants (5)
-
Alastair Reid -
John Meacham -
Marcin 'Qrczak' Kowalczyk -
Ross Paterson -
Simon Marlow