[M3devel] calling conventions (small proposal)

Jay K jay.krell at cornell.edu
Sun Feb 21 22:16:38 CET 2010


To be clear, I don't propose ignoring all unrecognized pragmas.

Just calling conventions.

You could interpret it as: 

  The pragmas *are* recognized, on all targets, but they have no meaning on most.

  The meaning is "do nothing".

 

 

Look at the situation in C for AMD64_NT. Calling conventions are accepted for compatibility

with I386_NT source. And they all mean nothing. This lets people maintain

one portable code base, and they *don't* even need to do so much as:

#ifndef _X86_

#define __stdcall /* nothing */

#define __cdecl /* nothing */

#define __fastcall /* nothing */

#endif

 

 

I'd be willing to prune the "big" list of calling conventions down to just two: __stdcall, __cdecl.

The rest are a pointless proliferation of synonyms.

Though that'd probably gratuitously break stuff (of course I can fix the entire cm3 tree in

a few minutes, that's not the issue).

 

 

Separate file would work, but I'd really rather stuff be all together.

Once you separate things, one version goes stale.

 

 

 - Jay
 


Subject: Re: [M3devel] calling conventions (small proposal)
From: hosking at cs.purdue.edu
Date: Sun, 21 Feb 2010 15:54:13 -0500
CC: jay.krell at cornell.edu; m3devel at elegosoft.com
To: darko at darko.org


Accepting and silently ignoring sounds very dangerous!


I want my compiler to warn me when I use a pragma that is unrecognised for my particular target.


Silence is deadly!


On 21 Feb 2010, at 15:09, Darko wrote:



This is a good idea. An alternate proposal would be to put the calling conventions in an external file, but this change would seem to be the simplest and in line with the stated definition of pragamas.






On 21/02/2010, at 10:52 PM, Jay K wrote:
1) All platforms should accept, but silently ignore, the NT386/I386_CYGWIN/etc. calling conventions:
at least __stdcall, and __cdecl
Probably all the synonyms: C, WINAPI, CALLBACK, WINAPIV, APIENTRY, APIPRIVATE, PASCAL,
 
This is a very small change.
 
 
This is will allow:
  a) possibly merging the two nearly identical OpenGL.i3 files
  b) implementing functions in Modula-3 that are portable, but use __stdcall, possibly for perf
  I intend to that for hand.c's replacement, soon.
  
 
Maybe experiment as to the perf.
__stdcall is supposed to be faster, because the code is smaller.
But __cdecl might be able to compete by using stores to the stack instead of pushes?
  I'd have to see how that compares in size, and it does increase stack usage some.
 
 
Probably not worth large scale experimenting/changing, but maybe nice to mark
new functions/interfaces as __stdcall (see next point).
 
 
I was actually thinking of trying flat out changing the default, but I think that is too difficult,
what with all the C<=>Modula-3 transitions. And not worth it given other
more valuable work to do.
 
 
2) The calling convention pragmas should be allowed on an interface, to set
the default for an interface.
 
2b) and I guess as well on a module, for unexported functions
 
I assert that other than __stdcall and __cdecl on NT386, nothing else is
particularly interesting here. There is __fastcall, maybe interesting.
It has different meanings to different compilers.
I'd rather keep this all fairly constrained.
 
No other platform has more than one calling convention, so this doesn't
have be to further generalized. Besides, as long as no platform uses
the same name to mean multiple things, ok.
 Mac68K Classic?
 Mac68K CFM? 
 Win16?
 MS-DOS?
 
 
(I did recently acquire a working Mac68K, as well it is easily
 run on a modern PPC Mac; far down the list, but...)
 
 
 - Jay


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100221/66830238/attachment-0002.html>


More information about the M3devel mailing list