1dnl
2dnl Test if the 64bit integer types are available, and if not if they
3dnl can be typedef'ed manually.
4dnl
5AC_MSG_CHECKING(for int64_t)
6AC_LANG_PUSH(C++)
7AC_CACHE_VAL(ac_cv_has_int64_t,[
8  AC_TRY_COMPILE([
9#if HAVE_INTTYPES_H
10# include <inttypes.h>
11#endif
12#if HAVE_STDINT_H
13# include <stdint.h>
14#endif
15#if HAVE_SYS_TYPES_H
16# include <sys/types.h>
17#endif
18    ],
19    [int64_t foo;],
20    ac_cv_has_int64_t=yes,
21    ac_cv_has_int64_t=no)
22  ])
23AC_MSG_RESULT($ac_cv_has_int64_t)
24
25AC_MSG_CHECKING(for uint64_t)
26AC_CACHE_VAL(ac_cv_has_uint64_t,[
27  AC_TRY_COMPILE([
28#if HAVE_INTTYPES_H
29# include <inttypes.h>
30#endif
31#if HAVE_STDINT_H
32# include <stdint.h>
33#endif
34#if HAVE_SYS_TYPES_H
35# include <sys/types.h>
36#endif
37    ],
38    [int64_t foo;],
39    ac_cv_has_uint64_t=yes,
40    ac_cv_has_uint64_t=no)
41  ])
42AC_MSG_RESULT($ac_cv_has_uint64_t)
43AC_LANG_POP
44
45AC_CHECK_SIZEOF(int)
46AC_CHECK_SIZEOF(long)
47AC_CHECK_SIZEOF(long long)
48
49if test x$ac_cv_has_int64_t = "xyes" ; then
50  TYPE64="int64_t"
51else
52  case 8 in
53    $ac_cv_sizeof_int) TYPE64="int";;
54    $ac_cv_sizeof_long) TYPE64="long";;
55    $ac_cv_sizeof_long_long) TYPE64="long long";;
56  esac
57  AC_DEFINE(HAVE_NO_INT64_T, 1, [int64_t does not exist])
58  AC_DEFINE_UNQUOTED(INT64_TYPE, $TYPE64,
59                     [the type to define int64_t manually])
60fi
61
62if test x$ac_cv_has_uint64_t = "xyes" ; then
63  TYPEU64="int64_t"
64else
65  case 8 in
66    $ac_cv_sizeof_int) TYPEU64="unsigned int";;
67    $ac_cv_sizeof_long) TYPEU64="unsigned long";;
68    $ac_cv_sizeof_long_long) TYPEU64="unsigned long long";;
69  esac
70  AC_DEFINE(HAVE_NO_UINT64_T, 1, [uint64_t does not exist])
71  AC_DEFINE_UNQUOTED(UINT64_TYPE, $TYPEU64,
72                     [the type to define uint64_t manually])
73fi
74
75if test -z "$TYPE64"; then
76  AC_MSG_ERROR(No 64 bit type found on this platform!)
77fi
78if test -z "$TYPEU64"; then
79  AC_MSG_ERROR(No unsigned 64 bit type found on this platform!)
80fi
81