intdiv0.m4 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # intdiv0.m4 serial 7 (gettext-0.20.2)
  2. dnl Copyright (C) 2002, 2007-2008, 2010-2020 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. gt_cv_int_divbyzero_sigfpe=
  15. changequote(,)dnl
  16. case "$host_os" in
  17. macos* | darwin[6-9]* | darwin[1-9][0-9]*)
  18. # On Mac OS X 10.2 or newer, just assume the same as when cross-
  19. # compiling. If we were to perform the real test, 1 Crash Report
  20. # dialog window would pop up.
  21. case "$host_cpu" in
  22. i[34567]86 | x86_64)
  23. gt_cv_int_divbyzero_sigfpe="guessing yes" ;;
  24. esac
  25. ;;
  26. esac
  27. changequote([,])dnl
  28. if test -z "$gt_cv_int_divbyzero_sigfpe"; then
  29. AC_RUN_IFELSE(
  30. [AC_LANG_SOURCE([[
  31. #include <stdlib.h> /* for exit() */
  32. #include <signal.h>
  33. #if !(defined _WIN32 && !defined __CYGWIN__)
  34. #include <unistd.h> /* for _exit() */
  35. #endif
  36. static void
  37. sigfpe_handler (int sig)
  38. {
  39. /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
  40. _exit (sig != SIGFPE);
  41. }
  42. int x = 1;
  43. int y = 0;
  44. int z;
  45. int nan;
  46. int main ()
  47. {
  48. signal (SIGFPE, sigfpe_handler);
  49. /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
  50. #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
  51. signal (SIGTRAP, sigfpe_handler);
  52. #endif
  53. /* Linux/SPARC yields signal SIGILL. */
  54. #if defined (__sparc__) && defined (__linux__)
  55. signal (SIGILL, sigfpe_handler);
  56. #endif
  57. z = x / y;
  58. nan = y / y;
  59. exit (2);
  60. }
  61. ]])],
  62. [gt_cv_int_divbyzero_sigfpe=yes],
  63. [gt_cv_int_divbyzero_sigfpe=no],
  64. [
  65. # Guess based on the CPU.
  66. changequote(,)dnl
  67. case "$host_cpu" in
  68. alpha* | i[34567]86 | x86_64 | m68k | s390*)
  69. gt_cv_int_divbyzero_sigfpe="guessing yes";;
  70. *)
  71. gt_cv_int_divbyzero_sigfpe="guessing no";;
  72. esac
  73. changequote([,])dnl
  74. ])
  75. fi
  76. ])
  77. case "$gt_cv_int_divbyzero_sigfpe" in
  78. *yes) value=1;;
  79. *) value=0;;
  80. esac
  81. AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value],
  82. [Define if integer division by zero raises signal SIGFPE.])
  83. ])