From: Jonathan Wakely <jwakely@redhat.com>
To: David Edelsohn <dje.gcc@gmail.com>
Cc: Jakub Jelinek <jakub@redhat.com>, Iain Sandoe <iain@sandoe.co.uk>,
libstdc++ <libstdc++@gcc.gnu.org>,
GCC Patches <gcc-patches@gcc.gnu.org>,
"CHIGOT, CLEMENT" <clement.chigot@atos.net>
Subject: Re: [PATCH, libstdc++] GLIBCXX_HAVE_INT64_T
Date: Fri, 8 Jan 2021 18:37:03 +0000 [thread overview]
Message-ID: <20210108183703.GF9471@redhat.com> (raw)
In-Reply-To: <CAGWvnykMChDFMuu2fm9GnyKTYvb70Pvhz4_5bSmbVWmjZbHW0A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1432 bytes --]
On 06/01/21 19:41 -0500, David Edelsohn wrote:
>Thanks for clarifying the issue.
>
>As you implicitly point out, GCC knows the type of INT64 and defines
>the macro __INT64_TYPE__ . The revised code can use that directly,
>such as:
>
>#if defined(_GLIBCXX_HAVE_INT64_T_LONG) \
> || defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
> typedef __INT64_TYPE__ streamoff;
> #elif defined(_GLIBCXX_HAVE_INT64_T)
> typedef int64_t streamoff;
> #else
> typedef long long streamoff;
> #endif
>
>Are there any additional issues not addressed by that approach, other
>than possible further simplification?
That avoids the ABI break that Jakub pointed out. But I think we can
simplify it further, as in the attached patch.
This uses __INT64_TYPE__ if that's defined, and long long otherwise. I
think that should be equivalent in all practical cases (I can imagine
some strange target where __INT64_TYPE__ is defined by the compiler,
but int64_t isn't defined when the configure checks look for it, and
so the current code would use long long and with my patch would use
__INT64_TYPE__ which could be long ... but I think in practice that's
unlikely. It was probably more likely in older releases where the
configure test would have been done with -std=gnu++98 and so int64_t
might not have been declared by libc's <stdint.h>, but if that was the
case then any ABI break it caused happened years ago.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 4183 bytes --]
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index e4175ea3e64..f13c5d2467f 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -474,63 +474,6 @@ AC_DEFUN([GLIBCXX_CHECK_WRITEV], [
])
-dnl
-dnl Check whether int64_t is available in <stdint.h>, and define HAVE_INT64_T.
-dnl Also check whether int64_t is actually a typedef to long or long long.
-dnl
-AC_DEFUN([GLIBCXX_CHECK_INT64_T], [
-
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
-
- AC_MSG_CHECKING([for int64_t])
- AC_CACHE_VAL(glibcxx_cv_INT64_T, [
- AC_TRY_COMPILE(
- [#include <stdint.h>],
- [int64_t var;],
- [glibcxx_cv_INT64_T=yes],
- [glibcxx_cv_INT64_T=no])
- ])
-
- if test $glibcxx_cv_INT64_T = yes; then
- AC_DEFINE(HAVE_INT64_T, 1, [Define if int64_t is available in <stdint.h>.])
- AC_MSG_RESULT($glibcxx_cv_INT64_T)
-
- AC_MSG_CHECKING([for int64_t as long])
- AC_CACHE_VAL(glibcxx_cv_int64_t_long, [
- AC_TRY_COMPILE(
- [#include <stdint.h>
- template<typename, typename> struct same { enum { value = -1 }; };
- template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
- int array[same<int64_t, long>::value];], [],
- [glibcxx_cv_int64_t_long=yes], [glibcxx_cv_int64_t_long=no])
- ])
-
- if test $glibcxx_cv_int64_t_long = yes; then
- AC_DEFINE(HAVE_INT64_T_LONG, 1, [Define if int64_t is a long.])
- AC_MSG_RESULT($glibcxx_cv_int64_t_long)
- fi
-
- AC_MSG_CHECKING([for int64_t as long long])
- AC_CACHE_VAL(glibcxx_cv_int64_t_long_long, [
- AC_TRY_COMPILE(
- [#include <stdint.h>
- template<typename, typename> struct same { enum { value = -1 }; };
- template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
- int array[same<int64_t, long long>::value];], [],
- [glibcxx_cv_int64_t_long_long=yes], [glibcxx_cv_int64_t_long_long=no])
- ])
-
- if test $glibcxx_cv_int64_t_long_long = yes; then
- AC_DEFINE(HAVE_INT64_T_LONG_LONG, 1, [Define if int64_t is a long long.])
- AC_MSG_RESULT($glibcxx_cv_int64_t_long_long)
- fi
- fi
-
- AC_LANG_RESTORE
-])
-
-
dnl
dnl Check whether LFS support is available.
dnl
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 3c799be82b1..a816ff79d16 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -185,9 +185,6 @@ GLIBCXX_CHECK_STDIO_PROTO
GLIBCXX_CHECK_MATH11_PROTO
GLIBCXX_CHECK_UCHAR_H
-# For the streamoff typedef.
-GLIBCXX_CHECK_INT64_T
-
# For LFS support.
GLIBCXX_CHECK_LFS
diff --git a/libstdc++-v3/include/bits/postypes.h b/libstdc++-v3/include/bits/postypes.h
index 718ff44628c..d2fbfc35dee 100644
--- a/libstdc++-v3/include/bits/postypes.h
+++ b/libstdc++-v3/include/bits/postypes.h
@@ -39,32 +39,6 @@
#include <cwchar> // For mbstate_t
-// XXX If <stdint.h> is really needed, make sure to define the macros
-// before including it, in order not to break <tr1/cstdint> (and <cstdint>
-// in C++11). Reconsider all this as soon as possible...
-#if (defined(_GLIBCXX_HAVE_INT64_T) && !defined(_GLIBCXX_HAVE_INT64_T_LONG) \
- && !defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG))
-
-#ifndef __STDC_LIMIT_MACROS
-# define _UNDEF__STDC_LIMIT_MACROS
-# define __STDC_LIMIT_MACROS
-#endif
-#ifndef __STDC_CONSTANT_MACROS
-# define _UNDEF__STDC_CONSTANT_MACROS
-# define __STDC_CONSTANT_MACROS
-#endif
-#include <stdint.h> // For int64_t
-#ifdef _UNDEF__STDC_LIMIT_MACROS
-# undef __STDC_LIMIT_MACROS
-# undef _UNDEF__STDC_LIMIT_MACROS
-#endif
-#ifdef _UNDEF__STDC_CONSTANT_MACROS
-# undef __STDC_CONSTANT_MACROS
-# undef _UNDEF__STDC_CONSTANT_MACROS
-#endif
-
-#endif
-
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -84,12 +58,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Note: In versions of GCC up to and including GCC 3.3, streamoff
* was typedef long.
*/
-#ifdef _GLIBCXX_HAVE_INT64_T_LONG
- typedef long streamoff;
-#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
- typedef long long streamoff;
-#elif defined(_GLIBCXX_HAVE_INT64_T)
- typedef int64_t streamoff;
+#ifdef __INT64_TYPE__
+ typedef __INT64_TYPE__ streamoff;
#else
typedef long long streamoff;
#endif
next prev parent reply other threads:[~2021-01-08 18:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 18:38 David Edelsohn
2021-01-06 18:55 ` Marc Glisse
2021-01-06 19:11 ` David Edelsohn
2021-01-06 19:37 ` Jakub Jelinek
2021-01-06 21:20 ` David Edelsohn
2021-01-06 21:41 ` Jakub Jelinek
2021-01-06 23:01 ` David Edelsohn
2021-01-06 23:39 ` Jakub Jelinek
2021-01-06 23:45 ` Jakub Jelinek
2021-01-07 0:41 ` David Edelsohn
2021-01-08 18:37 ` Jonathan Wakely [this message]
2021-01-08 18:52 ` Jakub Jelinek
2021-01-08 20:35 ` David Edelsohn
2021-04-29 20:06 ` David Edelsohn
2021-04-29 20:23 ` Jonathan Wakely
2021-04-30 19:31 ` Jonathan Wakely
2021-04-30 20:18 ` David Edelsohn
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=20210108183703.GF9471@redhat.com \
--to=jwakely@redhat.com \
--cc=clement.chigot@atos.net \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=iain@sandoe.co.uk \
--cc=jakub@redhat.com \
--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).