intdiv0.m4 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # intdiv0.m4 serial 1 (gettext-0.11.3)
  2. dnl Copyright (C) 2002 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl From Bruno Haible.
  7. AC_DEFUN([gt_INTDIV0],
  8. [
  9. AC_REQUIRE([AC_PROG_CC])dnl
  10. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  11. AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
  12. gt_cv_int_divbyzero_sigfpe,
  13. [
  14. AC_TRY_RUN([
  15. #include <stdlib.h>
  16. #include <signal.h>
  17. static void
  18. #ifdef __cplusplus
  19. sigfpe_handler (int sig)
  20. #else
  21. sigfpe_handler (sig) int sig;
  22. #endif
  23. {
  24. /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
  25. exit (sig != SIGFPE);
  26. }
  27. int x = 1;
  28. int y = 0;
  29. int z;
  30. int nan;
  31. int main ()
  32. {
  33. signal (SIGFPE, sigfpe_handler);
  34. /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
  35. #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
  36. signal (SIGTRAP, sigfpe_handler);
  37. #endif
  38. /* Linux/SPARC yields signal SIGILL. */
  39. #if defined (__sparc__) && defined (__linux__)
  40. signal (SIGILL, sigfpe_handler);
  41. #endif
  42. z = x / y;
  43. nan = y / y;
  44. exit (1);
  45. }
  46. ], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
  47. [
  48. # Guess based on the CPU.
  49. case "$host_cpu" in
  50. alpha* | i[34567]86 | m68k | s390*)
  51. gt_cv_int_divbyzero_sigfpe="guessing yes";;
  52. *)
  53. gt_cv_int_divbyzero_sigfpe="guessing no";;
  54. esac
  55. ])
  56. ])
  57. case "$gt_cv_int_divbyzero_sigfpe" in
  58. *yes) value=1;;
  59. *) value=0;;
  60. esac
  61. AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
  62. [Define if integer division by zero raises signal SIGFPE.])
  63. ])