<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
<FONT size=2>
>> But why would you have platform-dependent pragmas in code that is not platform-dependent?<BR>
<BR>
<BR>
example of mostly portable + pragma:<BR>
<BR>
<BR>
hand.c:<BR>
<BR>
#if !defined(_MSC_VER) && !defined(__stdcall)<BR>
#define __stdcall /* nothing */<BR>
#endif<BR>
<BR>
void __stdcall set_singleton<BR>
ANSI(( ulong a, ulong* s))<BR>
KR((a, s) ulong a; ulong* s;)<BR>
{<BR>
ulong a_word = a / SET_GRAIN;<BR>
ulong a_bit = a % SET_GRAIN;<BR>
s[a_word] |= (1UL << a_bit);<BR>
}<BR>
<BR>
<BR>
(gcc on Windows #defines __stdcall to __attribute__(something))<BR>
<BR>
<BR>
Not the best example -- this function doesn't seem well motivated.<BR>
We probably need a CG.i3 function to do div and mod in one go, since<BR>
the processors usually expose that. <BR>
Though this case is with a constant power of two, so..<BR>
And m3front would be a little pressed to notice the opportunity?<BR>
<BR>
<BR>
- Jay</FONT><BR><BR> <BR>
<HR id=stopSpelling>
From: hosking@cs.purdue.edu<BR>Date: Mon, 22 Feb 2010 11:01:57 -0500<BR>To: jay.krell@cornell.edu<BR>CC: m3devel@elegosoft.com; darko@darko.org<BR>Subject: Re: [M3devel] calling conventions (small proposal)<BR><BR><BASE>Pragmas should never give errors.
<DIV>If you are proposing that all platforms recognise the pragmas, but most do nothing with them, then I guess OK. But why would you have platform-dependent pragmas in code that is not platform-dependent?</DIV>
<DIV><BR>
<DIV><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="WORD-WRAP: break-word"><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV><FONT class=ecxApple-style-span color=#0000ff><FONT class=ecxApple-style-span face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span>Antony Hosking</SPAN></SPAN></FONT></FONT><FONT class=ecxApple-style-span face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN class=ecxApple-converted-space> </SPAN>|<SPAN class=ecxApple-converted-space> </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span>Associate Professor</SPAN></SPAN><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'" class=ecxApple-style-span> | Computer Science | Purdue University</SPAN></SPAN></FONT></DIV>
<DIV><FONT class=ecxApple-style-span face=GillSans-Light><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span>305 N. University Street | West Lafayette | IN 47907 | USA</SPAN></FONT></DIV>
<DIV><FONT class=ecxApple-style-span color=#0000ff face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span>Office</SPAN></SPAN></FONT><FONT class=ecxApple-style-span face=GillSans-Light><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span> +1 765 494 6001 |<SPAN class=ecxApple-converted-space> </SPAN></SPAN></SPAN></FONT><FONT class=ecxApple-style-span color=#0000ff face="Gill Sans"><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span><SPAN style="FONT-FAMILY: 'Gill Sans'; COLOR: rgb(0,0,255)" class=ecxApple-style-span>Mobile</SPAN></SPAN></FONT><FONT class=ecxApple-style-span face=GillSans-Light><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span><SPAN style="FONT-FAMILY: GillSans-Light" class=ecxApple-style-span><SPAN class=ecxApple-converted-space> </SPAN>+1 765 427 5484</SPAN></SPAN></FONT></DIV>
<DIV><FONT class=ecxApple-style-span face=GillSans-Light><BR class=ecxkhtml-block-placeholder></FONT></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN><BR class=ecxApple-interchange-newline></SPAN></DIV></SPAN></SPAN><BR class=ecxApple-interchange-newline></DIV><BR>
<DIV>
<DIV>On 22 Feb 2010, at 04:52, Jay K wrote:</DIV><BR class=ecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>I wouldn't mind<BR> - an error<SPAN class=ecxApple-converted-space> </SPAN><BR> - or a way to mark a pragma as needing an error vs. being ok with a warning<SPAN class=ecxApple-converted-space> </SPAN><BR> Though perhaps that shouldn't be a pragma but some other syntax not in <* *>.<BR> In fact, maybe this stuff doesn't belong in <* *>. I don't care much what<BR> the syntax is, but there is a legitimate need to note calling conventions,<BR> a syntax is already in use. I'd rather not invent a new syntax.<BR> <BR> <BR>The word "ignore" isn't relevant.<BR>Sorry if I was confusing.<BR>The proposal is that all targets recognize the pragmas __stdcall, __cdecl, etc.<BR>but that most platforms interpret them as doing nothing.<BR>The pragmas already exist.<BR>"Recognize and do nothing" is much different than "ignore stuff that isn't recognized".<BR> <BR> <BR> - Jay<BR> <BR>
<HR id=ecxstopSpelling>
Subject: Re: [M3devel] calling conventions (small proposal)<BR>From:<SPAN class=ecxApple-converted-space> </SPAN><A href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</A><BR>Date: Sun, 21 Feb 2010 16:52:20 -0500<BR>CC:<SPAN class=ecxApple-converted-space> </SPAN><A href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</A>;<SPAN class=ecxApple-converted-space> </SPAN><A href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</A><BR>To:<SPAN class=ecxApple-converted-space> </SPAN><A href="mailto:darko@darko.org">darko@darko.org</A><BR><BR>The compiler does continue to compile having warned that the pragma has no meaning.
<DIV><BR></DIV>
<DIV>So, yes, they are ignored, but I want a warning.</DIV>
<DIV><BR></DIV>
<DIV>I even want a warning if I write <**>.</DIV>
<DIV><BR><BR>
<DIV>
<DIV>On 21 Feb 2010, at 16:47, Darko wrote:</DIV><BR class=ecxecxApple-interchange-newline>
<BLOCKQUOTE>
<DIV style="WORD-WRAP: break-word">
<DIV>I thought that was the point of pragmas, that the compiler could freely ignore them and that they did not involve the correctness of the program.</DIV>
<DIV><BR></DIV><BR>
<DIV>
<DIV>On 22/02/2010, at 8:42 AM, Tony Hosking wrote:</DIV><BR class=ecxecxApple-interchange-newline>
<DIV style="WORD-WRAP: break-word">
<DIV><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV style="WORD-WRAP: break-word"><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: 12px Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV><SPAN style="FONT-SIZE: medium" class=ecxecxApple-style-span><FONT class=ecxecxApple-style-span color=#0000ff face="'Gill Sans'">Yes, but my point is that a pragma that has no meaning *should* give a warning. Otherwise, why did I write it.</FONT></SPAN></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DIV></SPAN></SPAN></DIV><BR>
<DIV>
<DIV>On 21 Feb 2010, at 16:16, Jay K wrote:</DIV><BR class=ecxecxApple-interchange-newline>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxecxhmmessage>To be clear, I don't propose ignoring all unrecognized pragmas.<BR>Just calling conventions.<BR>You could interpret it as:<SPAN class=ecxecxApple-converted-space> </SPAN><BR> The pragmas *are* recognized, on all targets, but they have no meaning on most.<BR> The meaning is "do nothing".<BR> <BR> <BR>Look at the situation in C for AMD64_NT. Calling conventions are accepted for compatibility<BR>with I386_NT source. And they all mean nothing. This lets people maintain<BR>one portable code base, and they *don't* even need to do so much as:<BR>#ifndef _X86_<BR>#define __stdcall /* nothing */<BR>#define __cdecl /* nothing */<BR>#define __fastcall /* nothing */<BR>#endif<BR> <BR> <BR>I'd be willing to prune the "big" list of calling conventions down to just two: __stdcall, __cdecl.<BR>The rest are a pointless proliferation of synonyms.<BR>Though that'd probably gratuitously break stuff (of course I can fix the entire cm3 tree in<BR>a few minutes, that's not the issue).<BR> <BR> <BR>Separate file would work, but I'd really rather stuff be all together.<BR>Once you separate things, one version goes stale.<BR> <BR> <BR> - Jay<BR> <BR>
<HR id=ecxecxstopSpelling>
Subject: Re: [M3devel] calling conventions (small proposal)<BR>From:<SPAN class=ecxecxApple-converted-space> </SPAN><A href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</A><BR>Date: Sun, 21 Feb 2010 15:54:13 -0500<BR>CC:<SPAN class=ecxecxApple-converted-space> </SPAN><A href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</A>;<SPAN class=ecxecxApple-converted-space> </SPAN><A href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</A><BR>To:<SPAN class=ecxecxApple-converted-space> </SPAN><A href="mailto:darko@darko.org">darko@darko.org</A><BR><BR>
<DIV>Accepting and silently ignoring sounds very dangerous!</DIV>
<DIV><BR></DIV>
<DIV>I want my compiler to warn me when I use a pragma that is unrecognised for my particular target.</DIV>
<DIV><BR></DIV>
<DIV>Silence is deadly!</DIV>
<DIV><BR></DIV>
<DIV>On 21 Feb 2010, at 15:09, Darko wrote:</DIV>
<DIV><BR class=ecxecxecxApple-interchange-newline>
<BLOCKQUOTE>
<DIV style="WORD-WRAP: break-word">
<DIV>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.</DIV>
<DIV><BR></DIV>
<DIV><BR></DIV><BR>
<DIV>
<DIV>On 21/02/2010, at 10:52 PM, Jay K wrote:</DIV><BR class=ecxecxecxApple-interchange-newline><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxecxecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxecxecxhmmessage>1) All platforms should accept, but silently ignore, the NT386/I386_CYGWIN/etc. calling conventions:<BR>at least __stdcall, and __cdecl<BR>Probably all the synonyms: C, WINAPI, CALLBACK, WINAPIV, APIENTRY, APIPRIVATE, PASCAL,<BR> <BR>This is a very small change.<BR> <BR> <BR>This is will allow:<BR> a) possibly merging the two nearly identical OpenGL.i3 files<BR> b) implementing functions in Modula-3 that are portable, but use __stdcall, possibly for perf<BR> I intend to that for hand.c's replacement, soon.<BR> <SPAN class=ecxecxecxApple-converted-space> </SPAN><BR> <BR>Maybe experiment as to the perf.<BR>__stdcall is supposed to be faster, because the code is smaller.<BR>But __cdecl might be able to compete by using stores to the stack instead of pushes?<BR> I'd have to see how that compares in size, and it does increase stack usage some.<BR> <BR> <BR>Probably not worth large scale experimenting/changing, but maybe nice to mark<BR>new functions/interfaces as __stdcall (see next point).<BR> <BR> <BR>I was actually thinking of trying flat out changing the default, but I think that is too difficult,<BR>what with all the C<=>Modula-3 transitions. And not worth it given other<BR>more valuable work to do.<BR> <BR> <BR>2) The calling convention pragmas should be allowed on an interface, to set<BR>the default for an interface.<BR> <BR>2b) and I guess as well on a module, for unexported functions<BR> <BR>I assert that other than __stdcall and __cdecl on NT386, nothing else is<BR>particularly interesting here. There is __fastcall, maybe interesting.<BR>It has different meanings to different compilers.<BR>I'd rather keep this all fairly constrained.<BR> <BR>No other platform has more than one calling convention, so this doesn't<BR>have be to further generalized. Besides, as long as no platform uses<BR>the same name to mean multiple things, ok.<BR> Mac68K Classic?<BR> Mac68K CFM?<SPAN class=ecxecxecxApple-converted-space> </SPAN><BR> Win16?<BR> MS-DOS?<BR> <BR> <BR>(I did recently acquire a working Mac68K, as well it is easily<BR> run on a modern PPC Mac; far down the list, but...)<BR> <BR> <BR> - Jay<BR></DIV></SPAN></DIV><BR></DIV></BLOCKQUOTE></DIV><BR></DIV></SPAN><BR class=ecxecxApple-interchange-newline></BLOCKQUOTE></DIV><BR></DIV></DIV><BR></DIV></BLOCKQUOTE></DIV><BR></DIV></DIV></SPAN><BR class=ecxApple-interchange-newline></BLOCKQUOTE></DIV><BR></DIV> </body>
</html>