+2004-10-11  Benjamin Kosnik  <bkoz@redhat.com>
+
+       PR libstdc++/16614 continued.
+       * include/ext/mt_allocator.h
+       (__per_type_pool_policy::_S_get_pool): Use saner defaults based on
+       specific type characteristics.
+       (__pool_base): Add constructor that takes a _Tune argument.
+       (__pool): Same.
+       * testsuite/ext/mt_allocator/tune-2.cc: Adjust default.
+       * testsuite/ext/mt_allocator/tune-4.cc: Same.
+       * testsuite/ext/mt_allocator/tune-3.cc: Same.
+
 2004-10-11  Joachim Kuebart  <kuebart@mathematik.uni-ulm.de>
            Paolo Carlini  <pcarlini@suse.de>
 
 
     explicit __pool_base() 
     : _M_options(_Tune()), _M_binmap(NULL), _M_init(false) { }
 
+    explicit __pool_base(const _Tune& __tune) 
+    : _M_options(__tune), _M_binmap(NULL), _M_init(false) { }
+
   protected:
     // Configuration options.
     _Tune                      _M_options;
        _M_once = __tmp;
       }
 
+      explicit __pool(const __pool_base::_Tune& __tune) 
+      : __pool_base(__tune), _M_bin(NULL), _M_bin_size(1), 
+      _M_thread_freelist(NULL) 
+      {
+       // On some platforms, __gthread_once_t is an aggregate.
+       __gthread_once_t __tmp = __GTHREAD_ONCE_INIT;
+       _M_once = __tmp;
+      }
+
       ~__pool();
 
     private:
       explicit __pool() 
       : _M_bin(NULL), _M_bin_size(1) { }
 
+      explicit __pool(const __pool_base::_Tune& __tune) 
+      : __pool_base(__tune), _M_bin(NULL), _M_bin_size(1) { }
+
       ~__pool();
 
     private:
       static __pool_type&
       _S_get_pool() 
       { 
-       static __pool_type _S_pool;
+       // Sane defaults for the __pool_type.
+       const static size_t __align = __alignof__(_Tp) >= sizeof(typename __pool_type::_Block_record) ? __alignof__(_Tp) : sizeof(typename __pool_type::_Block_record);
+       static __pool_base::_Tune _S_tune(__align, sizeof(_Tp) * 128, (sizeof(_Tp) * 2) >= __align ? sizeof(_Tp) * 2 : __align, __pool_type::_Tune::_S_chunk_size, __pool_type::_Tune::_S_max_threads, __pool_type::_Tune::_S_freelist_headroom, getenv("GLIBCXX_FORCE_NEW") ? true : false);
+       static __pool_type _S_pool(_S_tune);
        return _S_pool;
       }
 
       static __pool_type&
       _S_get_pool( ) 
       { 
-       static __pool_type _S_pool;
+       // Sane defaults for the __pool_type.
+       const static size_t __align = __alignof__(_Tp) >= sizeof(typename __pool_type::_Block_record) ? __alignof__(_Tp) : sizeof(typename __pool_type::_Block_record);
+       static __pool_base::_Tune _S_tune(__align, sizeof(_Tp) * 128, (sizeof(_Tp) * 2) >= __align ? sizeof(_Tp) * 2 : __align, __pool_type::_Tune::_S_chunk_size, __pool_type::_Tune::_S_max_threads, __pool_type::_Tune::_S_freelist_headroom, getenv("GLIBCXX_FORCE_NEW") ? true : false);
+       static __pool_type _S_pool(_S_tune);
        return _S_pool;
       }
 
     class __mt_alloc : public __mt_alloc_base<_Tp>, _Poolp
     {
     public:
-      typedef size_t                    size_type;
-      typedef ptrdiff_t                 difference_type;
-      typedef _Tp*                      pointer;
-      typedef const _Tp*                const_pointer;
-      typedef _Tp&                      reference;
-      typedef const _Tp&                const_reference;
-      typedef _Tp                       value_type;
-      typedef _Poolp                   __policy_type;
-      typedef typename _Poolp::__pool_type       __pool_type;
+      typedef size_t                           size_type;
+      typedef ptrdiff_t                        difference_type;
+      typedef _Tp*                             pointer;
+      typedef const _Tp*                       const_pointer;
+      typedef _Tp&                             reference;
+      typedef const _Tp&                       const_reference;
+      typedef _Tp                              value_type;
+      typedef _Poolp                           __policy_type;
+      typedef typename _Poolp::__pool_type     __pool_type;
 
       template<typename _Tp1, typename _Poolp1 = _Poolp>
         struct rebind
     {
       this->_S_initialize_once();
 
-      // Requests larger than _M_max_bytes are handled by new/delete
-      // directly.
+      // Requests larger than _M_max_bytes are handled by operator
+      // new/delete directly.
       __pool_type& __pool = this->_S_get_pool();
       const size_t __bytes = __n * sizeof(_Tp);
       if (__pool._M_check_threshold(__bytes))
 
   typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
   typedef __gnu_cxx::__pool_base::_Tune tune_type;
 
-  tune_type t_default;
   tune_type t_opt(16, 5120, 32, 5120, 20, 10, false);
   tune_type t_single(16, 5120, 32, 5120, 1, 10, false);
 
   allocator_type a;
-  tune_type t1 = a._M_get_options();  
-  VERIFY( t1._M_align == t_default._M_align );
+  tune_type t_default = a._M_get_options();
+  tune_type t1 = t_default; 
   a._M_set_options(t_opt);
   tune_type t2 = a._M_get_options();
   VERIFY( t1._M_align != t2._M_align );
 
   typedef _Cp policy_type;
   typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
 
-  tune_type t_default;
   tune_type t_opt(16, 5120, 32, 5120, 20, 10, false);
   tune_type t_single(16, 5120, 32, 5120, 1, 10, false);
 
   // First instances assured.
   allocator_type a;
-  tune_type t1 = a._M_get_options();
+  tune_type t_default = a._M_get_options();
+  tune_type t1 = t_default;
   tune_type t2;
   if (test_policy<policy_type>::per_type())
     {
 
 {
   int i;
   int j;
+  int k;
 };
 
 // Tune characteristics, two of different instantiations
   typedef _Cp policy_type;
 
   typedef __gnu_cxx::__mt_alloc<value_type, policy_type> allocator_type;
-  tune_type t_default;
   tune_type t_opt(16, 5120, 32, 5120, 20, 10, false);
   tune_type t_single(16, 5120, 32, 5120, 1, 10, false);
 
   allocator_type a;
-  tune_type t1 = a._M_get_options();
+  tune_type t_default = a._M_get_options();
+  tune_type t1 = t_default;
   tune_type t2;
   if (test_policy<policy_type>::per_type())
     {
-      VERIFY( t1._M_align == t_default._M_align );
       a._M_set_options(t_opt);
       t2 = a._M_get_options();  
       VERIFY( t1._M_align != t2._M_align );
   // Both policy_type and rebind_type::policy_type have same characteristics.
   if (test_policy<policy_type>::per_type())
     {
-      VERIFY( t3._M_align == t_default._M_align );
       a2._M_set_options(t_opt);
       t4 = a2._M_get_options();
       VERIFY( t3._M_align != t4._M_align );