longlong.m4 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # longlong.m4 serial 10
  2. dnl Copyright (C) 1999-2006 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 Paul Eggert.
  7. # Define HAVE_LONG_LONG_INT if 'long long int' works.
  8. # This fixes a bug in Autoconf 2.60, but can be removed once we
  9. # assume 2.61 everywhere.
  10. # Note: If the type 'long long int' exists but is only 32 bits large
  11. # (as on some very old compilers), HAVE_LONG_LONG_INT will not be
  12. # defined. In this case you can treat 'long long int' like 'long int'.
  13. AC_DEFUN([AC_TYPE_LONG_LONG_INT],
  14. [
  15. AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
  16. [AC_LINK_IFELSE(
  17. [AC_LANG_PROGRAM(
  18. [[long long int ll = 9223372036854775807ll;
  19. long long int nll = -9223372036854775807LL;
  20. typedef int a[((-9223372036854775807LL < 0
  21. && 0 < 9223372036854775807ll)
  22. ? 1 : -1)];
  23. int i = 63;]],
  24. [[long long int llmax = 9223372036854775807ll;
  25. return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
  26. | (llmax / ll) | (llmax % ll));]])],
  27. [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
  28. dnl If cross compiling, assume the bug isn't important, since
  29. dnl nobody cross compiles for this platform as far as we know.
  30. AC_RUN_IFELSE(
  31. [AC_LANG_PROGRAM(
  32. [[@%:@include <limits.h>
  33. @%:@ifndef LLONG_MAX
  34. @%:@ define HALF \
  35. (1LL << (sizeof (long long int) * CHAR_BIT - 2))
  36. @%:@ define LLONG_MAX (HALF - 1 + HALF)
  37. @%:@endif]],
  38. [[long long int n = 1;
  39. int i;
  40. for (i = 0; ; i++)
  41. {
  42. long long int m = n << i;
  43. if (m >> i != n)
  44. return 1;
  45. if (LLONG_MAX / 2 < m)
  46. break;
  47. }
  48. return 0;]])],
  49. [ac_cv_type_long_long_int=yes],
  50. [ac_cv_type_long_long_int=no],
  51. [ac_cv_type_long_long_int=yes])],
  52. [ac_cv_type_long_long_int=no])])
  53. if test $ac_cv_type_long_long_int = yes; then
  54. AC_DEFINE([HAVE_LONG_LONG_INT], 1,
  55. [Define to 1 if the system has the type `long long int'.])
  56. fi
  57. ])
  58. # This macro is obsolescent and should go away soon.
  59. AC_DEFUN([gl_AC_TYPE_LONG_LONG],
  60. [
  61. AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
  62. ac_cv_type_long_long=$ac_cv_type_long_long_int
  63. if test $ac_cv_type_long_long = yes; then
  64. AC_DEFINE(HAVE_LONG_LONG, 1,
  65. [Define if you have the 'long long' type.])
  66. fi
  67. ])