[PATCH, libstdc++] GLIBCXX_HAVE_INT64_T
Wed Jan 6 21:20:22 GMT 2021
On Wed, Jan 6, 2021 at 2:37 PM Jakub Jelinek <email@example.com> wrote:
> On Wed, Jan 06, 2021 at 01:38:25PM -0500, David Edelsohn via Gcc-patches wrote:
> > Is this an acceptable solution to determine the value at compile-time?
> This looks wrong to me. The fact that long is 64-bit doesn't imply that
> int64_t as defined by stdint.h must be long, it could be long long too.
> And while e.g. for C it doesn't really matter much whether streamoff
> will be long or long long if those two have the same precision,
> for C++ it matters a lot (affects mangling etc.).
Your response doesn't correspond to the patch nor to what I described.
Nowhere did I say that int64_t must correspond to "long". The patch
specifically chooses "long" or "long long" based on the
__SIZEOF_LONG__ *and* __SIZEOF_LONG_LONG__.
Currently libstdc++ configure tests for the type at configuration
time. My patch changes the behavior to retain the test for the type
at configure time but chooses "long" or "long long" at compile time.
I don't unilaterally choose "long" or "long long" as the type, but
rely on the configure test to ensure that __int64_t is a typedef for
either "long" or "long long".
The patch does assume that if __int64_t is a typedef for "long" or
"long long" and this is a 32/64 multilib, then the typedef for the
other 32/64 mode is an equivalent typedef, which is the case for
GLIBC, AIX, and other systems that I have checked.
> > diff --git a/libstdc++-v3/include/bits/postypes.h
> > b/libstdc++-v3/include/bits/postypes.h
> > index cb44cfe1396..81b9c4c6ae5 100644
> > --- a/libstdc++-v3/include/bits/postypes.h
> > +++ b/libstdc++-v3/include/bits/postypes.h
> > @@ -84,10 +84,15 @@ _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
> > +#if defined(_GLIBCXX_HAVE_INT64_T_LONG) \
> > + || defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
> > +
> > +#if __SIZEOF_LONG__ == 8
> > typedef long streamoff;
> > -#elif defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
> > +#elif __SIZEOF_LONG_LONG__ == 8
> > typedef long long streamoff;
> > +#endif
> > +
> > #elif defined(_GLIBCXX_HAVE_INT64_T)
> > typedef int64_t streamoff;
> > #else
More information about the Libstdc++