This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Minor follow-ups to the std::random work


Hi,

tested x86_64-linux, without PCHs too, committed to mainline.

Paolo.

/////////////////////
2009-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/tr1_impl/random: Remove, empty.
	* include/tr1_impl/random.tcc: Likewise.

	* include/std/random: Minor clean-ups, formatting fixes, adjust
	copyright years.
	* include/bits/random.tcc: Likewise.
	* include/bits/random.h: Likewise.
	* include/tr1/random: Likewise.
	* include/tr1/random.tcc: Likewise.
	* include/tr1/random.h: Likewise.

Index: include/tr1_impl/random
===================================================================
Index: include/tr1_impl/random.tcc
===================================================================
Index: include/std/random
===================================================================
--- include/std/random	(revision 145491)
+++ include/std/random	(working copy)
@@ -1,6 +1,6 @@
 // <random> -*- C++ -*-
 
-// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -40,10 +40,6 @@
 # include <c++0x_warning.h>
 #else
 
-#if defined(_GLIBCXX_INCLUDE_AS_TR1)
-#  error C++0x header cannot be included from TR1 header
-#endif
-
 #include <cmath>
 #include <cstdio>
 #include <cstdlib>
Index: include/bits/random.tcc
===================================================================
--- include/bits/random.tcc	(revision 145491)
+++ include/bits/random.tcc	(working copy)
@@ -1,6 +1,6 @@
 // random number generation (out of line) -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -32,14 +32,11 @@
  *  You should not attempt to use it directly.
  */
 
-#include <iostream>
-#include <vector>
 #include <numeric>
 #include <algorithm>
 
 namespace std
 {
-
   /*
    * (Further) implementation-space details.
    */
@@ -107,7 +104,7 @@
     seed(_UIntType __x0)
     {
       if ((__detail::__mod<_UIntType, 1U, 0U, __m>(__c) == 0U)
-       && (__detail::__mod<_UIntType, 1U, 0U, __m>(__x0) == 0U))
+	  && (__detail::__mod<_UIntType, 1U, 0U, __m>(__x0) == 0U))
 	_M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(1U);
       else
 	_M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(__x0);
@@ -150,7 +147,7 @@
       {
 	_UIntType __x0 = __g();
 	if ((__detail::__mod<_UIntType, 1U, 0U, __m>(__c) == 0U)
-	 && (__detail::__mod<_UIntType, 1U, 0U, __m>(__x0) == 0U))
+	    && (__detail::__mod<_UIntType, 1U, 0U, __m>(__x0) == 0U))
 	  _M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(1U);
 	else
 	  _M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(__x0);
@@ -181,9 +178,7 @@
 
       const typename __ios_base::fmtflags __flags = __os.flags();
       const _CharT __fill = __os.fill();
-      __os.flags(__ios_base::dec
-	       | __ios_base::fixed
-	       | __ios_base::left);
+      __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
       __os.fill(__os.widen(' '));
 
       __os << __lcr._M_x;
@@ -347,9 +342,7 @@
       const typename __ios_base::fmtflags __flags = __os.flags();
       const _CharT __fill = __os.fill();
       const _CharT __space = __os.widen(' ');
-      __os.flags(__ios_base::dec
-	       | __ios_base::fixed
-	       | __ios_base::left);
+      __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
       __os.fill(__space);
 
       for (size_t __i = 0; __i < __n - 1; ++__i)
@@ -487,9 +480,7 @@
       const typename __ios_base::fmtflags __flags = __os.flags();
       const _CharT __fill = __os.fill();
       const _CharT __space = __os.widen(' ');
-      __os.flags(__ios_base::dec
-	       | __ios_base::fixed
-	       | __ios_base::left);
+      __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
       __os.fill(__space);
 
       for (size_t __i = 0; __i < __r; ++__i)
@@ -550,9 +541,7 @@
       const typename __ios_base::fmtflags __flags = __os.flags();
       const _CharT __fill = __os.fill();
       const _CharT __space = __os.widen(' ');
-      __os.flags(__ios_base::dec
-	       | __ios_base::fixed
-	       | __ios_base::left);
+      __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
       __os.fill(__space);
 
       __os << __x.base() << __space << __x._M_n;
@@ -653,9 +642,7 @@
       const typename __ios_base::fmtflags __flags = __os.flags();
       const _CharT __fill = __os.fill();
       const _CharT __space = __os.widen(' ');
-      __os.flags(__ios_base::dec
-	       | __ios_base::fixed
-	       | __ios_base::left);
+      __os.flags(__ios_base::dec | __ios_base::fixed | __ios_base::left);
       __os.fill(__space);
 
       __os << __x.base();
@@ -2331,9 +2318,7 @@
     piecewise_constant_distribution<_RealType>::param_type::
     param_type()
     : _M_int(), _M_den(), _M_cp()
-    {
-      _M_initialize();
-    }
+    { _M_initialize(); }
 
   template<typename _RealType>
     template<typename _InputIteratorB, typename _InputIteratorW>
@@ -2532,9 +2517,7 @@
     piecewise_linear_distribution<_RealType>::param_type::
     param_type()
     : _M_int(), _M_den(), _M_cp(), _M_m()
-    {
-      _M_initialize();
-    }
+    { _M_initialize(); }
 
   template<typename _RealType>
     template<typename _InputIteratorB, typename _InputIteratorW>
@@ -2790,5 +2773,4 @@
 	}
       return __sum / __tmp;
     }
