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]

Divide by zero fails to produce SIGFPE


Is it possible to get cygwin32 to respond to
division by zero with SIGFPE?

I ported Yorick 1.4, ran the self test and got the
following error message:

  "**WARNING** 1.0/0.0 does not trigger SIGFPE"

In fact, division by zero yields "Inf".
For Yorick to run reliably, division by zero
*must* yield SIGFPE.

Quite a few systems fail to produce SIGFPE, and
the Yorick distribution comes with a patch for
most of them. Unfortunately cygwin32 is not included.
Now I searched the cygwin32 tree for "divide by zero"
and found in +++/i386-cygwin32/include/ieeefp.h:

  [...]
  /* EXCEPTIONS */
  typedef int fp_except;
  #define FP_X_INV 0x10	/* Invalid operation   */
  #define FP_X_DX  0x80	/* Divide by zero      */
  #define FP_X_OFL 0x04	/* Overflow exception  */
  #define FP_X_UFL 0x02	/* Underflow exception */
  #define FP_X_IMP 0x01	/* imprecise exception */
  [...]

Yorick has a patch for Solaris which reads:

  #include < ieeefp.h >
    fpsetmask(FP_X_INV | FP_X_DZ | FP_X_OFL);

However, cygwin32 does not seem to include the
fpsetmask function. (And what about the difference
between FP_X_DX and FP_X_DZ? Is this a typo?)

I contacted David Munro (munro@icf.llnl.gov), author
of Yorick. He was interested in the cygwin32 port,
but unaware of a way to get cygwin32 to produce
SIGFPE. However, he did send me a program to test
for proper divide by zero handling. It is attached
to this mail. I can't get it to produce SIGFPE.
Perhaps someone better versed in C than I could give
it a shot.

Thanks and best wishes,

Tijs
m.h.m.michels@kub.nl

Ps: Apart from this, Yorick works great!
-
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]