[M3devel] religion, philosophy, Posix vs. Win32

Jay jayk123 at hotmail.com
Mon Jan 14 05:39:19 CET 2008


I agree cross-buildability is nice. That is something NT-non-GNU will never have to the extent that NT-GNU would have, other than cross building from Windows x86 <=> Windows AMD64, etc., or NT => CE, or NT <=> 9x, which is all a fairly large set of cross combinations that do work..
 
You can have portability at one or more layers..and all that.
How many/much do you want?
At the Modula-3 level and at the C level and at the command line human interface/"scripting" level (for scripting, just use Quake or Perl or Python, really).
 
For now my priority is using the gcc backend and the associated as and ld and possibly dlltool.
And buildability of the gcc backend which requires much more, but is easy enough, I cross that bridge days ago.
 
For some reason the gcc produced mklib.exe crashes at startup, I believe here:C:\dev2\cm3.2\m3-libs\m3core\src\runtime\common\RTLinker.m3(81):      IF (imp.import = NIL) THEN  imp.import := imp.binder (0);  END;or here:
C:\dev2\cm3.2\m3-libs\m3core\src\runtime\common\RTLinker.m3(182):        IF (imp.import = NIL) THEN  imp.import := imp.binder (0);  END;
imp.binder is NULL. I'm sure there was a check for NULL followed by a jump to NULL and recall the callstack was to around here.
 
You can actually debug it with gdb. :)
That was kind of nice.
I'm not sure about looking at globals -- info globals just said I had void pointers, but at least I could see the stack.
 
Not that I must use mklib, but I was considering it, and it should work....
 
32 bit time_t is a nightmare waiting to happen.
Have folks upgraded to 64 bit time_t?
Win32, depending on the layer, supports 32 bit time_t seconds since 1970, 64 bit time_t I assume with the same start, and 64 bit time since 1601 something like 100's of nanoseconds, low enough precision to have a plenty large range (i.e. it isn't measuring 4 billionths of seconds and therefore would have already run out. :) )
Having time start at 1970 can be a bit inconenient. It is fine for the timestamps on files, but, e.g. for birthdays?
Admittedly 1601 isn't adequate either for historical purposes, and eventually, if you are dealing with history, the Gregorian calendar runs out back in time and things get even much more complicated. :)
 
 - Jay


