diff options
Diffstat (limited to 'config/c-compiler.m4')
-rw-r--r-- | config/c-compiler.m4 | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 509f96139f..38aab11bc6 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -125,6 +125,43 @@ undefine([Ac_cachevar])dnl ])# PGAC_TYPE_64BIT_INT +# PGAC_TYPE_128BIT_INT +# --------------------- +# Check if __int128 is a working 128 bit integer type, and if so +# define PG_INT128_TYPE to that typename. This currently only detects +# a GCC/clang extension, but support for different environments may be +# added in the future. +# +# For the moment we only test for support for 128bit math; support for +# 128bit literals and snprintf is not required. +AC_DEFUN([PGAC_TYPE_128BIT_INT], +[AC_CACHE_CHECK([for __int128], [pgac_cv__128bit_int], +[AC_LINK_IFELSE([AC_LANG_PROGRAM([ +/* + * These are globals to discourage the compiler from folding all the + * arithmetic tests down to compile-time constants. We do not have + * convenient support for 64bit literals at this point... + */ +__int128 a = 48828125; +__int128 b = 97656255; +],[ +__int128 c,d; +a = (a << 12) + 1; /* 200000000001 */ +b = (b << 12) + 5; /* 400000000005 */ +/* use the most relevant arithmetic ops */ +c = a * b; +d = (c + b) / b; +/* return different values, to prevent optimizations */ +if (d != a+1) + return 0; +return 1; +])], +[pgac_cv__128bit_int=yes], +[pgac_cv__128bit_int=no])]) +if test x"$pgac_cv__128bit_int" = xyes ; then + AC_DEFINE(PG_INT128_TYPE, __int128, [Define to the name of a signed 128-bit integer type.]) +fi])# PGAC_TYPE_128BIT_INT + # PGAC_C_FUNCNAME_SUPPORT # ----------------------- |