PR79017 workaround incomplete C99 math on darwin
authorJonathan Wakely <jwakely@redhat.com>
Mon, 9 Jan 2017 17:15:58 +0000 (17:15 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 9 Jan 2017 17:15:58 +0000 (17:15 +0000)
PR libstdc++/79017
* acinclude.m4 (GLIBCXX_CHECK_C99_TR1): Check for llrint and llround
functions separately on darwin and if they're missing define
_GLIBCXX_NO_C99_ROUNDING_FUNCS.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/c_global/cmath [_GLIBCXX_NO_C99_ROUNDING_FUNCS] (llrint)
(llrintf, llrintl, llround, llroundf, llroundl): Do not define.

From-SVN: r244231

libstdc++-v3/ChangeLog
libstdc++-v3/acinclude.m4
libstdc++-v3/config.h.in
libstdc++-v3/configure
libstdc++-v3/include/c_global/cmath

index 4111bae..5d9f26d 100644 (file)
@@ -1,5 +1,14 @@
 2017-01-09  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/79017
+       * acinclude.m4 (GLIBCXX_CHECK_C99_TR1): Check for llrint and llround
+       functions separately on darwin and if they're missing define
+       _GLIBCXX_NO_C99_ROUNDING_FUNCS.
+       * config.h.in: Regenerate.
+       * configure: Regenerate.
+       * include/c_global/cmath [_GLIBCXX_NO_C99_ROUNDING_FUNCS] (llrint)
+       (llrintf, llrintl, llround, llroundf, llroundl): Do not define.
+
        * testsuite/30_threads/condition_variable/members/3.cc: Use new macro
        to detect correct thread_local destructors.
        * testsuite/util/testsuite_hooks.h (CORRECT_THREAD_LOCAL_DTORS):
index eef107a..4e04cce 100644 (file)
@@ -1890,12 +1890,14 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
                  lgamma(0.0);
                  lgammaf(0.0f);
                  lgammal(0.0l);
+                 #ifndef __APPLE__ /* see below */
                  llrint(0.0);
                  llrintf(0.0f);
                  llrintl(0.0l);
                  llround(0.0);
                  llroundf(0.0f);
                  llroundl(0.0l);
+                 #endif
                  log1p(0.0);
                  log1pf(0.0f);
                  log1pl(0.0l);
@@ -1954,6 +1956,29 @@ AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
     AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1,
              [Define if C99 functions or macros in <math.h> should be imported
              in <tr1/cmath> in namespace std::tr1.])
+
+    case "${target_os}" in
+      darwin*)
+        AC_MSG_CHECKING([for ISO C99 rounding functions in <math.h>])
+        AC_CACHE_VAL(glibcxx_cv_c99_math_llround, [
+          AC_TRY_COMPILE([#include <math.h>],
+                [llrint(0.0);
+                 llrintf(0.0f);
+                 llrintl(0.0l);
+                 llround(0.0);
+                 llroundf(0.0f);
+                 llroundl(0.0l);
+                ],
+                [glibcxx_cv_c99_math_llround=yes],
+                [glibcxx_cv_c99_math_llround=no])
+          ])
+       AC_MSG_RESULT($glibcxx_cv_c99_math_llround)
+        ;;
+    esac
+    if test x"$glibcxx_cv_c99_math_llround" = x"no"; then
+      AC_DEFINE(_GLIBCXX_NO_C99_ROUNDING_FUNCS, 1,
+               [Define if C99 llrint and llround functions are missing from <math.h>.])
+    fi
   fi
 
   # Check for the existence of <inttypes.h> functions (NB: doesn't make
index cdd313b..51b770d 100644 (file)
 /* Define to the letter to which size_t is mangled. */
 #undef _GLIBCXX_MANGLE_SIZE_T
 
+/* Define if C99 llrint and llround functions are missing from <math.h>. */
+#undef _GLIBCXX_NO_C99_ROUNDING_FUNCS
+
 /* Define if ptrdiff_t is int. */
 #undef _GLIBCXX_PTRDIFF_T_IS_INT
 
index c7f679a..64d8933 100755 (executable)
@@ -20079,12 +20079,14 @@ typedef double_t  my_double_t;
                  lgamma(0.0);
                  lgammaf(0.0f);
                  lgammal(0.0l);
+                 #ifndef __APPLE__ /* see below */
                  llrint(0.0);
                  llrintf(0.0f);
                  llrintl(0.0l);
                  llround(0.0);
                  llroundf(0.0f);
                  llroundl(0.0l);
+                 #endif
                  log1p(0.0);
                  log1pf(0.0f);
                  log1pl(0.0l);
@@ -20156,6 +20158,50 @@ $as_echo "$glibcxx_cv_c99_math_tr1" >&6; }
 
 $as_echo "#define _GLIBCXX_USE_C99_MATH_TR1 1" >>confdefs.h
 
+
+    case "${target_os}" in
+      darwin*)
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C99 rounding functions in <math.h>" >&5
+$as_echo_n "checking for ISO C99 rounding functions in <math.h>... " >&6; }
+        if test "${glibcxx_cv_c99_math_llround+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <math.h>
+int
+main ()
+{
+llrint(0.0);
+                 llrintf(0.0f);
+                 llrintl(0.0l);
+                 llround(0.0);
+                 llroundf(0.0f);
+                 llroundl(0.0l);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  glibcxx_cv_c99_math_llround=yes
+else
+  glibcxx_cv_c99_math_llround=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_c99_math_llround" >&5
+$as_echo "$glibcxx_cv_c99_math_llround" >&6; }
+        ;;
+    esac
+    if test x"$glibcxx_cv_c99_math_llround" = x"no"; then
+
+$as_echo "#define _GLIBCXX_NO_C99_ROUNDING_FUNCS 1" >>confdefs.h
+
+    fi
   fi
 
   # Check for the existence of <inttypes.h> functions (NB: doesn't make
index 3630a5b..6e7508f 100644 (file)
@@ -1012,12 +1012,14 @@ _GLIBCXX_END_NAMESPACE_VERSION
 #undef lgamma
 #undef lgammaf
 #undef lgammal
+#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
 #undef llrint
 #undef llrintf
 #undef llrintl
 #undef llround
 #undef llroundf
 #undef llroundl
+#endif
 #undef log1p
 #undef log1pf
 #undef log1pl
@@ -1143,6 +1145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using ::lgammaf;
   using ::lgammal;
 
+#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
   using ::llrint;
   using ::llrintf;
   using ::llrintl;
@@ -1150,6 +1153,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using ::llround;
   using ::llroundf;
   using ::llroundl;
+#endif
 
   using ::log1p;
   using ::log1pf;