1# PGAC_TYPE_64BIT_INT(TYPE) 2# ------------------------- 3# Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to 4# yes or no respectively, and define HAVE_TYPE_64 if yes. 5AC_DEFUN([PGAC_TYPE_64BIT_INT], 6[define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl 7define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl 8AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar], 9[AC_TRY_RUN( 10[typedef $1 ac_int64; 11 12/* 13 * These are globals to discourage the compiler from folding all the 14 * arithmetic tests down to compile-time constants. 15 */ 16ac_int64 a = 20000001; 17ac_int64 b = 40000005; 18 19int does_int64_work() 20{ 21 ac_int64 c,d; 22 23 if (sizeof(ac_int64) != 8) 24 return 0; /* definitely not the right size */ 25 26 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */ 27 c = a * b; 28 d = (c + b) / b; 29 if (d != a+1) 30 return 0; 31 return 1; 32} 33main() { 34 exit(! does_int64_work()); 35}], 36[Ac_cachevar=yes], 37[Ac_cachevar=no], 38[# If cross-compiling, check the size reported by the compiler and 39# trust that the arithmetic works. 40AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([], [sizeof($1) == 8])], 41 Ac_cachevar=yes, 42 Ac_cachevar=no)])]) 43 44Ac_define=$Ac_cachevar 45if test x"$Ac_cachevar" = xyes ; then 46 AC_DEFINE(Ac_define, 1, [Define to 1 if `]$1[' works and is 64 bits.]) 47fi 48undefine([Ac_define])dnl 49undefine([Ac_cachevar])dnl 50])# PGAC_TYPE_64BIT_INT 51