This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[chip@valinux.com: [LIBSTDC++] PATCH: 'long long' support]


Would someone please accept or reject this patch?

----- Forwarded message from Chip Salzenberg <chip@valinux.com> -----

Date: Thu, 23 Dec 1999 11:35:44 -0800
From: Chip Salzenberg <chip@valinux.com>
To: libstdc++ project <libstdc++@sourceware.cygnus.com>
Subject: [LIBSTDC++] PATCH: 'long long' support

With these patches, I built a libstdc++ with 'long long' support.
I hope they'll be acceptable.  The one part I'm not sure about is the
change to _S_format_long (now _S_format_integer), which ends up using
'long long' math for all integral output.  I'll have to bench it.


1999-12-23  Chip Salzenberg  <chip@valinux.com>

	Improve 'long long' support:
	* mknumeric_limits: Use $CPPFLAGS for gen-num-limits.
	* src/Makefile.am (generated_headers): Pass $(CXX) and
	$(CPPFLAGS) to mknumeric_limits.
	* src/gen-num-limits.cc: Output limits for long long and
	unsigned long long.
	* bits/locale-facets.tcc (_S_format_type): Define as unsigned long
	or unsigned long long, depending on _GLIBCPP_USE_LONG_LONG.
	(_S_format_integer): Rename from _S_format_long.  Accept
	_S_format_type, not unsigned long.
	(num_get<>::do_get(..., unsigned long long&)): Fix typo.
	* src/locale-inst.cc (_S_format_integer): Rename from
	_S_format_long.
	(num_get<>::{get,put}): Complete variants for long long.
	stl/bits/stl_config.h (__STL_LONG_LONG): Re-enable.

Index: mknumeric_limits
===================================================================
RCS file: /cvs/libstdc++/libstdc++/mknumeric_limits,v
retrieving revision 1.19
diff -u -2 -r1.19 mknumeric_limits
--- mknumeric_limits	1999/12/15 04:52:18	1.19
+++ mknumeric_limits	1999/12/23 19:17:11
@@ -156,5 +156,5 @@
 EOF
 
-$CXX -I$BUILD_DIR \
+$CXX $CPPFLAGS -I$BUILD_DIR \
     -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
      $LDFLAGS
Index: src/Makefile.am
===================================================================
--- Makefile.am	1999/12/21 16:53:15	1.72
+++ Makefile.am	1999/12/23 19:30:13
@@ -518,5 +518,6 @@
 
 $(generated_headers): $(top_srcdir)/mknumeric_limits
-	$(SHELL) $(top_srcdir)/mknumeric_limits `pwd`/.. $(top_srcdir)
+	CXX='$(CXX)' CPPFLAGS='$(CPPFLAGS)' \
+	  $(SHELL) $(top_srcdir)/mknumeric_limits `pwd`/.. $(top_srcdir)
 	@echo timestamp > $(top_builddir)/stamp-limits
 
Index: src/gen-num-limits.cc
===================================================================
RCS file: /cvs/libstdc++/libstdc++/src/gen-num-limits.cc,v
retrieving revision 1.8
diff -u -2 -r1.8 gen-num-limits.cc
--- gen-num-limits.cc	1999/10/10 02:58:38	1.8
+++ gen-num-limits.cc	1999/12/23 19:17:11
@@ -64,5 +64,6 @@
 //
 // Integer types: bool, char, signed char, unsigned char, wchar_t,
-// short, unsigned short, int, unsigned, long, unsigned long
+// short, unsigned short, int, unsigned, long, unsigned long,
+// and possibly long long and unsigned long long
 //
 // Here ISO 14882 disagrees with LIA-1 in stating bool to be an
@@ -135,4 +136,7 @@
 SPECIALIZE_TRAPPING(unsigned int);
 SPECIALIZE_TRAPPING(unsigned long);
+#if _GLIBCPP_USE_LONG_LONG
+SPECIALIZE_TRAPPING(unsigned long long);
+#endif
 
 #undef SPECIALIZE_TRAPPING
@@ -158,4 +162,8 @@
 DEFINED_TYPE_NAME(long);
 DEFINED_TYPE_NAME(unsigned long);
+#ifdef _GLIBCPP_USE_LONG_LONG
+DEFINED_TYPE_NAME(long long);
+DEFINED_TYPE_NAME(unsigned long long);
+#endif
 DEFINED_TYPE_NAME(float);
 DEFINED_TYPE_NAME(double);
@@ -251,4 +259,8 @@
 SPECIALIZE_IEC559(long);
 SPECIALIZE_IEC559(unsigned long);
+#ifdef _GLIBCPP_USE_LONG_LONG
+SPECIALIZE_IEC559(long long);
+SPECIALIZE_IEC559(unsigned long long);
+#endif
 
 #undef SPECIALIZE_IEC559
