calc.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <unistd.h>
  2. #include <signal.h>
  3. #include <grass/calc.h>
  4. /****************************************************************************/
  5. volatile int floating_point_exception;
  6. volatile int floating_point_exception_occurred;
  7. int columns;
  8. /****************************************************************************/
  9. static RETSIGTYPE handle_fpe(int n)
  10. {
  11. floating_point_exception = 1;
  12. floating_point_exception_occurred = 1;
  13. }
  14. void pre_exec(void)
  15. {
  16. #ifndef __MINGW32__
  17. #ifdef SIGFPE
  18. struct sigaction act;
  19. act.sa_handler = &handle_fpe;
  20. act.sa_flags = 0;
  21. sigemptyset(&act.sa_mask);
  22. sigaction(SIGFPE, &act, NULL);
  23. #endif
  24. #endif
  25. floating_point_exception_occurred = 0;
  26. }
  27. void post_exec(void)
  28. {
  29. #ifndef __MINGW32__
  30. #ifdef SIGFPE
  31. struct sigaction act;
  32. act.sa_handler = SIG_DFL;
  33. act.sa_flags = 0;
  34. sigemptyset(&act.sa_mask);
  35. sigaction(SIGFPE, &act, NULL);
  36. #endif
  37. #endif
  38. }
  39. /****************************************************************************/
  40. void calc_init(int cols)
  41. {
  42. columns = cols;
  43. }
  44. /****************************************************************************/