<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><div id="yiv1878505494">Dear all,<br>actually I have found on The Modula-3 book of Harbison that it is expected to be exported safe INTERFACEs from safe and also UNSAFE MODULES, but the programmer should take care of the tournarounds of some failing ("not type safe checked") operations in the later case that could end crashing the entire systems without checked runtime error.<br>I agree that some important needs of this procedures are highly dependent on the platform/system specific helper procedures (please take a look of the old fashioned m3tohtml web page of http://www.cs.tut.fi/lintula/manual/modula3/m3sources/html/os/src/POSIX/FilePosix.m3.html of how the Unix operating system dependent UNSAFE INTERFACEs are isolated from the helper Procedures of Unix/POSIX platform for FilePosix UNSAFE MODULE and then become accesable through a safe FilePosix
INTERFACE).<br>In fact this is supposed to disallow unchecked runtime errors as much as is possible to happen (maybe just at the most
operating system and specific level that is on m3core and not ever in libm3 which I think may be more secure than just type safe checked as I mentioned).<br>Definitely we need platform low level handling, say POSIX, WIN32 (possibly new WIN64 nowadays) specific code, but to do that is good rule of the thumb have the unsafe code like in those days of a huge number of supported operating system code (for UNIX and later for WIN32 platforms) that tells the system history.<br>Actually the Modula-3 compiler wouldn't be able to tell anything about C and if I'm not misunderstanding nor misinterpreting this mechanism of Modula-3 UNSAFE INTERFACE-UNSAFE MODULE -safe INTERFACE if I can make such a name was used to avoid unchecked runtime errors happened at pure Modula-3 parts of the system (such as libm3), and maybe a little more beyond that, having defined platform specific and operating system low level interfaces which can be more easily reworked.<br>You can
read about this issue a bit more on the Partial Revelations article about safety issue http://modula3.elegosoft.com/pm3/pkg/modula3/src/discussion/partialRev.html .<br>Apart of that, I don't know if you would like the kind of documentation is reported on the SRC M3 generated file more than the corresponding one in nowadays (not produced every day I guess) http://opencm3.net/doc/help/gen_html/libm3/src/os/POSIX/FilePosix.m3.html I think could be useful to get back the same style of documentation procedures and correspondent files on this platform specific files (might be helpful to know where are the correspondant Interfaces on WIN platform as It wasn't on back days http://www.cs.tut.fi/lintula/manual/modula3/m3sources/html/os/src/WIN32/FileWin32.m3.html ).<br><br>Happy holidays and hope this helps a bit more.<br><br><br>--- El <b>lun, 22/12/08, Mika Nystrom <i><mika@async.caltech.edu></i></b> escribió:<br><blockquote
style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">De: Mika Nystrom <mika@async.caltech.edu><br>Asunto: Re: [M3devel] Rv: Re: serial/Cygwin was Re: [M3commit] FilePosixC.c<br>Para: "Jay" <jay.krell@cornell.edu><br>CC: mika@camembert.async.caltech.edu<br>Fecha: lunes, 22 diciembre, 2008
10:49<br><br><pre>I think Daniel has a point. He said "UNSAFE", not<br>"unsafe". "UNSAFE"<br>means something very specific in Modula-3, and operations that are<br>UNSAFE are only permitted to be exported by UNSAFE INTERFACEs and<br>hence only can be used in UNSAFE MODULEs. <br><br>If, however, there are UNSAFE interfaces in non-UNSAFE INTERFACEs, that<br>is a problem that really shouldn't be allowed to get worse.<br><br>This is all covered in sections 1.4.5 and 2.1 of the Green Book.<br>I'm not sure exactly what you guys are talking about but I would<br>appreciate it if I could rely on the Green Book for programming in<br>Modula-3....<br><br>Not everything that's <*EXTERNAL*> is UNSAFE, by the way. It is<br>perfectly possible for a routine coded in C or Fortran to export a<br>non-UNSAFE Modula-3 interface. Conversely, a Modula-3 MODULE can<br>definitely export an UNSAFE interface.<br><br>I think if you interpret section 2.1 a bit loosely,
but<br> I think<br>still within the spirit of the authors' intent, you can go as far<br>as to say that it's OK to introduce UNSAFE code (even in non-UNSAFE<br>interfaces) as long as the program needs to use at least one UNSAFE<br>INTERFACE in order to trigger the error. The contrapositive of<br>this is that it should not be possible for a Modula-3 program that<br>imports only non-UNSAFE interfaces to cause an unchecked runtime<br>error. Ever.<br><br>Some examples...., in the following, assume that CrashHorribly<br>can cause an unchecked runtime error when called.<br><br>INTERFACE A; TYPE T = BRANDED ROOT; END A.<br>UNSAFE INTERFACE B; IMPORT A; TYPE T <: A.T; END B.<br>UNSAFE INTERFACE C; IMPORT A; PROCEDURE CrashHorribly(arg : A.T); END C.<br><br>This is OK since an importer has to be UNSAFE to trigger CrashHorribly.<br><br>INTERFACE A; TYPE T = BRANDED ROOT; END A.<br>INTERFACE B; IMPORT A; TYPE T <: A.T; END B.<br>UNSAFE INTERFACE C; IMPORT
A;<br> PROCEDURE CrashHorribly(arg : A.T); END C.<br><br>Still OK, an importer still has to be UNSAFE to trigger CrashHorribly.<br><br>INTERFACE A; TYPE T = BRANDED ROOT; END A.<br>UNSAFE INTERFACE B; IMPORT A; TYPE T <: A.T; END B.<br>INTERFACE C; IMPORT A; PROCEDURE CrashHorribly(arg : A.T); END C.<br><br>Might be OK, as long as the only way to get an unchecked runtime<br>error in C is by passing in a B.T. If you can get an unchecked<br>runtime error in C.CrashHorribly without importing B (say by passing<br>in a bare A.T or a "home-made" subtype of A), it's wrong.<br><br>INTERFACE A; TYPE T = BRANDED ROOT; END A.<br>INTERFACE B; IMPORT A; TYPE T <: A.T; END B.<br>INTERFACE C; IMPORT A; PROCEDURE CrashHorribly(arg : A.T); END C..<br><br>Definitely wrong.<br><br> Mika<br><br><br>Jay writes:<br>>--_4c4a182e-6ca9-4b3c-a937-0fea11bffd83_<br>>Content-Type: text/plain; charset="iso-8859-1"<br>>Content-Transfer-Encoding:<br>
quoted-printable<br>><br>><br>>The real world is unsafe.Safe areas are created by unsafe code=2C which<br>mus=<br>>t be=2C to a certain extent=2C bug free=2C in order to provide as safe as<br>a=<br>>dvertised. I don't believe what I added is any more untrusted/unsafe<br>than =<br>>what was there before.Well=2C maybe in a minor way. m3core has<br>"lots" of "=<br>>external" functions=2C which are called by "lots" of<br>functions at higher le=<br>>vels..ok=2C maybe not "lots"=2C but if you look at the<br>m3core/src/unix dire=<br>>ctories that I have worked on -- cygwin=2C openbsd=2C amd64_linux=2C<br>linux-=<br>>common -- this is a fairly minimal set of stuff that is being used by<br>preex=<br>>isting code. A LITTLE bit I added beyond what was there. If you look at<br>all=<br>> the other directories=2C you'll find lots more external stuff=2C most<br>of w=<br>>hich is not used within the CM3 codebase (but could
be<br> used by folks<br>outsid=<br>>e). It is true I may have introduced external where it wasn't<br>previously=<br>>=2C but I don't think it matters.It is prevalent one level down. Moving<br>som=<br>>e of it one level up is ok I believe. =20<br>>Non-Posix does potentially have a place in .c files.It<br>depends.Basically=2C=<br>> as I see things=2C a small amount of #ifdef is ok.A lot of #ifdef becomes<br>=<br>>hard to read=2C and at some point=2C you split the files into separate<br>file=<br>>s=2C "no" #ifdefs -- or conceptually each file can be viewed as<br>wrapped in =<br>>an #ifdef or other platform detection.You need #ifdef in any C that uses<br>64=<br>> bit integers=2C for example. Current Microsoft compilers do support<br>"long =<br>>long" but __int64 supporg goes way back=2C and __int64 is a better<br>name any=<br>>way.<br>>What is the 128 bit integer type to be called -- "__int128" or<br>"long long<br>
l=<br>>ong".<br>>=20<br>>=20<br>>The names "char"=2C "short"=2C "int"=2C<br>"long"=2C "long long" are mostly ju=<br>>st funny mistaken names.<br>>The right names to provide are explicitly sized=2C int8=2C uint8=2C int16=<br>>=2C uint16=2C int32=2C uint32=2C int64=2C uint64=2C and pointer sized<br>types=<br>> such as "size_t" and "diff_t".<br>>Modula-3 I think is reasonable here=2C since it's primary integral type<br>is =<br>>pointer sized=2C and it has "bits x for ..."=2C though the other<br>types prob=<br>>ably ought to be built in and blessed somewhere=2C not just in the<br>Csupport=<br>> library section.<br>>=20<br>>Not sure what "Posix" means=2C since it might incorporate<br>by-reference ANSI=<br>> C.<br>>=20<br>> - Jay<br>><br>><br>><br>>Date: Sat=2C 20 Dec 2008 00:09:41 +0000From: dabenavidesd@yahoo.esTo:<br>m3dev=<br>>el@elegosoft.comSubject: [M3devel] Rv: Re: serial/Cygwin
was<br> Re:<br>[M3commit]=<br>> FilePosixC.c<br>><br>><br>><br>>Dear all:I'm glad that Jay and all the people around are making<br>contributio=<br>>ns=2C so we can claim that as some day there were a good number of<br>supporte=<br>>d platforms nowadays we also have.However I have a question=2C but its<br>more=<br>> a suggestion=2C the modification Tony is referring is not as standard as<br>w=<br>>e would like since the type safety is affected with the change introduced<br>a=<br>>llowing <*EXTERNAL*> (untrusted) functions in the INTERFACE<br>FilePosix=2C it=<br>>'s an implementation issue of the CM3 (IMHO it should warn) compiler=2C<br>so =<br>>we may want to mark as UNSAFE INTERFACE=2C however doing that I think some<br>=<br>>clients could not claim any more they are safe so that "fix" is<br>not feasib=<br>>le.Can you push to a lower level (as in the UNSAFE FilePosix<br>implementation=<br>> module
before<br> committing the change) or make it available in other<br>Interfa=<br>>ce already available=2C why do we need that change anyway? Also IMHO we<br>sh=<br>>ould leave out what is not POSIX (we should not care for WIN64 although I<br>k=<br>>now is needed by the C compiler preprocessor) out of that file.Although I<br>d=<br>>on't have the formal specification or program=2C but I can remember<br>libm3 c=<br>>ode was specified and mechanically checked with the Extended Static<br>Checker=<br>> Modula-3 (which is not sound also=2C that is could be cheated=2C see<br>http:=<br>>//www.researchchannel.org/prog/displayevent.aspx?rID=3D2761&fID=3D345<br>)=2C =<br>> that would be a good reason for keeping as safe as possible and close to<br>h=<br>>istorical interfaces and just rework implementations (even if they are not<br>=<br>>safe) as needed. I know that implementation is not safe but at least<br>having=<br>> it well
enough<br> implemented the ESC/M3 checker and the compiler would tell<br>=<br>>us the library should work Ok and is safe and (hopefully) without the<br>error=<br>>s detected by the ESC as we care for the details in the UNSAFE<br>implementati=<br>>on.There are any special interfaces we should have as "standard"<br>in the low=<br>>er level runtime (hard enough question I know)=2C can we give some<br>hints/id=<br>>eas on that?Thanks in advance--- El vie=2C 19/12/08=2C Jay<br><jay.krell@corne=<br>>ll.edu> escribi=F3:<br>>De: Jay <jay.krell@cornell.edu>Asunto: Re: [M3devel]<br>serial/CygwinPara: "m3=<br>>devel" <m3devel@elegosoft.com>=2C "Tony"<br><hosking@cs.purdue.edu>Fecha: vier=<br>>nes=2C 19 diciembre=2C 2008 1:25> And I'll fix SOLsun/gnu.I /think/<br>it is o=<br>>k now -- changing my "ino_t" to"m3_ino_t".I'm still<br>checking though.And I o=<br>>nly checked SOLgnu. I will check SOLsun. -
Jay<br> =<br>><br>>--_4c4a182e-6ca9-4b3c-a937-0fea11bffd83_<br>>Content-Type: text/html; charset="iso-8859-1"<br>>Content-Transfer-Encoding: quoted-printable<br>><br>><html><br>><head><br>><style><br>>.hmmessage P<br>>{<br>>margin:0px=3B<br>>padding:0px<br>>}<br>>body.hmmessage<br>>{<br>>font-size: 10pt=3B<br>>font-family:Verdana<br>>}<br>></style><br>></head><br>><body class=3D'hmmessage'><br>>The real world is unsafe.<BR>Safe areas are created by unsafe code=2C<br>which=<br>> must be=2C to a certain extent=2C bug free=2C in order to provide as safe<br>=<br>>as advertised.<BR> =3B<BR> =3B<BR>I<br>don't believe what I added is a=<br>>ny more untrusted/unsafe than what was there before.<BR>Well=2C maybe<br>in a =<br>>minor way.<BR> =3B<BR> =3B<BR>m3core
has<br>"lots" of<br> "external" funct=<br>>ions=2C which are called by "lots" of functions at higher<br>levels..ok=2C may=<br>>be not "lots"=2C but if you look at the m3core/src/unix<br>directories that I =<br>>have worked on -- cygwin=2C openbsd=2C amd64_linux=2C linux-common -- this<br>=<br>>is a fairly minimal set of stuff that is being used by preexisting code. A<br>=<br>>LITTLE bit I added beyond what was there. If you look at all the other<br>dire=<br>>ctories=2C you'll find lots more external stuff=2C most of which is not<br>use=<br>>d within the CM3 codebase (but could be used by folks<br>outside).<BR> =3B=<br>><BR> =3B<BR>It is true I may have introduced external<br>where it wasn't p=<br>>reviously=2C but I don't think it matters.<BR>It is prevalent one<br>level dow=<br>>n. Moving some of it one level up is ok
I<br>believe. =3B<BR> =3B<BR><br>><BR>Non-Posix<br> does potentially have a place in .c files.<BR>It<br>depends.<BR>=<br>>Basically=2C as I see things=2C a small amount of #ifdef is ok.<BR>A<br>lot of=<br>> #ifdef becomes hard to read=2C and at some point=2C you split the files<br>in=<br>>to separate files=2C "no" #ifdefs -- or conceptually each file<br>can be viewe=<br>>d as wrapped in an #ifdef or other platform detection.<BR>You need<br>#ifdef i=<br>>n any =3BC that uses 64 bit integers=2C for example. Current<br>Microsoft&=<br>>nbsp=3Bcompilers do support "long long" but __int64 supporg goes<br>way back=<br>>=2C and __int64 is a better name anyway.<BR><br>>What is the 128 bit integer type to be called -- "__int128" or<br>"long long l=<br>>ong".<BR><br>> =3B<BR><br>> =3B<BR><br>>The names "char"=2C
"short"=2C "int"=2C<br>"long"=2C =3B"long long" =<br>>=3Bare mostly just<br> funny mistaken names.<BR><br>>The right names to provide are explicitly sized=2C<br>int8=2C =3Buint8=2C =<br>>int16=2C uint16=2C int32=2C uint32=2C int64=2C uint64=2C and pointer sized<br>=<br>>types such as "size_t" and "diff_t".<BR><br>>Modula-3 I think is reasonable here=2C since it's primary integral type<br>is =<br>>pointer sized=2C and it has "bits x for ..."=2C though the other<br>types prob=<br>>ably ought to be built in and blessed somewhere=2C not just in the<br>Csupport=<br>> library section.<BR><br>><BR> =3B<BR><br>>Not sure what "Posix" means=2C since it might incorporate<br>by-reference ANSI=<br>> C.<BR><br>> =3B<BR><br>> =3B<BR> =3B-<br>Jay<BR><BR><BR><BR><br>><br>><HR
id=3DstopSpelling><br>><BR><br>><BR>Date: Sat=2C 20 Dec 2008 00:09:41<br> +0000<BR>From:<br>dabenavidesd@yahoo.es<=<br>>BR>To: m3devel@elegosoft.com<BR>Subject: [M3devel] Rv: Re:<br>serial/Cygwin wa=<br>>s Re: [M3commit] FilePosixC.c<BR><BR><BR><BR><br>><TABLE cellSpacing=3D0 cellPadding=3D0 border=3D0><br>><TBODY><br>><TR><br>><TD vAlign=3Dtop>Dear all:<BR>I'm glad that Jay and all the<br>people around a=<br>>re making contributions=2C so we can claim that as some day there were a<br>go=<br>>od number of supported platforms nowadays we also have.<BR>However I<br>have a=<br>> question=2C but its more a suggestion=2C the modification Tony is<br>referrin=<br>>g is not as standard as we would like since the type safety is affected<br>wit=<br>>h the change introduced allowing
<=3B<SPAN<br>class=3DEC_current-rev>*</SPAN=<br>>>EXTERNAL<SPAN<br> class=3DEC_current-rev>*</SPAN>>=3B<br>(untrusted) functions =<br>>in the INTERFACE FilePosix=2C it's an implementation issue of the CM3<br>(IMHO=<br>> it should warn) compiler=2C so we may want to mark as UNSAFE INTERFACE=2C<br>=<br>>however doing that I think some clients could not =3B claim any<br>more th=<br>>ey are safe so that "fix" is not feasible.<BR>Can you push<br>to a lower level=<br>> (as in the UNSAFE FilePosix implementation module before committing the<br>ch=<br>>ange) or make it available in other Interface already available=2C why do<br>w=<br>>e need that change anyway? =3B Also IMHO we should leave out what<br>is no=<br>>t POSIX (we should not care for WIN64 although I know is needed by the C<br>co=<br>>mpiler preprocessor) out of that file.<BR>Although I don't have<br>the
formal =<br>>specification or program=2C but I can remember libm3 code was<br> specified<br>and=<br>> mechanically checked with the Extended Static Checker Modula-3 (which is<br>n=<br>>ot sound also=2C that is could be cheated=2C see<br>http://www.researchchannel=<br>>.org/prog/displayevent.aspx?rID=3D2761&=3BfID=3D345 )=2C =3B<br>that wo=<br>>uld be a good reason for keeping as safe as possible and close to<br>historica=<br>>l interfaces and just rework implementations (even if they are not safe)<br>as=<br>> needed. I know that implementation is not safe but at least having it<br>well=<br>> enough implemented the ESC/M3 checker and the compiler would tell us the<br>l=<br>>ibrary should work Ok and is safe and (hopefully) without the errors<br>detect=<br>>ed by the ESC as we care for the details in the UNSAFE<br>implementation.<BR>T=<br>>here are any special interfaces we should have as "standard"
in<br>the lower l=<br>>evel runtime (hard enough question I know)=2C can we give<br> some hints/ideas<br>=<br>>on that?<BR>Thanks in<br>advance<BR><BR><BR><BR>--- El <B>vie=2C<br>19/12/08=2C J=<br>>ay <I><=3Bjay.krell@cornell.edu>=3B</I></B><br>escribi=F3:<BR><br>><BLOCKQUOTE style=3D"PADDING-LEFT: 5px=3B MARGIN-LEFT:<br>5px">De: Jay <=3Bj=<br>>ay.krell@cornell.edu>=3B<BR>Asunto: Re: [M3devel]<br>serial/Cygwin<BR>Para: =<br>>"m3devel" <=3Bm3devel@elegosoft.com>=3B=2C<br>"Tony" <=3Bhosking@cs.purd=<br>>ue.edu>=3B<BR>Fecha: viernes=2C 19 diciembre=2C 2008<br>1:25<BR><BR><PRE>>=<br>>=3B And I'll fix SOLsun/gnu.<BR><BR>I /think/ it is ok now<br>-- changing my "=<br>>ino_t" to<BR>"m3_ino_t".<BR>I'm still<br>checking though.<BR>And I only
checke=<br>>d SOLgnu. I will check SOLsun.<BR> <BR> -<br> Jay<BR><br></PRE></BLOCKQUOTE><BR></=<br>>TD></TR></TBODY></TABLE><BR></body><br>></html>=<br>><br>>--_4c4a182e-6ca9-4b3c-a937-0fea11bffd83_--<br></pre></blockquote></div></td></tr></table><br>