Date: Mon, 14 Jan 2008 03:32:37 +0100From: dabenavidesd at yahoo.esSubject: Re: [M3devel] religion, philosophy, Posix vs. Win32To: mika at async.caltech.edu; jayk123 at hotmail.comCC: m3devel at elegosoft.comHi all,Yes, I also noticed the Time.T issue in pm3 1.1.15 because I was trying to get compiled m3browser and I finally arranged to do that, but the program just broke, and I didn't know about cygwin differences against a real UNIX platform.Also in that pm3 NT386GNU, the winvbt implementation was the one of dec-src not like current cm3 winvbt (that use WIDECHAR as I remember)I tried to have the same interfaces to be able to use from m3browser.Now fortunately you can compile m3browser with NT386 cm3 platform.I just liked very much the way one can make a bootstrap from pm3 from one platform to another and make a minimal compiler for NT386GNU:http://tkb.mpl.com/~tkb/software/misc/pm3-NT386GNU.patchI couldn't repeat the above link instructions in a Debian Sarge machine, with all the pm3 Debian packages installed (available in the Debian Woody http://archive.debian.org/pool/main/p/pm3/ ) I think the reason was I was unable to do all the bootstrap process http://archive.debian.org/pool/main/p/pm3-i386I would like to have that kind of posix to cygwin capability of port at least a minimal compiler/runtime system.Also, talking  about the topic of port NT386 to NT386GNU (more than a year ago) I got some answer from Bert Laverman, 
Daniel Benavides wrote: 
> What if we use the cygwin platform to run cm3, an use its runtime 
> of linker and c Compiler? 
"Normally this involves a speed penalty, because cygwin will emulate 
a UNIX environment, and has to translate this to Windows calls. The 
advantage is of course that you can ignore most differences between 
Windows and UNIX. 
If you don't want the speed penalty, and can take care of the 
platform differences, then you can use the -mno-cygwin flag. However, 
make sure you use only "real" Windows API calls." 

Bert LavermanThanksMika Nystrom <mika at async.caltech.edu> escribió:
Jay,I don't know if this is completely responsive to your question, andtake it with a grain of salt because I have never programmed on a"pure" Windows system (and God willing, I never shall).I expect the NT386GNU target, Cygwin, Windows-POSIX, whatever youcall it, to look as much as Unix "as possible." (Obviously not,but as "reasonable".) The main things are (1) yes, /bin/sh, and(2) Unix (POSIX?) libc---Modula-3 does a good job of covering upthe basic stuff so you don't need to worry about it for the mostpart, but sometimes, just sometimes, you need to get, say, somesystem information that doesn't have an existing M3 interface (saythe amount of free diskspace or something like that). Then youshould be able to call C code that is portable between Unix andWindows.One thing that is bizarre about the old NT386GNU PM3 that doesn'tconform to the above description: it uses Windows Time.T. It's allthe more bizarre because Cygwin uses Unix time_t. (Time.Now andtime(3) are off by a couple of hundred years on NT386GNU, whereasthey are the same on all Unixes.) I am sure there are other things.Oh yes, the open-file (default) locking semantics are differenttoo. Those two are actually the only differences that I noticedin the programming environments.MikaJay writes:>--_d0659847-2f20-454a-9665-5df3b5ce2832_>Content-Type: text/plain; charset="iso-8859-1">Content-Transfer-Encoding: quoted-printable>>The conclusion here is:> Just try to convince me otherwise. :)>>The gist of the question is:> Just what characteristics of "Posix" and "Win32" should "NT386GNU" have?>> Just what characteristics of "Posix" do people notice and like?>You can't say "the whole thing". :)>>Restated:>>What is Posix? I don't mean, where is the standard document web site.>I mean what is it TO YOU?>>Is it open/read/write/close?>Is it fork?>Is it sbrk?> On these previous ones, they are interesting to many programmers,> but Modula-3 already layers over all this, so these are unlikely defining>characteristics here.>>Is it sh? Probably somewhat. But if have you sat in Cygwin sh much vs. cmd?> It is annoying. Command line history is flaky. Paths are munged to say /cy=>gdrive.> You lose the critical F8 command line completion against history feature.> You lose a lot of editing capability, but do gain some alternate possibly=> "portable"> similar.>>Is it Perl? No.>Is it X Windows. I doubt it.>Is it pthreads? Probably not.> Or at least vtalarm? Maybe?> Or setjmp/longjmp? Ok.> Longjmp to the same buffer multiple times? Not likely.> Longjmp to a place that has already returned? Not likely.>All full paths starting with a forward slash? Maybe.> Backward slash being a valid non-seperator path character? Maybe.>>Think about that last one.>It is valid and occurs in Win32 code to treat forward slash and backward sl=>ash the same.>Some code does, some code does not.>What if you just did that unconditionally, like even in Posix?>What is the role of backward slash in Posix paths? It either just doesn't o=>ccur,>or is an escape character, or is a regular character. Something at a low le=>vel>could replace the backward slashes with forward slashes.>>I would like to change the code in m3-sys/cm3/m3path.m3 to treat backward s=>lashes>and forward slashes the same. Backward slashes just won't occur on Posix, r=>ight?>So far I have managed without this change, but not having it has bitten me =>a few times.>I do have the analogous change to the Win32 path code in m3core.>>It is the redundant filenames libfoo.a instead of foo.lib and libfoo.so ins=>tead of foo.so?>Perhaps. This seems dumb, redundant to me. Why have prefixes and suffixes?>Don't suffixes suffice?>>That all said, I remain convinced that a useful intermediate or probably en=>dpoint>is a toolset that targets Windows using cm3cg, ld, as, but otherwise looks =>like>NT386 as much as possible. MAYBE alter the library names to libfoo.*.>>sh and make are needed for building cm3cg.>I did use Cygwin for that. MinGWin sounds promising here too but I haven't =>tried.>> - Jay>>>_________________________________________________________________>Get the power of Windows + Web with the new Windows Live.>http://www.windowslive.com?ocid=3DTXT_TAGHM_Wave2_powerofwindows_012008=>>--_d0659847-2f20-454a-9665-5df3b5ce2832_>Content-Type: text/html; charset="iso-8859-1">Content-Transfer-Encoding: quoted-printable>>>>

