intdiv0.m4 2.3 KB

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