@@ -293,4 +305,8 @@
 DEFINE_EXTREMA(long, LONG_MIN, LONG_MAX);
 DEFINE_EXTREMA(unsigned long, 0, ULONG_MAX);
+#ifdef _GLIBCPP_USE_LONG_LONG
+DEFINE_EXTREMA(long long, LONG_LONG_MIN, LONG_LONG_MAX);
+DEFINE_EXTREMA(unsigned long long, 0, ULONG_LONG_MAX);
+#endif
 DEFINE_EXTREMA(float, FLT_MIN, FLT_MAX);
 DEFINE_EXTREMA(double, DBL_MIN, DBL_MAX);
@@ -651,4 +667,9 @@
     type_trait<long>();
     type_trait<unsigned long>();
+
+#ifdef _GLIBCPP_USE_LONG_LONG
+    type_trait<long long>();
+    type_trait<unsigned long long>();
+#endif
 
     type_trait<float>();
Index: src/locale-inst.cc
===================================================================
RCS file: /cvs/libstdc++/libstdc++/src/locale-inst.cc,v
retrieving revision 1.18
diff -u -2 -r1.18 locale-inst.cc
--- locale-inst.cc	1999/12/18 10:16:41	1.18
+++ locale-inst.cc	1999/12/23 19:17:12
@@ -252,6 +252,6 @@
   template 
     ostreambuf_iter
-    _S_format_long<char, ostreambuf_iter>
-    (ostreambuf_iter, ios_base &, char, bool, unsigned long);
+    _S_format_integer<char, ostreambuf_iter>
+    (ostreambuf_iter, ios_base &, char, bool, _S_format_type);
 
 #ifdef _GLIBCPP_USE_WCHAR_T
@@ -280,6 +280,6 @@
   template 
     wostreambuf_iter
-    _S_format_long<wchar_t, wostreambuf_iter>
-    (wostreambuf_iter, ios_base &, wchar_t, bool, unsigned long);
+    _S_format_integer<wchar_t, wostreambuf_iter>
+    (wostreambuf_iter, ios_base &, wchar_t, bool, _S_format_type);
 #endif
 
Index: bits/locale_facets.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/locale_facets.h,v
retrieving revision 1.13
diff -u -2 -r1.13 locale_facets.h
--- locale_facets.h	1999/12/20 20:05:38	1.13
+++ locale_facets.h	1999/12/23 19:17:23
@@ -908,12 +908,13 @@
 
 #ifdef _GLIBCPP_USE_LONG_LONG
-      iter_type 
+      iter_type
       get(iter_type __in, iter_type __end, ios_base& __io,
-	  ios_base::iostate& __err, long long& __v) const;
+	  ios_base::iostate& __err, long long& __v) const
+      { return do_get(__in, __end, __io, __err, __v); }
 #endif
 
       iter_type 
       get(iter_type __in, iter_type __end, ios_base& __io,
-	  ios_base::iostate& __err, unsigned short& __v) const
+	  ios_base::iostate& __err, unsigned short& __v)  const
       { return do_get(__in, __end, __io, __err, __v); }
 
@@ -1056,14 +1057,20 @@
       { return do_put(__s, __f, __fill, __v); }
 
+      iter_type 
+      put(iter_type __s, ios_base& __f, char_type __fill, 
+	  unsigned long __v) const
+      { return do_put(__s, __f, __fill, __v); }
+
 #ifdef _GLIBCPP_USE_LONG_LONG 
       iter_type 
-      put(iter_type __s, ios_base& __f, char_type __fill, long long __v) const
+      put(iter_type __s, ios_base& __f, char_type __fill,
+	  long long __v) const
       { return do_put(__s, __f, __fill, __v); }
-#endif
 
       iter_type 
-      put(iter_type __s, ios_base& __f, char_type __fill, 
-	  unsigned long __v) const
+      put(iter_type __s, ios_base& __f, char_type __fill,
+	  unsigned long long __v) const
       { return do_put(__s, __f, __fill, __v); }
+#endif
 
       iter_type 
@@ -1093,11 +1100,16 @@
       do_put(iter_type, ios_base&, char_type __fill, long __v) const;
 
+      virtual iter_type 
+      do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
+
 #ifdef _GLIBCPP_USE_LONG_LONG 
       virtual iter_type 
-      do_put(iter_type, ios_base&, char_type __fill, long long __v) const;
-#endif
+      do_put(iter_type, ios_base&, char_type __fill,
+	     long long __v) const;
 
       virtual iter_type 
