Subject: RE: SML-NJ for CygWin32
From: [email-masked] (Gary Fuehrer)

21 Aug 1997 22:04:36 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <6CC63E2E4FC1D011A2A700609716117A266F0A.cygnus.gnu-win32@seawolf>
Mime-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Original-To: "[email-masked]'" <[email-masked]>
Original-Cc: "'Denis Trcek'" <[email-masked]>
X-Priority: 3
X-Mailer: Internet Mail Service (5.0.1458.49)
Original-Sender: [email-masked]

I have now successfully gotten SML-NJ 109.30 to build and run under
CygWin32.  To accomplish this, changes had to be made to both cygwin.dll
(the winsup project) as well as to the SML-NJ runtime source code.  The
changes to SML-NJ are just to add the necessary settings for the
CygWin32 platform.  I am now attempting to get the SML-NJ team to
incorporate those changes.  Because they are just additional settings to
support another platform, I anticipate the SML-NJ team will gladly
accept them.

The changes in winsup included a bug fix in mmap.cc and a patch to
exception.cc which adds functionality.  Another bug, the one I reported
below in gcc's preprocessor, has a workaround for the purposes of this
porting effort, but it would be very nice to get it fixed also.  Below
is my original posting to this news group and how I resolved or worked
around each one.

Here is my current list of issues and questions concerning CygWin32:

1. Will the preprocessor bug in the CygWin32 build of gcc be fixed in
beta 19? (see description of bug in point 1. of previous message below).

2. Will my fix for the mmap bug I described in my posting to gnu-win32
on 8/12/97 entitled "mmap(,,,MAP_PRIVATE,,) bug and fix" be incorporated
in beta 19?

3. What can we do to add my patch in exception handling that provides
the sig_info and sigcontext optional arguments to signal handlers like
is done in every other flavor of Unix?  Without intending any offense to
anyone at all, I might say that the exception handling code in the beta
18 exception.cc is rather poor and lacks the usual optional argument I
need (see point 2. of previous message below).  I know exception
handling has changed (improved) in beta 19.  I also know that Sergey
Okhapkin has some patches to the exception code in beta 18.  And now I
have a patch that adds the optional arguments and fixes another bug
(which I haven't yet reported).  Is there some way that the various
knowledgeable parties involved in the changes to exception.cc can
coordinate in order to get a "much better" version checked into beta 19?
At the very least, could we see the current beta 19 version of
exception.cc?

Thank you,
Gary

> ----------
> From: 	Geoffrey Noer[SMTP:[email-masked]]
> Sent: 	Thursday, July 24, 1997 2:03 AM
> To: 	Gary Fuehrer
> Cc: 	[email-masked]
> Subject: 	Re: FW: SML-NJ for CygWin32
> 
> I'm really sorry, but I'm not going to be able to look into this
> in detail.  Beta 19 when it comes out will fix a lot of
> signals-related
> issues so that may help.  But several of the calls you are missing
> still
> haven't been implemented yet so it won't solve all of your problems...
> -gjn
> 
> Gary Fuehrer wrote:
> > 
> > I am attempting to get Standard ML of New Jersey (version 109.29)
> built
> > and working under CygWin32 (version b18).  CygWin32 is excellent,
> and
> > I'm having only minor difficulties getting this to happen.  Would
> > someone consider the following problems I'm having and give me some
> > feedback as to how resolvable/impossible they might be?
> > 
> > 1.  SML-NJ builds an assembler source file by passing a bunch of
> macro
> > definitions and statements through gcc's preprocessor.  For x86,
> certain
> > assembly statements need to have a dollar sign before a numeric
> constant
> > (e.g. movl	$3, %eax).  Combined with C language macros, the
> > following kind of statements get passed to gcc when building the
> SML-NJ
> > runtime executable:
> > 	#define REQ_CALLC   3
> > 	:
> > 	movl	$REQ_CALLC, %eax
> > 
> > The expected output of the preprocessor is:
> > 	movl	$3, %eax
> > 
> > With the CygWin32 version of gcc, I get the following:
> > 	movl	$REQ_CALLC, %eax
> > 
> > It looks as if the dollar sign is being interpreted as part of the
> name
> > of a symbol, which is then not defined as a macro and hence remains
> > un-expanded.  In demonstration of this, I can add a space separator
> > between the dollar sign and the macro and things work:
> > 	movl $ REQ_CALLC, %eax  ==> preprocessor ==>  movl $ 3, %eax
> > 
> > This is clearly incorrect behavior on the part of CygWin's gcc.
> Dollar
> > signs are not valid leading characters of C (or C++) identifiers.
> > 
Until this is fixed in the preprocessor, the work-around for building
SML-NJ is to add a space separator between the "$" and the constant.  I
will NOT submit this change to the SML-NJ team.  They would likely
reject it anyhow (I would).

> > 
> > 2.	The signal handling in CygWin32 doesn't let me do the following:
> > a.	Get and Set the "eip" register (or any register) of the
> > excepting thread.
> > b.	Ascertain the kind of floating point exception that occurred.
> > The need is for "siginfo_t" and "sigcontext" parameters that can be
> > optionally received and modified by signal handlers.
I have a patch for exception.cc in winsup to add this functionality and
fix a related bug.

> > 
> > 3.	There is no SIGVTALRM signal.
SML-NJ doesn't seem to need this in order to function.  For now, I'm
providing a dummy #define.

> > 
> > 4.	"L_ctermid" is not defined (but "L_cuserid" is).
I don't remember why SML-NJ needs this.  For now, I'm providing a dummy
#define.  It's not critical.

> > 
> > 5.	The following definitions are not in the Posix sockets include
> > files (only the Windows socket stuff)
> > 	#    define SO_SNDBUF       0x1001          /* send buffer size
> > */
> > 	#    define SO_RCVBUF       0x1002          /* receive buffer
> > size */
> > 	#    define SO_SNDLOWAT     0x1003          /* send low-water
> > mark */
> > 	#    define SO_RCVLOWAT     0x1004          /* receive low-water
> > mark */
> > 	#    define SO_SNDTIMEO     0x1005          /* send timeout */
> > 	#    define SO_RCVTIMEO     0x1006          /* receive timeout
> > */
> > 	#    define SO_ERROR        0x1007          /* get error status
> > and clear */
> > 	#    define SO_TYPE         0x1008          /* get socket type
> > */
I don't remember why SML-NJ needs this.  For now, I'm providing dummy
#defines.  It's not critical.

> > 
> > 6.	This header file doesn't exist:
> > 			#include <netinet/tcp.h>
I don't remember why SML-NJ needs this.  For now I'm leaving it out.
It's not critical.

> > 
> > 7.	The following functions, declared in CygWin's header files, fail
> > to link:
> > 	getnetbyname
> > 	getnetbyaddr
> > 	fpgetround
> > 	fpsetround
> > 	pause
> > 	getgroups
> > 	ctermid
> > 	mkfifo
> > 	fchown
> > 	fpathconf
> SML-NJ doesn't seem to need these to funcion.  I made a mistake about
> needing fpsetround and fpgetround.  Some others are in beta 19 (ie
> getgroups, pause, fpathconf).  Posix library funcionality in SML-NJ
> for CygWin32 is reduced by what remains unimplemented (getnetbyname,
> getnetbyaddr, mkfifo, fchown, ctermid).
> 
> > 
> > 
> > I would appreciate any information you can give me on how these
> problems
> > will be resolved in future releases of CygWin32.
> > 
> > Thanks,
> > Gary
> > 
> 
> 
> -- 
> Geoffrey Noer
> [email-masked]
> 
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".