intdiv0.m4 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # intdiv0.m4 serial 6 (gettext-0.18.2)
  2. dnl Copyright (C) 2002, 2007-2008, 2010-2016 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>
  32. #include <signal.h>
  33. static void
  34. sigfpe_handler (int sig)
  35. {
  36. /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
  37. _exit (sig != SIGFPE);
  38. }
  39. int x = 1;
  40. int y = 0;
  41. int z;
  42. int nan;
  43. int main ()
  44. {
  45. signal (SIGFPE, sigfpe_handler);
  46. /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
  47. #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
  48. signal (SIGTRAP, sigfpe_handler);
  49. #endif
  50. /* Linux/SPARC yields signal SIGILL. */
  51. #if defined (__sparc__) && defined (__linux__)
  52. signal (SIGILL, sigfpe_handler);
  53. #endif
  54. z = x / y;
  55. nan = y / y;
  56. exit (2);
  57. }
  58. ]])],
  59. [gt_cv_int_divbyzero_sigfpe=yes],
  60. [gt_cv_int_divbyzero_sigfpe=no],
  61. [
  62. # Guess based on the CPU.
  63. changequote(,)dnl
  64. case "$host_cpu" in
  65. alpha* | i[34567]86 | x86_64 | m68k | s390*)
  66. gt_cv_int_divbyzero_sigfpe="guessing yes";;
  67. *)
  68. gt_cv_int_divbyzero_sigfpe="guessing no";;
  69. esac
  70. changequote([,])dnl
  71. ])
  72. fi
  73. ])
  74. case "$gt_cv_int_divbyzero_sigfpe" in
  75. *yes) value=1;;
  76. *) value=0;;
  77. esac
  78. AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value],
  79. [Define if integer division by zero raises signal SIGFPE.])
  80. ])