]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Stop using TR1 macros in <cctype> and <cfenv>
authorJonathan Wakely <jwakely@redhat.com>
Fri, 12 May 2023 20:36:56 +0000 (21:36 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 16 May 2023 08:59:19 +0000 (09:59 +0100)
As with the two commits before this, the _GLIBCXX_USE_C99_CTYPE_TR1 and
_GLIBCXX_USE_C99_FENV_TR1 macros are misleading when they are also used
for <cctype> and <cfenv>, not only for TR1 headers. It is also wrong,
because the configure checks for TR1 use -std=c++98 and a target might
define the C99 features for C++11 but not for C++98.

Add separate configure checks for the <ctype.h> and <fenv.h> features using -std=c++11
for the checks. Use the new macros defined by those checks in the
C++11-specific parts of <cctype>, <cfenv>, and <fenv.h>.

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_USE_C99): Check for isblank in C++11
mode and define _GLIBCXX_USE_C99_CTYPE. Check for <fenv.h>
functions in C++11 mode and define _GLIBCXX_USE_C99_FENV.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/c_compatibility/fenv.h: Check _GLIBCXX_USE_C99_FENV
instead of _GLIBCXX_USE_C99_FENV_TR1.
* include/c_global/cfenv: Likewise.
* include/c_global/cctype: Check _GLIBCXX_USE_C99_CTYPE instead
of _GLIBCXX_USE_C99_CTYPE_TR1.

libstdc++-v3/acinclude.m4
libstdc++-v3/config.h.in
libstdc++-v3/configure
libstdc++-v3/include/c_compatibility/fenv.h
libstdc++-v3/include/c_global/cctype
libstdc++-v3/include/c_global/cfenv

index 0c01b526ebf8722f7b24ff56e70c7758c094aebe..988c532c4e28bb13207e186ff5ef4089bab90a5e 100644 (file)
@@ -1476,6 +1476,52 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
       fi
     fi
 
