This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: SML-NJ for CygWin32


Gary Fuehrer wrote:
> > > 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.

I hope you made modifications in call_handler() and wrap assembly code? 
Current sources  contains all you need to implement this functionality:

  res = SuspendThread (OurhThread);
  debug_printf ("suspend said %d error %d\n", res, GetLastError());
  orig.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
  res = GetThreadContext (OurhThread, &orig);

  unsigned int *sp = (unsigned int *) orig.Esp;
  *(--sp) = orig.Eip;	/*  rethere = orig.Eip;*/
  orig.Eip = (unsigned) &&wrap;

  *(--sp) = oldmask;
  *(--sp) = n;
  *(--sp) = (DWORD) pfunc;
  orig.Esp = (DWORD) sp;
  SetThreadContext (OurhThread, &orig); /* Restart the thread */
  ResumeThread (OurhThread);
  /* It looks like a bug in Windows NT, but several waiting threads are not
     always released on SetEvent() without this sleep...
  */
  Sleep(1);
  PulseEvent (signal_arrived);
  WSACancelBlockingCall();
  return;
  /* This code is run in the standard thread space */
  /* Commented out instructions are emulated already */
 wrap:
  asm ("orl	$0x0,(%esp)\n"  /* probe out enough room to play */
      "orl	$0x0,-0x800(%esp)\n"
      "orl	$0x0,-0x1000(%esp)\n"
//      "pushl	_rethere\n"
//      "pushl 	_oldmask\n"
//      "pushl 	_sigarg\n"
//      "pushl 	_sigfunc\n");
      "pusha\n"
      "pushf\n"
      "pushl 	%ebp\n"
      "movl 	%esp,%ebp\n"
      "pushl	0xb*4(%ebp)\n"		// sigarg
      "movl	0xa*4(%ebp),%eax\n"	// sigfunc
      "call 	*%eax\n"
      "pushl	0xc*4(%ebp)\n"		// oldmask
      "call	_set_process_mask\n"
      "leave\n"
      "popf\n"
      "popa\n"
      "popl	_rethere\n"
      "popl	_rethere\n"
      "popl	_rethere\n"
      "ret");

The saved integer registers are accessible from signal handler. Save float 
context just near pusha/pushf and modify sigarg/sigfunc/oldmask offsets.

> > > 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.

I don't know how to implement virtual timer on win32.

> > > 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.

L_ctermid define should be added to stdio.h, and ctermid() call should be 
added to winsup sources for POSIX conformance.

> > > 5.	The following definitions are not in the Posix sockets include
> > > files (only the Windows socket stuff)

The missing defines already added to headers.


--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia
Looking for a job

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]