-      do_put(iter_type, ios_base&, char_type __fill, unsigned long) const;
+      do_put(iter_type, ios_base&, char_type __fill,
+	     unsigned long long __v) const;
+#endif
 
       virtual iter_type 
Index: bits/locale_facets.tcc
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/locale_facets.tcc,v
retrieving revision 1.22
diff -u -2 -r1.22 locale_facets.tcc
--- locale_facets.tcc	1999/12/18 10:16:41	1.22
+++ locale_facets.tcc	1999/12/23 19:17:25
@@ -645,5 +645,5 @@
       errno = 0;
       __v = strtoull(__xtrc, &__sanity, __base);
-      if !((__sanity != __xtrc && *__sanity == '\0' && errno == 0))
+      if (!(__sanity != __xtrc && *__sanity == '\0' && errno == 0))
 	__err |= ios_base::failbit;
       
@@ -862,5 +862,5 @@
 	{
 	  unsigned long __uv = __v;
-	  return _S_format_long(__s, __io, __fill, false, __uv);
+	  return _S_format_integer(__s, __io, __fill, false, __uv);
 	}
       else
@@ -909,11 +909,17 @@
     }
 
+#ifdef _GLIBCPP_USE_LONG_LONG
+  typedef unsigned long long _S_format_type;
+#else
+  typedef unsigned long _S_format_type;
+#endif
+
   template <typename _CharT, typename _OutIter>
     _OutIter
-    _S_format_long(_OutIter __s, ios_base& __io, _CharT __fill, bool __neg,
-		   unsigned long __v)
+    _S_format_integer(_OutIter __s, ios_base& __io, _CharT __fill, bool __neg,
+		      _S_format_type __v)
     {
       // Leave room for "+/-," "0x," and commas.
-      const long _M_room = numeric_limits<unsigned long>::digits10 * 2 + 4;
+      const size_t _M_room = numeric_limits<_S_format_type>::digits10 * 2 + 4;
       _CharT __digits[_M_room];
       _CharT* __front = __digits + _M_room;
@@ -990,5 +996,5 @@
 	  __uv = -__uv; 
 	}
-      return _S_format_long(__s, __io, __fill, __neg, __uv);
+      return _S_format_integer(__s, __io, __fill, __neg, __uv);
     }
 
@@ -1006,5 +1012,5 @@
 	  __uv = -__uv; 
 	}
-      return _S_format_long(__s, __b, __fill, __neg, __uv);
+      return _S_format_integer(__s, __b, __fill, __neg, __uv);
     }
 #endif
@@ -1015,5 +1021,14 @@
     do_put(iter_type __s, ios_base& __io, char_type __fill, 
 	   unsigned long __v) const
-    { return _S_format_long(__s, __io, __fill, false, __v); }
+    { return _S_format_integer(__s, __io, __fill, false, __v); }
+
+#ifdef _GLIBCPP_USE_LONG_LONG 
+  template <typename _CharT, typename _OutIter>
+    _OutIter 
+    num_put<_CharT, _OutIter>::
+    do_put(iter_type __s, ios_base& __io, char_type __fill, 
+	   unsigned long long __v) const
+    { return _S_format_integer(__s, __io, __fill, false, __v); }
+#endif
 
   // The following code uses sprintf() to convert floating point
@@ -1170,6 +1185,6 @@
       __io.flags(__fmt & __fmtmask | (ios_base::hex | ios_base::showbase));
       try {
-	_OutIter __s2 = _S_format_long(__s, __io, __fill, false, 
-				       reinterpret_cast<unsigned long>(__v));
+	_OutIter __s2 = _S_format_integer(__s, __io, __fill, false, 
+					 reinterpret_cast<unsigned long>(__v));
 	__io.flags(__fmt);
 	return __s2;
Index: stl/bits/stl_config.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/stl/bits/stl_config.h,v
retrieving revision 1.22
diff -u -2 -r1.22 stl_config.h
--- stl_config.h	1999/09/09 04:40:34	1.22
+++ stl_config.h	1999/12/23 19:17:26
@@ -270,10 +270,7 @@
 #     define __STL_USE_EXCEPTIONS
 #   endif
-/// 1998-10-27 ncm, support for long long elsewhere is not ready yet. 
-#if 0
 #   ifndef __STRICT_ANSI__
 #     define __STL_LONG_LONG
 #   endif
-#endif
 # endif
 



-- 
Chip Salzenberg             - a.k.a. -              <chip@valinux.com>
     "Fleagal.  Bingo.  Drooper.  Snork.  They're cops."   //MST3K


----- End forwarded message -----

-- 
Chip Salzenberg             - a.k.a. -              <chip@valinux.com>
     "Fleagal.  Bingo.  Drooper.  Snork.  They're cops."   //MST3K

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]