+    # Check for the existence of <ctype.h> functions.
+    AC_CACHE_CHECK([for ISO C99 support for C++11 in <ctype.h>],
+    glibcxx_cv_c99_ctype, [
+    AC_TRY_COMPILE([#include <ctype.h>],
+                  [int ch;
+                   int ret;
+                   ret = isblank(ch);
+                  ],[glibcxx_cv_c99_ctype=yes],
+                    [glibcxx_cv_c99_ctype=no])
+    ])
+    if test x"$glibcxx_cv_c99_ctype" = x"yes"; then
+      AC_DEFINE(_GLIBCXX_USE_C99_CTYPE, 1,
+               [Define if C99 functions in <ctype.h> should be imported in
+               <cctype> in namespace std for C++11.])
+    fi
+
+    # Check for the existence of <fenv.h> functions.
+    AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
+    ac_c99_fenv=no;
+    if test x"$ac_has_fenv_h" = x"yes"; then
+      AC_MSG_CHECKING([for ISO C99 support for C++11 in <fenv.h>])
+      AC_TRY_COMPILE([#include <fenv.h>],
+                    [int except, mode;
+                     fexcept_t* pflag;
+                     fenv_t* penv;
+                     int ret;
+                     ret = feclearexcept(except);
+                     ret = fegetexceptflag(pflag, except);
+                     ret = feraiseexcept(except);
+                     ret = fesetexceptflag(pflag, except);
+                     ret = fetestexcept(except);
+                     ret = fegetround();
+                     ret = fesetround(mode);
+                     ret = fegetenv(penv);
+                     ret = feholdexcept(penv);
+                     ret = fesetenv(penv);
+                     ret = feupdateenv(penv);
+                    ],[ac_c99_fenv=yes], [ac_c99_fenv=no])
+      AC_MSG_RESULT($ac_c99_fenv)
+    fi
+    if test x"$ac_c99_fenv" = x"yes"; then
+      AC_DEFINE(_GLIBCXX_USE_C99_FENV, 1,
+               [Define if C99 functions in <fenv.h> should be imported in
+               <cfenv> in namespace std for C++11.])
+    fi
+
     gcc_no_link="$ac_save_gcc_no_link"
     LIBS="$ac_save_LIBS"
     CXXFLAGS="$ac_save_CXXFLAGS"
index 62be4c7994543f80c13f4a703ceb4cc0bd1241ba..f91f7eb90973a2ef3b193902eaa49186c014785d 100644 (file)
    library functions to be present. */
 #undef _GLIBCXX_USE_C99_COMPLEX_TR1
 
+/* Define if C99 functions in <ctype.h> should be imported in <cctype> in
+   namespace std for C++11. */
+#undef _GLIBCXX_USE_C99_CTYPE
+
 /* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in
    namespace std::tr1. */
 #undef _GLIBCXX_USE_C99_CTYPE_TR1
 
+/* Define if C99 functions in <fenv.h> should be imported in <cfenv> in
+   namespace std for C++11. */
+#undef _GLIBCXX_USE_C99_FENV
+
 /* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in
    namespace std::tr1. */
 #undef _GLIBCXX_USE_C99_FENV_TR1
index 26bc090deb156b42c711182f83b9a14ce14126e9..a9589d882e6306f8184cd8a50ab2f26d601c607b 100755 (executable)
@@ -18824,6 +18824,103 @@ $as_echo "#define _GLIBCXX11_USE_C99_WCHAR 1" >>confdefs.h
       fi
     fi
 
+    # Check for the existence of <ctype.h> functions.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C99 support for C++11 in <ctype.h>" >&5
+$as_echo_n "checking for ISO C99 support for C++11 in <ctype.h>... " >&6; }
+if ${glibcxx_cv_c99_ctype+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+int
+main ()
+{
+int ch;
+                   int ret;
+                   ret = isblank(ch);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  glibcxx_cv_c99_ctype=yes
+else
+  glibcxx_cv_c99_ctype=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_ctype" >&5
+$as_echo "$glibcxx_cv_c99_ctype" >&6; }
+    if test x"$glibcxx_cv_c99_ctype" = x"yes"; then
+
+$as_echo "#define _GLIBCXX_USE_C99_CTYPE 1" >>confdefs.h
+
+    fi
+
+    # Check for the existence of <fenv.h> functions.
+    for ac_header in fenv.h
+do :
+  ac_fn_cxx_check_header_mongrel "$LINENO" "fenv.h" "ac_cv_header_fenv_h" "$ac_includes_default"
+if test "x$ac_cv_header_fenv_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_FENV_H 1
+_ACEOF
+ ac_has_fenv_h=yes
+else
+  ac_has_fenv_h=no
+fi
+
+done
+
+    ac_c99_fenv=no;
+    if test x"$ac_has_fenv_h" = x"yes"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C99 support for C++11 in <fenv.h>" >&5
+$as_echo_n "checking for ISO C99 support for C++11 in <fenv.h>... " >&6; }
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <fenv.h>
+int
+main ()
+{
+int except, mode;
+                     fexcept_t* pflag;
+                     fenv_t* penv;
+                     int ret;
+                     ret = feclearexcept(except);
+                     ret = fegetexceptflag(pflag, except);
+                     ret = feraiseexcept(except);
+                     ret = fesetexceptflag(pflag, except);
+                     ret = fetestexcept(except);
+                     ret = fegetround();
+                     ret = fesetround(mode);
+                     ret = fegetenv(penv);
+                     ret = feholdexcept(penv);
+                     ret = fesetenv(penv);
+                     ret = feupdateenv(penv);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_c99_fenv=yes
+else
+  ac_c99_fenv=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_c99_fenv" >&5
+$as_echo "$ac_c99_fenv" >&6; }
+    fi
+    if test x"$ac_c99_fenv" = x"yes"; then
+
+$as_echo "#define _GLIBCXX_USE_C99_FENV 1" >>confdefs.h
+
+    fi
+
     gcc_no_link="$ac_save_gcc_no_link"
     LIBS="$ac_save_LIBS"
     CXXFLAGS="$ac_save_CXXFLAGS"
index 70ce3f834f4ad37d8f376af43f9277d3618609a0..83e930f12d16f33edd16f75c955b5e1b9027ee69 100644 (file)
@@ -38,7 +38,7 @@
 
 #if __cplusplus >= 201103L
 
-#if _GLIBCXX_USE_C99_FENV_TR1
+#if _GLIBCXX_USE_C99_FENV
 
 #undef feclearexcept
 #undef fegetexceptflag
@@ -74,7 +74,7 @@ namespace std
   using ::feupdateenv;
 } // namespace
 
-#endif // _GLIBCXX_USE_C99_FENV_TR1
+#endif // _GLIBCXX_USE_C99_FENV
 
 #endif // C++11
 
index bd667fba15dabcdb25ccffed21ef3c56cc145f8d..e6ff1204df67cd3d0af92e445348f84b2ccd4b34 100644 (file)
@@ -78,7 +78,7 @@ namespace std
 
 #if __cplusplus >= 201103L
 
-#ifdef _GLIBCXX_USE_C99_CTYPE_TR1
+#ifdef _GLIBCXX_USE_C99_CTYPE
 
 #undef isblank
 
@@ -87,7 +87,7 @@ namespace std
   using ::isblank;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99_CTYPE_TR1
+#endif // _GLIBCXX_USE_C99_CTYPE
 
 #endif // C++11
 
index 6704dc5423ed8e0abb36fb5ffdc05b39fc5bc309..3a1d9c4a6aa6c296a305d388355571a1d35cfd15 100644 (file)
@@ -41,7 +41,7 @@
 # include <fenv.h>
 #endif
 
-#ifdef _GLIBCXX_USE_C99_FENV_TR1
+#ifdef _GLIBCXX_USE_C99_FENV
 
 #undef feclearexcept
 #undef fegetexceptflag
@@ -77,7 +77,7 @@ namespace std
   using ::feupdateenv;
 } // namespace std
 
-#endif // _GLIBCXX_USE_C99_FENV_TR1
+#endif // _GLIBCXX_USE_C99_FENV
 
 #endif // C++11
 
This page took 0.108453 seconds and 5 git commands to generate.