This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: __intN patch 3/5: main __int128 -> __intN conversion.
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Tue, 23 Sep 2014 20:03:15 +0100
- Subject: Re: __intN patch 3/5: main __int128 -> __intN conversion.
- Authentication-results: sourceware.org; auth=none
- References: <201408132211 dot s7DMBGBu016387 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1408212030310 dot 16900 at digraph dot polyomino dot org dot uk> <201408212123 dot s7LLNPIQ018746 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1408212131060 dot 16900 at digraph dot polyomino dot org dot uk> <201408220515 dot s7M5Fhpa007479 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1408221051550 dot 5292 at digraph dot polyomino dot org dot uk> <201408221924 dot s7MJOcjB022631 at greed dot delorie dot com> <Pine dot LNX dot 4 dot 64 dot 1408222013390 dot 16713 at digraph dot polyomino dot org dot uk> <201408260303 dot s7Q33nqm024601 at greed dot delorie dot com>
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__)