intdiv0.m4 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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, distributed under the terms of the GNU
  4. dnl General Public License. As a special exception to the GNU General
  5. dnl Public License, this file may be distributed as part of a program
  6. dnl that contains a configuration script generated by Autoconf, under
  7. dnl the same distribution terms as the rest of that program.
  8. dnl From Bruno Haible.
  9. AC_DEFUN([gt_INTDIV0],
  10. [
  11. AC_REQUIRE([AC_PROG_CC])dnl
  12. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  13. AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
  14. gt_cv_int_divbyzero_sigfpe,
  15. [
  16. AC_TRY_RUN([
  17. #include <stdlib.h>
  18. #include <signal.h>
  19. static void
  20. #ifdef __cplusplus
  21. sigfpe_handler (int sig)
  22. #else
  23. sigfpe_handler (sig) int sig;
  24. #endif
  25. {
  26. /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
  27. exit (sig != SIGFPE);
  28. }
  29. int x = 1;
  30. int y = 0;
  31. int z;
  32. int nan;
  33. int main ()
  34. {
  35. signal (SIGFPE, sigfpe_handler);
  36. /* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
  37. #if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
  38. signal (SIGTRAP, sigfpe_handler);
  39. #endif
  40. /* Linux/SPARC yields signal SIGILL. */
  41. #if defined (__sparc__) && defined (__linux__)
  42. signal (SIGILL, sigfpe_handler);
  43. #endif
  44. z = x / y;
  45. nan = y / y;
  46. exit (1);
  47. }
  48. ], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no,
  49. [
  50. # Guess based on the CPU.
  51. case "$host_cpu" in
  52. alpha* | i[34567]86 | m68k | s390*)
  53. gt_cv_int_divbyzero_sigfpe="guessing yes";;
  54. *)
  55. gt_cv_int_divbyzero_sigfpe="guessing no";;
  56. esac
  57. ])
  58. ])
  59. case "$gt_cv_int_divbyzero_sigfpe" in
  60. *yes) value=1;;
  61. *) value=0;;
  62. esac
  63. AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value,
  64. [Define if integer division by zero raises signal SIGFPE.])
  65. ])