>>The conclusion here is: Just try to conv=>ince me otherwise. :)The gist of the question is:  Just wh=>at characteristics of "Posix" and "Win32" should "NT386GNU" have?&n=>bsp;Just what characteristics of "Posix" do people notice and like?You =>can't say "the whole thing". :)Restated:What is Posix? I do=>n't mean, where is the standard document web site.I mean what is it TO =>YOU?Is it open/read/write/close?Is it fork?Is it sbrk?&=>nbsp; On these previous ones, they are interesting to many programmers,=> but Modula-3 already layers over all this, so these are unlikely defi=>ningcharacteristics here.Is it sh? Probably somewhat. But if ha=>ve you sat in Cygwin sh much vs. cmd? It is annoying. Command line=> history is flaky. Paths are munged to say /cygdrive. You lose the=> critical F8 command line completion against history feature.  You=> lose a lot of editing capability, but do gain some alternate possibly "por=>table"  similar.Is it Perl? No.Is it X Windows. I doub=>t it.Is it pthreads? Probably not.  Or at least vtalarm? Maybe=>?  Or setjmp/longjmp? Ok.    Longjmp to the sam=>e buffer multiple times? Not likely.    Longjmp to a pla=>ce that has already returned? Not likely.All full paths starting with a=> forward slash? Maybe.  Backward slash being a valid non-seperator=> path character? Maybe.Think about that last one.It is valid an=>d occurs in Win32 code to treat forward slash and backward slash the same.<=>br>Some code does, some code does not.What if you just did that uncondi=>tionally, like even in Posix?What is the role of backward slash in Posi=>x paths? It either just doesn't occur,or is an escape character, or is =>a regular character. Something at a low levelcould replace the backward=> slashes with forward slashes.I would like to change the code in m3=>-sys/cm3/m3path.m3 to treat backward slashesand forward slashes the sam=>e. Backward slashes just won't occur on Posix, right?So far I have mana=>ged without this change, but not having it has bitten me a few times.I =>do have the analogous change to the Win32 path code in m3core.It is=> the redundant filenames libfoo.a instead of foo.lib and libfoo.so instead =>of foo.so?Perhaps. This seems dumb, redundant to me. Why have prefixes =>and suffixes?Don't suffixes suffice?That all said, I remain con=>vinced that a useful intermediate or probably endpointis a toolset that=> targets Windows using cm3cg, ld, as, but otherwise looks likeNT386 as =>much as possible. MAYBE alter the library names to libfoo.*.sh and =>make are needed for building cm3cg.I did use Cygwin for that. MinGWin s=>ounds promising here too but I haven't tried. - Jay> />

Get the power of Windows + Web with the new Windows Live. >=3D'http://www.windowslive.com?ocid=3DTXT_TAGHM_Wave2_powerofwindows_012008=>' target=3D'_new'>Get it now!>=>>--_d0659847-2f20-454a-9665-5df3b5ce2832_--


Web Revelación Yahoo! 2007:Premio Favorita del Público - ¡Vota tu preferida!
_________________________________________________________________
Watch “Cause Effect,” a show about real people making a real difference.
http://im.live.com/Messenger/IM/MTV/?source=text_watchcause
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080114/05b01af4/attachment-0002.html>


More information about the M3devel mailing list