From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed 3/3] libstdc++: Stop using TR1 macros in <cctype> and <cfenv>
Date: Tue, 16 May 2023 10:11:32 +0100 [thread overview]
Message-ID: <20230516091132.1698684-3-jwakely@redhat.com> (raw)
In-Reply-To: <20230516091132.1698684-1-jwakely@redhat.com>
Tested powerpc64le-linux. Pushed to trunk.
-- >8 --
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 | 46 ++++++++++
libstdc++-v3/config.h.in | 8 ++
libstdc++-v3/configure | 97 +++++++++++++++++++++
libstdc++-v3/include/c_compatibility/fenv.h | 4 +-
libstdc++-v3/include/c_global/cctype | 4 +-
libstdc++-v3/include/c_global/cfenv | 4 +-
6 files changed, 157 insertions(+), 6 deletions(-)
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 0c01b526ebf..988c532c4e2 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -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"
diff --git a/libstdc++-v3/include/c_compatibility/fenv.h b/libstdc++-v3/include/c_compatibility/fenv.h
index 70ce3f834f4..83e930f12d1 100644
--- a/libstdc++-v3/include/c_compatibility/fenv.h
+++ b/libstdc++-v3/include/c_compatibility/fenv.h
@@ -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
diff --git a/libstdc++-v3/include/c_global/cctype b/libstdc++-v3/include/c_global/cctype
index bd667fba15d..e6ff1204df6 100644
--- a/libstdc++-v3/include/c_global/cctype
+++ b/libstdc++-v3/include/c_global/cctype
@@ -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
diff --git a/libstdc++-v3/include/c_global/cfenv b/libstdc++-v3/include/c_global/cfenv
index 6704dc5423e..3a1d9c4a6aa 100644
--- a/libstdc++-v3/include/c_global/cfenv
+++ b/libstdc++-v3/include/c_global/cfenv
@@ -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
--
2.40.1
prev parent reply other threads:[~2023-05-16 9:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 9:11 [committed 1/3] libstdc++: Stop using _GLIBCXX_USE_C99_COMPLEX_TR1 in <complex> Jonathan Wakely
2023-05-16 9:11 ` [committed 2/3] libstdc++: Stop using _GLIBCXX_USE_C99_STDINT_TR1 in <cstdint> Jonathan Wakely
2023-05-16 9:11 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230516091132.1698684-3-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).