-
 }
Index: include/bits/random.h
===================================================================
--- include/bits/random.h	(revision 145491)
+++ include/bits/random.h	(working copy)
@@ -1,6 +1,6 @@
 // random number generation -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -64,7 +64,8 @@
   namespace __detail
   {
     template<typename _UIntType, size_t __w,
-	     bool = __w < static_cast<size_t>(std::numeric_limits<_UIntType>::digits)>
+	     bool = __w < static_cast<size_t>
+			  (std::numeric_limits<_UIntType>::digits)>
       struct _Shift
       { static const _UIntType __value = 0; };
 
@@ -74,9 +75,13 @@
 
     // XXX need constexpr
     template<typename _UIntType, size_t __w,
-	     bool = __w <static_cast<size_t>(std::numeric_limits<_UIntType>::digits)>
+	     bool = __w <static_cast<size_t>
+			 (std::numeric_limits<_UIntType>::digits)>
       struct _ShiftMin1
-      { static const _UIntType __value = __gnu_cxx::__numeric_traits<_UIntType>::max; };
+      { 
+	static const _UIntType __value =
+	  __gnu_cxx::__numeric_traits<_UIntType>::max;
+      };
 
     template<typename _UIntType, size_t __w>
       struct _ShiftMin1<_UIntType, __w, true>
Index: include/tr1/random
===================================================================
--- include/tr1/random	(revision 145491)
+++ include/tr1/random	(working copy)
@@ -1,6 +1,6 @@
 // random number generation -*- C++ -*-
 
-// Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -37,10 +37,6 @@
 
 #pragma GCC system_header
 
-#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
-#  error TR1 header cannot be included from C++0x header
-#endif
-
 #include <cmath>
 #include <cstdio>
 #include <cstdlib>
@@ -54,14 +50,10 @@
 #include <tr1/type_traits>
 #include <tr1/cmath>
 
-#if defined(_GLIBCXX_INCLUDE_AS_TR1)
-#  include <tr1/random.h>
-#else
-#  define _GLIBCXX_INCLUDE_AS_TR1
-#  define _GLIBCXX_TR1 tr1::
-#  include <tr1/random.h>
-#  undef _GLIBCXX_TR1
-#  undef _GLIBCXX_INCLUDE_AS_TR1
+#include <tr1/random.h>
+
+#ifndef _GLIBCXX_EXPORT_TEMPLATE
+# include <tr1/random.tcc>
 #endif
 
 #endif // _GLIBCXX_TR1_RANDOM
Index: include/tr1/random.tcc
===================================================================
--- include/tr1/random.tcc	(revision 145491)
+++ include/tr1/random.tcc	(working copy)
@@ -1,6 +1,6 @@
 // random number generation (out of line) -*- C++ -*-
 
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2009 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -36,7 +36,6 @@
 {
 namespace tr1
 {
-
   /*
    * (Further) implementation-space details.
    */
@@ -324,7 +323,7 @@
       if (__value == 0)
 	__value = 19780503;
 
-      std::_GLIBCXX_TR1 linear_congruential<unsigned long, 40014, 0, 2147483563>
+      std::tr1::linear_congruential<unsigned long, 40014, 0, 2147483563>
 	__lcg(__value);
 
       for (int __i = 0; __i < long_lag; ++__i)
@@ -443,7 +442,7 @@
     {
       for (int __j = 0; __j < __n; ++__j)
 #if _GLIBCXX_USE_C99_MATH_TR1
-	_M_npows[__j] = std::_GLIBCXX_TR1 ldexp(_RealType(1), -__w + __j * 32);
+	_M_npows[__j] = std::tr1::ldexp(_RealType(1), -__w + __j * 32);
 #else
         _M_npows[__j] = std::pow(_RealType(2), -__w + __j * 32);
 #endif
@@ -459,7 +458,7 @@
 
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // 512. Seeding subtract_with_carry_01 from a single unsigned long.
-      std::_GLIBCXX_TR1 linear_congruential<unsigned long, 40014, 0, 2147483563>
+      std::tr1::linear_congruential<unsigned long, 40014, 0, 2147483563>
 	__lcg(__value);
 
       this->seed(__lcg);
@@ -905,14 +904,14 @@
 	{
 	  const _RealType __m = std::floor(_M_mean);
 	  _M_lm_thr = std::log(_M_mean);
-	  _M_lfm = std::_GLIBCXX_TR1 lgamma(__m + 1);
+	  _M_lfm = std::tr1::lgamma(__m + 1);
 	  _M_sm = std::sqrt(__m);
 
 	  const _RealType __pi_4 = 0.7853981633974483096156608458198757L;
 	  const _RealType __dx = std::sqrt(2 * __m * std::log(32 * __m
 							      / __pi_4));
-	  _M_d = std::_GLIBCXX_TR1 round(std::max(_RealType(6),
-						  std::min(__m, __dx)));
+	  _M_d = std::tr1::round(std::max(_RealType(6),
+					  std::min(__m, __dx)));
 	  const _RealType __cx = 2 * __m + _M_d;
 	  _M_scx = std::sqrt(__cx / 2);
 	  _M_1cx = 1 / __cx;
@@ -1008,7 +1007,7 @@
 		  }
 
 		__reject = (__w - __e - __x * _M_lm_thr
-			    > _M_lfm - std::_GLIBCXX_TR1 lgamma(__x + __m + 1));
+			    > _M_lfm - std::tr1::lgamma(__x + __m + 1));
 
 		__reject |= __x + __m >= __thr;
 
@@ -1099,11 +1098,11 @@
 	  const _RealType __d1x =
 	    std::sqrt(__np * __1p * std::log(32 * __np
 					     / (81 * __pi_4 * __1p)));
-	  _M_d1 = std::_GLIBCXX_TR1 round(std::max(_RealType(1), __d1x));
+	  _M_d1 = std::tr1::round(std::max(_RealType(1), __d1x));
 	  const _RealType __d2x =
 	    std::sqrt(__np * __1p * std::log(32 * _M_t * __1p
 					     / (__pi_4 * __pa)));
-	  _M_d2 = std::_GLIBCXX_TR1 round(std::max(_RealType(1), __d2x));
+	  _M_d2 = std::tr1::round(std::max(_RealType(1), __d2x));
 	  
 	  // sqrt(pi / 2)
 	  const _RealType __spi_2 = 1.2533141373155002512078826424055226L;
@@ -1119,8 +1118,8 @@
 	  const _RealType __s2s = _M_s2 * _M_s2;
 	  _M_s = (_M_a123 + 2 * __s2s / _M_d2
 		  * std::exp(-_M_d2 * _M_d2 / (2 * __s2s)));
-	  _M_lf = (std::_GLIBCXX_TR1 lgamma(__np + 1)
-		   + std::_GLIBCXX_TR1 lgamma(_M_t - __np + 1));
+	  _M_lf = (std::tr1::lgamma(__np + 1)
+		   + std::tr1::lgamma(_M_t - __np + 1));
 	  _M_lp1p = std::log(__pa / __1p);
 
 	  _M_q = -std::log(1 - (__p12 - __pa) / __1p);
@@ -1248,8 +1247,8 @@
 		if (!__reject)
 		  {
 		    const _RealType __lfx =
-		      std::_GLIBCXX_TR1 lgamma(__np + __x + 1)
-		      + std::_GLIBCXX_TR1 lgamma(_M_t - (__np + __x) + 1);
+		      std::tr1::lgamma(__np + __x + 1)
+		      + std::tr1::lgamma(_M_t - (__np + __x) + 1);
 		    __reject = __v > _M_lf - __lfx + __x * _M_lp1p;
 		  }
 
@@ -1578,6 +1577,5 @@
       __os.precision(__precision);
       return __os;
     }
-
 }
 }
Index: include/tr1/random.h
===================================================================
--- include/tr1/random.h	(revision 145491)
+++ include/tr1/random.h	(working copy)
@@ -1,6 +1,6 @@
 // random number generation -*- C++ -*-
 
-// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+// Copyright (C) 2009 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -38,28 +38,10 @@
 
 #pragma GCC system_header
 
-#if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
-#  error TR1 header cannot be included from C++0x header
-#endif
-
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
-#include <string>
-#include <iosfwd>
-#include <limits>
-#include <ext/type_traits.h>
-#include <ext/numeric_traits.h>
-#include <bits/concept_check.h>
-#include <debug/debug.h>
-#include <tr1/type_traits>
-#include <tr1/cmath>
-
 namespace std
 {
 namespace tr1
 {
-
   // [5.1] Random number generation
 
   /**
@@ -2427,10 +2409,7 @@
   /* @} */ // group tr1_random_distributions_continuous
   /* @} */ // group tr1_random_distributions
   /* @} */ // group tr1_random
-
 }
 }
 
-#include <tr1/random.tcc>
-
 #endif // _GLIBCXX_TR1_RANDOM_H

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