From: Dmitry Volyntsev Date: Wed, 6 Jul 2022 05:58:12 +0000 (-0700) Subject: Ensuring that double type is always evaluated at standard precision. X-Git-Tag: 0.7.6~9 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=e0e56b0da80406a01d8c3e733c96b4bdfb7409ac;p=njs.git Ensuring that double type is always evaluated at standard precision. Previously, GCC on x86 uses extended precision for intermediate calculations by default. This might conflict with njs_diyfp_t because GCC is not always rounds back the intermediate values to standard precision. The fix is to explicitly tell to a compiler to do so. This closes #507 issue on Github. --- diff --git a/auto/types b/auto/types index 7bb9c16a..6e1c2c61 100644 --- a/auto/types +++ b/auto/types @@ -118,3 +118,57 @@ njs_feature_test="#include return 0; }" . auto/feature + + +# Ensuring that double type is always evaluated at standard +# precision required by njs_diyfp_t + + +case $NJS_CC_NAME in + + gcc) + NJS_CFLAGS="$NJS_CFLAGS -fexcess-precision=standard" + ;; + + clang) + + njs_found=no + + njs_feature="flag -ffp-eval-method=double" + njs_feature_name=NJS_HAVE_FP_EVAL_METHOD + njs_feature_run=no + njs_feature_incs="-ffp-eval-method=double" + njs_feature_libs= + njs_feature_test="int main(void) { + return 0; + }" + + . auto/feature + + if [ $njs_found = yes ]; then + NJS_CFLAGS="$NJS_CFLAGS -ffp-eval-method=double" + fi + + ;; + + SunC) + + njs_found=no + + njs_feature="flag -xarch=sse2" + njs_feature_name=NJS_HAVE_XARCH_SSE2 + njs_feature_run=no + njs_feature_incs="-xarch=sse2" + njs_feature_libs= + njs_feature_test="int main(void) { + return 0; + }" + + . auto/feature + + if [ $njs_found = yes ]; then + NJS_CFLAGS="$NJS_CFLAGS -xarch=sse2" + fi + ;; + +esac