@@ -15057,12 +15057,15 @@ else
15057
15057
/* end confdefs.h. */
15058
15058
15059
15059
/*
15060
+ * We don't actually run this test, just link it to verify that any support
15061
+ * functions needed for __int128 are present.
15062
+ *
15060
15063
* These are globals to discourage the compiler from folding all the
15061
15064
* arithmetic tests down to compile-time constants. We do not have
15062
- * convenient support for 64bit literals at this point...
15065
+ * convenient support for 128bit literals at this point...
15063
15066
*/
15064
15067
__int128 a = 48828125;
15065
- __int128 b = 97656255 ;
15068
+ __int128 b = 97656250 ;
15066
15069
15067
15070
int
15068
15071
main ()
@@ -15071,13 +15074,12 @@ main ()
15071
15074
__int128 c,d;
15072
15075
a = (a << 12) + 1; /* 200000000001 */
15073
15076
b = (b << 12) + 5; /* 400000000005 */
15074
- /* use the most relevant arithmetic ops */
15077
+ /* try the most relevant arithmetic ops */
15075
15078
c = a * b;
15076
15079
d = (c + b) / b;
15077
- /* return different values, to prevent optimizations */
15080
+ /* must use the results, else compiler may optimize arithmetic away */
15078
15081
if (d != a+1)
15079
- return 0;
15080
- return 1;
15082
+ return 1;
15081
15083
15082
15084
;
15083
15085
return 0;
@@ -15094,10 +15096,63 @@ fi
15094
15096
{ $as_echo " $as_me :${as_lineno-$LINENO } : result: $pgac_cv__128bit_int " >&5
15095
15097
$as_echo " $pgac_cv__128bit_int " >&6 ; }
15096
15098
if test x" $pgac_cv__128bit_int " = xyes ; then
15099
+ # Some versions of gcc have problems passing __int128 function arguments
15100
+ # when using non-default alignment. Test that, if not cross-compiling.
15101
+ { $as_echo " $as_me :${as_lineno-$LINENO } : checking for __int128 alignment bug" >&5
15102
+ $as_echo_n " checking for __int128 alignment bug... " >&6 ; }
15103
+ if ${pgac_cv__128bit_int_bug+: } false ; then :
15104
+ $as_echo_n " (cached) " >&6
15105
+ else
15106
+ if test " $cross_compiling " = yes; then :
15107
+ pgac_cv__128bit_int_bug=assuming-ok
15108
+ else
15109
+ cat confdefs.h - << _ACEOF >conftest.$ac_ext
15110
+ /* end confdefs.h. */
15111
+
15112
+ /* This must match the corresponding code in c.h: */
15113
+ #if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
15114
+ #define pg_attribute_aligned(a) __attribute__((aligned(a)))
15115
+ #endif
15116
+ typedef __int128 int128a
15117
+ #if defined(pg_attribute_aligned)
15118
+ pg_attribute_aligned(8)
15119
+ #endif
15120
+ ;
15121
+ int128a holder;
15122
+ void pass_by_val(void *buffer, int128a par) { holder = par; }
15123
+
15124
+ int
15125
+ main ()
15126
+ {
15127
+
15128
+ long int i64 = 97656225L << 12;
15129
+ int128a q;
15130
+ pass_by_val(main, (int128a) i64);
15131
+ q = (int128a) i64;
15132
+ if (q != holder)
15133
+ return 1;
15134
+
15135
+ ;
15136
+ return 0;
15137
+ }
15138
+ _ACEOF
15139
+ if ac_fn_c_try_run " $LINENO " ; then :
15140
+ pgac_cv__128bit_int_bug=ok
15141
+ else
15142
+ pgac_cv__128bit_int_bug=broken
15143
+ fi
15144
+ rm -f core * .core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15145
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
15146
+ fi
15147
+
15148
+ fi
15149
+ { $as_echo " $as_me :${as_lineno-$LINENO } : result: $pgac_cv__128bit_int_bug " >&5
15150
+ $as_echo " $pgac_cv__128bit_int_bug " >&6 ; }
15151
+ if test x" $pgac_cv__128bit_int_bug " ! = xbroken ; then
15097
15152
15098
15153
$as_echo " #define PG_INT128_TYPE __int128" >> confdefs.h
15099
15154
15100
- # The cast to long int works around a bug in the HP C Compiler,
15155
+ # The cast to long int works around a bug in the HP C Compiler,
15101
15156
# see AC_CHECK_SIZEOF for more information.
15102
15157
{ $as_echo " $as_me :${as_lineno-$LINENO } : checking alignment of PG_INT128_TYPE" >&5
15103
15158
$as_echo_n " checking alignment of PG_INT128_TYPE... " >&6 ; }
@@ -15132,6 +15187,7 @@ cat >>confdefs.h <<_ACEOF
15132
15187
_ACEOF
15133
15188
15134
15189
15190
+ fi
15135
15191
fi
15136
15192
15137
15193
# Check for various atomic operations now that we have checked how to declare
0 commit comments