__intN patch 3/5: main __int128 -> __intN conversion.
Jonathan Wakely
jwakely@redhat.com
Tue Sep 23 19:03:00 GMT 2014
On 25/08/14 23:03 -0400, DJ Delorie wrote:
>
>> I'd like to see the updated version of the whole of patch 3 (tested
>> to be actually independent of the other patches) for review, though
>> I won't be reviewing the C++ parts.
>
>Here it is. Tested on x86_64. I include the msp430-modes.def patch
>for demonstration purposes although obviously msp430's __int20 won't
>work without the other patches.
[snip]
>* libstdc++-v3/
> * src/c++11/limits.cc: Add support for __intN types.
> * include/std/type_traits: Likewise.
> * include/std/limits: Likewise.
> * include/c_std/cstdlib: Likewise.
> * include/bits/cpp_type_traits.h: Likewise.
> * include/c_global/cstdlib: Likewise.
These libstdc++ changes are OK for trunk.
Just one question about the include/std/limits changes below.
It seems that __glibcxx_signed_b isn't strictly necessary as it
doesn't use the B argument, so is it just there for consistency?
>Index: libstdc++-v3/include/std/limits
>===================================================================
>--- libstdc++-v3/include/std/limits (revision 214383)
>+++ libstdc++-v3/include/std/limits (working copy)
>@@ -122,27 +122,38 @@
> #ifndef __glibcxx_long_double_tinyness_before
> # define __glibcxx_long_double_tinyness_before false
> #endif
>
> // You should not need to define any macros below this point.
>
>-#define __glibcxx_signed(T) ((T)(-1) < 0)
>+#define __glibcxx_signed_b(T,B) ((T)(-1) < 0)
>
>-#define __glibcxx_min(T) \
>- (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0)
>+#define __glibcxx_min_b(T,B) \
>+ (__glibcxx_signed_b (T,B) ? -__glibcxx_max_b (T,B) - 1 : (T)0)
>
>-#define __glibcxx_max(T) \
>- (__glibcxx_signed (T) ? \
>- (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
>+#define __glibcxx_max_b(T,B) \
>+ (__glibcxx_signed_b (T,B) ? \
>+ (((((T)1 << (__glibcxx_digits_b (T,B) - 1)) - 1) << 1) + 1) : ~(T)0)
>
>-#define __glibcxx_digits(T) \
>- (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
>+#define __glibcxx_digits_b(T,B) \
>+ (B - __glibcxx_signed_b (T,B))
>
> // The fraction 643/2136 approximates log10(2) to 7 significant digits.
>+#define __glibcxx_digits10_b(T,B) \
>+ (__glibcxx_digits_b (T,B) * 643L / 2136)
>+
>+#define __glibcxx_signed(T) \
>+ __glibcxx_signed_b (T, sizeof(T) * __CHAR_BIT__)
More information about the Libstdc++
mailing list