<html><head><base href="x-msg://5444/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>This is C code...</div><br><div><div>On 22 Feb 2010, at 16:10, Jay K wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; "><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.<span class="Apple-converted-space"> </span><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:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Mon, 22 Feb 2010 11:01:57 -0500<br>To:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a>;<span class="Apple-converted-space"> </span><a href="mailto:darko@darko.org">darko@darko.org</a><br>Subject: Re: [M3devel] calling conventions (small proposal)<br><br>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 class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div style="word-wrap: break-word; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div><font class="ecxApple-style-span" color="#0000ff"><font class="ecxApple-style-span" face="Gill Sans"><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; color: rgb(0, 0, 255); "><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; color: rgb(0, 0, 255); ">Antony Hosking</span></span></font></font><font class="ecxApple-style-span" face="Gill Sans"><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; "><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; "><span class="ecxApple-converted-space"> </span>|<span class="ecxApple-converted-space"> </span></span></span><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; "><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; ">Associate Professor</span></span><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; "><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; "> | Computer Science | Purdue University</span></span></font></div><div><font class="ecxApple-style-span" face="GillSans-Light"><span class="ecxApple-style-span" style="font-family: GillSans-Light; ">305 N. University Street | West Lafayette | IN 47907 | USA</span></font></div><div><font class="ecxApple-style-span" color="#0000ff" face="Gill Sans"><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; color: rgb(0, 0, 255); "><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; color: rgb(0, 0, 255); ">Office</span></span></font><font class="ecxApple-style-span" face="GillSans-Light"><span class="ecxApple-style-span" style="font-family: GillSans-Light; "><span class="ecxApple-style-span" style="font-family: GillSans-Light; "> +1 765 494 6001 |<span class="ecxApple-converted-space"> </span></span></span></font><font class="ecxApple-style-span" color="#0000ff" face="Gill Sans"><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; color: rgb(0, 0, 255); "><span class="ecxApple-style-span" style="font-family: 'Gill Sans'; color: rgb(0, 0, 255); ">Mobile</span></span></font><font class="ecxApple-style-span" face="GillSans-Light"><span class="ecxApple-style-span" style="font-family: GillSans-Light; "><span class="ecxApple-s!" tyle-span="" style="font-family: GillSans-Light; "><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 class="ecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxhmmessage" style="font-family: Verdana; font-size: 10pt; ">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 "ign! ore 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 class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div style="word-wrap: break-word; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ec!" xecxapple-style-span="" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><span class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div><span class="ecxecxApple-style-span" style="font-size: medium; "><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 class="ecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; ">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 gr! atuitously 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 class="ecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; ">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></div></span><br class="Apple-interchange-newline"></blockquote></div><br></body></html>