float.c 649 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* This file is part of the GNU plotutils package. */
  2. /*
  3. * Copyright (C) 1982-1994, Nicholas B. Tufillaro. All rights reserved.
  4. *
  5. * GNU enhancements Copyright (C) 1996, 1997, 2005, 2008, Free Software
  6. * Foundation, Inc.
  7. */
  8. #include "sys-defines.h"
  9. #include <signal.h>
  10. #include "ode.h"
  11. #include "extern.h"
  12. /*
  13. * arithmetic exceptions (e.g., floating point errors) come here
  14. */
  15. RETSIGTYPE
  16. fptrap (int sig)
  17. {
  18. rterror ("arithmetic exception");
  19. }
  20. void
  21. setflt (void)
  22. {
  23. if (signal (SIGFPE, SIG_IGN) != SIG_IGN)
  24. signal (SIGFPE, fptrap);
  25. }
  26. void
  27. resetflt (void)
  28. {
  29. if (signal (SIGFPE, SIG_IGN) != SIG_IGN)
  30. signal (SIGFPE, SIG_DFL);
  31. }