Re: [xml] The NaN dilemma

[ This is a reply to a private email by robert. I am posting on
  the mailing-list, because my mailserver refuses to send mail
  directly to robert (I assume it doesn't like the all-digit
  hostname). ]

I have attached a test program that can be used to examine the
problem further. Compile with and without -DLOOP_FOREVER. If you
do find any detailed explanation of what is going on I would like
to hear about it (currently I assume that the default signal
handler is re-installed after the first ignored SIGFPE is met to
prevent the FPU from causing an infinite loop).
#if defined(__GNUC__) && defined(__i386__)

#include <stdio.h>
#include <float.h>
# include <fpu_control.h>
#include <signal.h>

double pinf(void) { return DBL_MAX + DBL_MAX; }
double ninf(void) { return -pinf(); }
double nan(void) { return pinf() + ninf(); }

void SignalCatcher(int signo)
  fprintf(stderr, "SignalCatcher(%d)\n", signo);

int main(void)
  fpu_control_t cw;
  struct sigaction action;

  action.sa_flags = SA_RESTART;
  action.sa_handler = SignalCatcher;
  action.sa_handler = SIG_IGN;
  sigaction(SIGFPE, &action, NULL);

  /* Unmask Invalid Operation */
  cw &= ~(_FPU_MASK_IM);

  printf("%f\n", pinf());
  printf("%f\n", ninf());
  printf("%f\n", nan());

  return 0;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]