[libstdc++] Inconsistent detection of __int128

Jonathan Wakely jwakely@redhat.com
Tue May 4 11:12:03 GMT 2021


On 30/04/21 16:24 -0400, David Edelsohn via Libstdc++ wrote:
>On Fri, Jan 8, 2021 at 11:10 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>>
>> On 03/01/21 22:26 -0500, David Edelsohn via Libstdc++ wrote:
>> >On Sun, Jan 3, 2021 at 9:45 PM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> >>
>> >> On Mon, 4 Jan 2021, 00:44 David Edelsohn via Libstdc++, <libstdc++@gcc.gnu.org> wrote:
>> >>>
>> >>> Or is there some other reason that _GLIBCXX_USE_INT128 and
>> >>> __SIZEOF_INT128__ are used in different contexts?
>> >>
>> >> Yes.
>> >>
>> >> I'll reply when I'm back from taking some time off. Probably Wednesday.
>> >
>> >If the uses of _GLIBCXX_USE_INT128 in libstdc++ headers specifically
>> >are checking if __int128 type is different than "long" and "long
>> >long", as opposed to the availability of the __int128, can c++config.h
>>
>> Yes, the test is not just "is __int128 a valid type?" but "should we
>> use __int128 as a larger integer type?"
>>
>> We used to use it more widely, but many places that use __int128
>> conditionally now check __GLIBCXX_INT_N_0 instead, because that is
>> defined when __int128 is available and we're not compiling in a
>> "strict ansi" dialect.
>>
>> Of the two remaining uses of _GLIBCXX_USE_INT128 I think one is wrong
>> and should test __SIZEOF__INT128__ directly. We specifically do want
>> to use unsigned __int128 in __to_chars_unsigned_type even if it's the
>> same as a standard type.
>>
>> So that leaves one remaining use, and I think that should do as you
>> suggest here ...
>>
>> >define _GLIBCXX_USE_INT128 by comparing __SIZEOF_INT128__ to
>> >__SIZEOF_LONG_LONG__ and __SIZEOF_LONG__ instead of the libstdc++
>> >configure template typename test?
>>
>> Yes, that seems fine. But since we only need it in one place, let's
>> just do that test in that one place. It makes the purpose of the test
>> more explicit, and so you don't need to look up what
>> _GLIBCXX_USE_INT128 means and when it's true.
>>
>> Does the attached patch work for you?
>
>Hi, Jonathan
>
>Thanks for pushing the INT64_T patch.
>
>I tested your revised patch in January and it works perfectly.
>
>Could you push your INT128 patch to trunk when you have a moment?
>
>Thanks, David

I've pushed the attached to trunk after testing on powerpc-aix and
x86_64-linux.

Contrary to what I said in January, I think both sues of
_GLIBCXX_USE_INT128 do want to only use __int128 if it's larger than
long long. For __to_chars_unsigned_type there's no point trying to use
unsigned __int128 if it's the same size as unsigned long long, because
we'd already have chosen unsigned long long.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 4215 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20210504/86da6207/attachment.bin>


More information about the Libstdc++ mailing list