stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r660350 [1/2] - in /stdcxx/branches/4.3.x: etc/config/src/ include/loc/ include/rw/ src/ tests/include/ tests/localization/ tests/src/
Date Tue, 27 May 2008 01:51:31 GMT
Author: sebor
Date: Mon May 26 18:51:19 2008
New Revision: 660350

URL: http://svn.apache.org/viewvc?rev=660350&view=rev
Log:
2008-05-26  Martin Sebor  <sebor@roguewave.com>

	Merged revs 654288, 658434, 653946, 658425, 659155, 659199,
	656914,	654288, 653279, 655960, 655995, and 658807 from
	branches/4.2.x.

	2008-05-07  Martin Sebor  <sebor@roguewave.com>

	STDCXX-913
	* include/rw/_iosfailure.h (__rw_badbit_set, __rw_eofbit_set,
	__rw_failbit_set): Explicitly declared virtual dtors.
	* src/exception.cpp (__rw_badbit_set, __rw_eofbit_set,
	__rw_failbit_set): Defined virtual dtors out of line to
	reduce code bloat and silence gcc 4.3 warning: inlining
	failed, call is unlikely and code size would grow.

	2008-05-20  Martin Sebor  <sebor@roguewave.com>

	STDCXX-941
	* include/loc/_ctype.h (narrow): Silenced the useless HP aCC 3
	Warning (suggestion) 887: Type 'unsigned int' is smaller than
	type 'unsigned long', unwanted widening in value may result.
	Regression introduced in 4.2.1 (in r649646).

	2008-05-06  Travis Vitek  <vitek@roguewave.com>

	STDCXX-845
	* src/messages.cpp (__rw_manage_cat_data): Employ a simple paging
	scheme and one level of indirection to avoid moving catalog data
	around when adding or removing message catalogs from the cache.
	Ensure that we do cleanup when closing last catalog regardless of
	the order that catalogs are closed.
	* src/catalog.cpp (catclose): Fix off-by-one error exposed with
	updated test.
	* tests/localization/22.locale.messages.mt.cpp: Updated to test
	multiple catalogs with multiple locales simultaneously.

	2008-05-20  Martin Sebor  <sebor@roguewave.com>

	STDCXX-940
	* src/ti_numpunct.cpp: Silenced the useless HP aCC 6 remark
	#4244-D: extern storage class used with a function definition
	while carefully avoiding HP aCC 3 Warning (suggestion) #933:
	Null macro argument #1 for macro.
	* src/ti_num_put.cpp: Same.
	* src/ti_num_get.cpp: Same.

	2008-05-22  Martin Sebor  <sebor@roguewave.com>

	* src/version.cpp (__rw_ident): Added a comment.

	2008-05-22  Martin Sebor  <sebor@roguewave.com>

	* src/fpclass.h: New header with declarations of floating point
	classification functions mirroring the equivalent macros defined
	by C99 in <math.h>.
	* src/num_put.cpp (__rw_isfinite, __rw_signbit, __rw_isinf,
	__rw_isnan, __rw_isqnan, __rw_issnan): Moved inline functions to
	the new fpclass.h header.

	2008-05-15  Martin Sebor  <sebor@roguewave.com>

	STDCXX-937
	* src/limits.cpp: Used the quoted form of an #include directive
	to #include the <limits> header twice to fool Sun C++, otherwise
	the compiler fails to #include the header twice.

	2008-05-07  Martin Sebor  <sebor@roguewave.com>

	STDCXX-913
	* include/rw/_iosfailure.h (__rw_badbit_set, __rw_eofbit_set,
	__rw_failbit_set): Explicitly declared virtual dtors.
	* src/exception.cpp (__rw_badbit_set, __rw_eofbit_set,
	__rw_failbit_set): Defined virtual dtors out of line to
	reduce code bloat and silence gcc 4.3 warning: inlining
	failed, call is unlikely and code size would grow.

	2008-05-04  Martin Sebor  <sebor@roguewave.com>

	STDCXX-908
	* etc/config/src/MMAP.cpp: New test to check for mmap() and munmap()
	in <sys/mman.h>.
	* src/mman.cpp (__rw_mmap): Avoided using mmap() when _RWSTD_NO_MMAP
	is #defined and instead dynamically allocated memory and copied the
	file into it.
	Defined _RWSTD_NO_MUNMAP when _RWSTD_NO_MMAP is #defined.
	[_RWSTD_NO_MUNMAP](__rw_munmap): Avoided calling munmap() and instead
	deallocated the block using operator delete.

	2008-05-07  Travis Vitek  <vitek@roguewave.com>

	STDCXX-536
	* tests/include/rw_thread.h (rw_thread_pool): Add timeout
	parameter with default value.
	(rw_thread_pool_timeout_expired): New function declaration.
	* tests/src/thread.cpp: (_rw_timeout_handler): New function
	to respond to alarm signals and set timeout flag.
	(rw_thread_pool_timeout_expired): New function to query
	timeout status.
	(rw_thread_pool): Set alarm based on timeout value provided.
	* tests/localization/22.locale.codecvt.mt.cpp: Add timeout
	option with default value. Poll rw_thread_pool_time_expired()
	in thread function and respond.
	* tests/localization/22.locale.cons.mt.cpp: Ditto.
	* tests/localization/22.locale.ctype.mt.cpp: Ditto.
	* tests/localization/22.locale.globals.mt.cpp: Ditto.
	* tests/localization/22.locale.messages.mt.cpp: Ditto.
	* tests/localization/22.locale.money.get.mt.cpp: Ditto.
	* tests/localization/22.locale.money.put.mt.cpp: Ditto.
	* tests/localization/22.locale.moneypunct.mt.cpp: Ditto.
	* tests/localization/22.locale.num.get.mt.cpp: Ditto.
	* tests/localization/22.locale.num.put.mt.cpp: Ditto.
	* tests/localization/22.locale.numpunct.mt.cpp: Ditto.
	* tests/localization/22.locale.statics.mt.cpp: Ditto.
	* tests/localization/22.locale.time.get.mt.cpp: Ditto.
	* tests/localization/22.locale.time.put.mt.cpp: Ditto.

	2008-05-13 Travis Vitek <vitek@roguewave.com>

	STDCXX-536
	* tests/localization/22.locale.codecvt.mt.cpp: Pass
	opt_timeout to rw_thread_pool() to enable timeouts.
	* tests/localization/22.locale.cons.mt.cpp: Ditto.
	* tests/localization/22.locale.ctype.mt.cpp: Ditto.
	* tests/localization/22.locale.globals.mt.cpp: Ditto.
	* tests/localization/22.locale.messages.mt.cpp: Ditto.
	* tests/localization/22.locale.money.get.mt.cpp: Ditto.
	* tests/localization/22.locale.money.put.mt.cpp: Ditto.
	* tests/localization/22.locale.moneypunct.mt.cpp: Ditto.
	* tests/localization/22.locale.num.get.mt.cpp: Ditto.
	* tests/localization/22.locale.num.put.mt.cpp: Ditto.
	* tests/localization/22.locale.numpunct.mt.cpp: Ditto.
	* tests/localization/22.locale.statics.mt.cpp: Ditto.
	* tests/localization/22.locale.time.get.mt.cpp: Ditto.
	* tests/localization/22.locale.time.put.mt.cpp: Ditto.

	2008-05-21  Travis Vitek  <vitek@roguewave.com>

	* tests/localization/22.locale.moneypunct.mt.cpp: Cast timeout
	to size_t to avoid conversion warnings.
	* tests/localization/22.locale.numpunct.mt.cpp: Ditto.
	* tests/localization/22.locale.globals.mt.cpp: Ditto.
	* tests/localization/22.locale.codecvt.mt.cpp: Ditto.
	* tests/localization/22.locale.cons.mt.cpp: Ditto.
	* tests/localization/22.locale.money.put.mt.cpp: Ditto.
	* tests/localization/22.locale.money.get.mt.cpp: Ditto.
	* tests/localization/22.locale.num.put.mt.cpp: Ditto.
	* tests/localization/22.locale.num.get.mt.cpp: Ditto.
	* tests/localization/22.locale.statics.mt.cpp: Ditto.
	* tests/localization/22.locale.time.put.mt.cpp: Ditto.
	* tests/localization/22.locale.time.get.mt.cpp: Ditto.
	* tests/localization/22.locale.ctype.mt.cpp: Ditto.
	* tests/localization/22.locale.messages.mt.cpp: Ditto.
	(thread_func): Poll thread timeout flag in thread loop.

Added:
    stdcxx/branches/4.3.x/etc/config/src/MMAP.cpp
      - copied unchanged from r656875, stdcxx/branches/4.2.x/etc/config/src/MMAP.cpp
    stdcxx/branches/4.3.x/src/fpclass.h
      - copied unchanged from r659252, stdcxx/branches/4.2.x/src/fpclass.h
Modified:
    stdcxx/branches/4.3.x/include/loc/_ctype.h
    stdcxx/branches/4.3.x/include/rw/_iosfailure.h
    stdcxx/branches/4.3.x/src/catalog.cpp
    stdcxx/branches/4.3.x/src/exception.cpp
    stdcxx/branches/4.3.x/src/limits.cpp
    stdcxx/branches/4.3.x/src/messages.cpp
    stdcxx/branches/4.3.x/src/mman.cpp
    stdcxx/branches/4.3.x/src/ti_num_get.cpp
    stdcxx/branches/4.3.x/src/ti_num_put.cpp
    stdcxx/branches/4.3.x/src/ti_numpunct.cpp
    stdcxx/branches/4.3.x/src/version.cpp
    stdcxx/branches/4.3.x/tests/include/rw_thread.h
    stdcxx/branches/4.3.x/tests/localization/22.locale.codecvt.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.cons.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.ctype.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.globals.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.messages.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.money.get.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.money.put.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.moneypunct.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.num.get.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.num.put.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.numpunct.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.statics.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.time.get.mt.cpp
    stdcxx/branches/4.3.x/tests/localization/22.locale.time.put.mt.cpp
    stdcxx/branches/4.3.x/tests/src/thread.cpp

Modified: stdcxx/branches/4.3.x/include/loc/_ctype.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/loc/_ctype.h?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/include/loc/_ctype.h (original)
+++ stdcxx/branches/4.3.x/include/loc/_ctype.h Mon May 26 18:51:19 2008
@@ -25,7 +25,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 2001-2005 Rogue Wave Software.
+ * Copyright 2001-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -541,7 +541,11 @@
 inline char
 ctype<wchar_t>::narrow (char_type __c, char __dfault) const
 {
-    const _RWSTD_SIZE_T __inx = _RWSTD_STATIC_CAST (_RWSTD_UWCHAR_INT_T, __c);
+    // carefully convert wchar_t to the unsigned form of its
+    // underlying integer type, avoiding sign extension and
+    // similar issues
+    const _RWSTD_UWCHAR_INT_T __inx =
+        _RWSTD_STATIC_CAST (_RWSTD_UWCHAR_INT_T, __c);
 
     // optimize away all but the first call to the virtual do_widen()
     if (   __inx < sizeof _C_narrow_tab / sizeof *_C_narrow_tab

Modified: stdcxx/branches/4.3.x/include/rw/_iosfailure.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_iosfailure.h?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/include/rw/_iosfailure.h (original)
+++ stdcxx/branches/4.3.x/include/rw/_iosfailure.h Mon May 26 18:51:19 2008
@@ -25,7 +25,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -56,11 +56,25 @@
 };
 
 
-struct _RWSTD_EXPORT __rw_badbit_set: __rw_failure { };
+// (optionally) thrown when stream sets badbit
+struct _RWSTD_EXPORT __rw_badbit_set: __rw_failure
+{
+    virtual ~__rw_badbit_set () _THROWS (());
+};
+
+
+// (optionally) thrown when stream sets eofbit
+struct _RWSTD_EXPORT __rw_eofbit_set: __rw_failure
+{
+    virtual ~__rw_eofbit_set () _THROWS (());
+};
 
-struct _RWSTD_EXPORT __rw_eofbit_set: __rw_failure { };
 
-struct _RWSTD_EXPORT __rw_failbit_set: __rw_failure { };
+// (optionally) thrown when stream sets failbit
+struct _RWSTD_EXPORT __rw_failbit_set: __rw_failure
+{
+    virtual ~__rw_failbit_set () _THROWS (());
+};
 
 }   // namespace __rw
 

Modified: stdcxx/branches/4.3.x/src/catalog.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/catalog.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/catalog.cpp (original)
+++ stdcxx/branches/4.3.x/src/catalog.cpp Mon May 26 18:51:19 2008
@@ -140,6 +140,8 @@
       __rw_catlist[j-1] = __rw_catlist[j];
     if (j < __rw_catlist.size())
       __rw_catlist[j] = 0;
+    else
+      __rw_catlist[__rw_catlist.size () - 1] = 0;
     return 0;
   }
   return -1;

Modified: stdcxx/branches/4.3.x/src/exception.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/exception.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/exception.cpp (original)
+++ stdcxx/branches/4.3.x/src/exception.cpp Mon May 26 18:51:19 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -936,8 +936,10 @@
 }
 
 
-// outline to reduce code bloat caused by compilers that emit the vtbl
-// in every translation unit containing the definition of the class
+// trivial dtors outlined to reduce code bloat caused by compilers that
+// emit the vtbl in every translation unit containing the definition of
+// the class
+
 // virtual dtor
 /* virtual */ __rw_failure::~__rw_failure () _THROWS (())
 {
@@ -945,4 +947,22 @@
 }
 
 
+/* virtual */ __rw_badbit_set::~__rw_badbit_set () _THROWS (())
+{
+    // no-op
+}
+
+
+/* virtual */ __rw_eofbit_set::~__rw_eofbit_set () _THROWS (())
+{
+    // no-op
+}
+
+
+/* virtual */ __rw_failbit_set::~__rw_failbit_set () _THROWS (())
+{
+    // no-op
+}
+
+
 }   // namespace __rw

Modified: stdcxx/branches/4.3.x/src/limits.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/limits.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/limits.cpp (original)
+++ stdcxx/branches/4.3.x/src/limits.cpp Mon May 26 18:51:19 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -31,12 +31,17 @@
 #include <rw/_defs.h>  
                        
 // define generic template and specializations
-#include <limits>
+// use the quoted form of the #include directive to fool Sun C++
+// otherwise the compiler fails to #include the header twice,
+// most likely because it makes assumptions about headers with
+// (C++) standard names
+#include "limits"
 
 #if _MSC_VER != 1300   // working around an MSVC 7.0 bug (PR #26562)
 #  undef _RWSTD_LIMITS_INCLUDED
 #  define _RWSTD_DEFINE_EXPORTS
 
    // define static data members of specializations
-#  include <limits>
+   // again, use the quoted form of the #include directive
+#  include "limits"
 #endif   // MSVC != 7.0

Modified: stdcxx/branches/4.3.x/src/messages.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/messages.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/messages.cpp (original)
+++ stdcxx/branches/4.3.x/src/messages.cpp Mon May 26 18:51:19 2008
@@ -70,6 +70,14 @@
     } loc;
 };
 
+struct __rw_open_cat_page
+{
+    static const size_t _C_size = 8;
+
+    __rw_open_cat_page* _C_next; // next page
+    __rw_open_cat_data _C_data [_C_size];
+};
+
 
 // manages a global, per-process repository of open catalogs according
 // to the following table:
@@ -90,21 +98,25 @@
 static __rw_open_cat_data*
 __rw_manage_cat_data (int &cat,  __rw_open_cat_data *pcat_data)
 {
-    // a per-process array of catalog data structs
-    static __rw_open_cat_data  catalog_buf [8];
-    static __rw_open_cat_data* catalogs = catalog_buf;
+    // a per-process array of pointers to catalog data structs
+    static __rw_open_cat_data* catalog_buf [__rw_open_cat_page::_C_size];
+    static __rw_open_cat_data** catalogs = 0;
+
+    // first page of a per-process list of pages of catalog data structs
+    static __rw_open_cat_page  catalog_page;
 
     static size_t n_catalogs      = 0;
     static size_t catalog_bufsize = sizeof catalog_buf / sizeof *catalog_buf;
     static size_t largest_cat     = 0;
-    static int    init            = 0;
 
- 
-    if (0 == init) {
+    if (!catalogs) {
+        
         for (size_t i = 0; i < catalog_bufsize; ++i) {
-            catalogs [i].catd = _RWSTD_BAD_CATD;
+            catalog_page._C_data [i].catd = _RWSTD_BAD_CATD;
+            catalog_buf [i] = &catalog_page._C_data [i];
         }
-        init = 1;
+
+        catalogs = catalog_buf;
     }
 
     if (-1 == cat) {
@@ -115,27 +127,40 @@
         if (pcat_data) {
              if (n_catalogs == catalog_bufsize) {
 
-                // reallocate buffer of facet pointers
-                __rw_open_cat_data* const tmp =
-                    new __rw_open_cat_data[n_catalogs * 2];
+                // allocate new page of catalog data
+                __rw_open_cat_page* const page =
+                    new __rw_open_cat_page;
+
+                // insert new page into singly-linked page list
+                page->_C_next = catalog_page._C_next;
+                catalog_page._C_next = page;
+
+                // initialize new page
+                for (size_t i = 0; i < __rw_open_cat_page::_C_size; ++i) {
+                    page->_C_data [i].catd = _RWSTD_BAD_CATD;
+                }
+
+                // rwallocate buffer of catalog data pointers
+                __rw_open_cat_data** const data =
+                    new __rw_open_cat_data* [n_catalogs + __rw_open_cat_page::_C_size];
 
-                memcpy (tmp, catalogs, n_catalogs * sizeof *tmp);
+                memcpy (data, catalogs, n_catalogs * sizeof *data);
                  
                 if (catalogs != catalog_buf)
                     delete[] catalogs;
 
-                catalogs         = tmp;
-                catalog_bufsize *= 2;
+                catalogs         = data;
+                catalog_bufsize += __rw_open_cat_page::_C_size;
 
-                for (size_t i = n_catalogs; i < catalog_bufsize; ++i) {
-                    catalogs [i].catd = _RWSTD_BAD_CATD;
+                for (size_t i = 0; i < __rw_open_cat_page::_C_size; ++i) {
+                    catalogs [n_catalogs + i] = &page->_C_data [i];
                 }
 
                 cat = int (n_catalogs);
-                memcpy (&catalogs [cat].loc, &pcat_data->loc,
-                        sizeof (_STD::locale));
 
-                catalogs [cat].catd = pcat_data->catd;
+                catalogs [cat]->catd = pcat_data->catd;
+                memcpy (&catalogs [cat]->loc, &pcat_data->loc,
+                        sizeof (_STD::locale));
 
                 if (size_t (cat) > largest_cat)
                     largest_cat = size_t (cat);
@@ -145,38 +170,42 @@
             else {
                 // find the first open slot and use it.
                 cat = 0;
-                while (catalogs [cat].catd != _RWSTD_BAD_CATD) {
+                while (catalogs [cat]->catd != _RWSTD_BAD_CATD) {
                     ++cat;
                 }
 
+                catalogs [cat]->catd = pcat_data->catd;
+                memcpy (&catalogs [cat]->loc, &pcat_data->loc,
+                        sizeof (_STD::locale));
+
                 if (size_t (cat) > largest_cat)
                     largest_cat = size_t (cat);
 
-                memcpy (&catalogs [cat].loc, &pcat_data->loc,
-                        sizeof (_STD::locale));
-
-                catalogs [cat].catd = pcat_data->catd;
                 ++n_catalogs;
             }
         }
     }
     else {
+
         if (0 == pcat_data) {
             // find struct and return it
             if (size_t (cat) < catalog_bufsize)
-                return catalogs + cat;
+                return catalogs [cat];
 
             return 0;
         }
 
         // initialize the struct to an invalid state
         --n_catalogs;
-        catalogs [cat].catd = _RWSTD_BAD_CATD;
+        catalogs [cat]->catd = _RWSTD_BAD_CATD;
+
         if (size_t (cat) == largest_cat) {
 
             // find the next smallest valid slot
+            largest_cat = 0;
+
             for (int i = cat; i >= 0; --i) {
-                if (catalogs [i].catd != _RWSTD_BAD_CATD) {
+                if (catalogs [i]->catd != _RWSTD_BAD_CATD) {
                     largest_cat = size_t (i);
                     break;
                 }
@@ -186,11 +215,9 @@
                 sizeof catalog_buf / sizeof *catalog_buf;
 
             if ((largest_cat < bufsize / 2) && (catalogs != catalog_buf)) {
-
                 // when there are no more open catalogs indexed beyond
-                // second half of the statically allocated repository, copy
-                // the open catalogs back into the statically allocated
-                // repository.
+                // second half of the static pointer repository, copy
+                // the open catalog pointers back into the repository.
 
                 catalog_bufsize = bufsize;
 
@@ -198,7 +225,19 @@
                         catalog_bufsize * sizeof (*catalogs));
 
                 delete[] catalogs;
+
                 catalogs = catalog_buf;
+
+                // remove all pages, they're not in use
+                while (catalog_page._C_next)
+                {
+                    // remove next page from page list
+                    __rw_open_cat_page* page = catalog_page._C_next;
+                    catalog_page._C_next = page->_C_next;
+
+                    // deallocate that page
+                    delete page;
+                }
             }
         }
     }

Modified: stdcxx/branches/4.3.x/src/mman.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/mman.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/mman.cpp (original)
+++ stdcxx/branches/4.3.x/src/mman.cpp Mon May 26 18:51:19 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 2001-2006 Rogue Wave Software.
+ * Copyright 2001-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -36,9 +36,9 @@
 
 #include <sys/stat.h>
 
-#ifndef _MSC_VER
+#ifndef _RWSTD_NO_MMAP
 #  include <sys/mman.h>
-#else
+#elif defined (_WIN32)
 #  include <windows.h>
 #  include <io.h>
 #endif   // _MSC_VER
@@ -69,12 +69,17 @@
 
     *size = sb.st_size;
 
-#if !defined(_MSC_VER)
-    const int fd = open (fname, O_RDONLY);
 
+#ifndef _WIN32
+    const int fd = open (fname, O_RDONLY);
+   
     if (-1 == fd)
         return 0;
 
+#endif   // _WIN32
+
+#ifndef _RWSTD_NO_MMAP
+
     // On HPUX systems MAP_SHARED will prevent a second mapping of the same
     // file if the regions are overlapping; one solution is to make the 
     // mapping private.
@@ -92,7 +97,9 @@
 
     if (MAP_FAILED == data)   // failure
         return 0;
-#else
+
+#elif defined (_WIN32)
+
     HANDLE mmf = 
         CreateFile (fname, GENERIC_READ, FILE_SHARE_READ, NULL,
                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -114,6 +121,23 @@
     CloseHandle (mmf);
     CloseHandle (mmfv);
 
+#else   // no mmap() or equivalent
+
+#  ifndef _RWSTD_NO_MUNMAP
+#    define _RWSTD_NO_MUNMAP
+#  endif   // _RWSTD_NO_MUNMAP
+
+    // read() takes a size_t argument, convert off_t to it
+    const size_t mapsize = size_t (sb.st_size);
+
+    void* data = operator new (mapsize);
+    const ssize_t nread = read (fd, data, mapsize);
+
+    if (size_t (nread) != mapsize) {
+        operator delete (data);
+        data = 0;
+    }
+
 #endif  // _MSC_VER
 
     return data;
@@ -128,10 +152,12 @@
     void* pv = _RWSTD_CONST_CAST (void*, pcv);
 
     // POSIX munmap() takes a void*, but not all platforms conform
-#ifndef _MSC_VER
+#ifndef _RWSTD_NO_MUNMAP
     munmap (_RWSTD_STATIC_CAST (_RWSTD_MUNMAP_ARG1_T, pv), size);
-#else
+#elif defined (_WIN32)
     UnmapViewOfFile (pv);
+#else   // no munmap()
+    operator delete (pv);
 #endif  // _MSC_VER
 }
 

Modified: stdcxx/branches/4.3.x/src/ti_num_get.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/ti_num_get.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/ti_num_get.cpp (original)
+++ stdcxx/branches/4.3.x/src/ti_num_get.cpp Mon May 26 18:51:19 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -47,6 +47,16 @@
 
 #define TARGS_C   <char, _RWSTD_ISTREAMBUF_ITER (char) >
 
+
+#if 6 == _RWSTD_HP_aCC_MAJOR
+   // silence the useless HP aCC 6 remark 4244: extern storage class
+   // used with a function definition on the "extern _RWSTD_EXPORT"
+   // macro argument below where the redundant "extern" is there to
+   // silence HP aCC 3 Warning (suggestion) 933: Null macro argument #1
+#  pragma diag_suppress 4244
+#endif   // aCC 6
+
+
 _RWSTD_SPECIALIZE_FACET_ID (num_get, TARGS_C);
 _RWSTD_DEFINE_FACET_FACTORY (extern _RWSTD_EXPORT, num_get, TARGS_C, num_get);
 _RWSTD_SPECIALIZE_USE_FACET (num_get);

Modified: stdcxx/branches/4.3.x/src/ti_num_put.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/ti_num_put.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/ti_num_put.cpp (original)
+++ stdcxx/branches/4.3.x/src/ti_num_put.cpp Mon May 26 18:51:19 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -45,6 +45,16 @@
 
 #define TARGS_C   <char, _RWSTD_OSTREAMBUF_ITER (char) >
 
+
+#if 6 == _RWSTD_HP_aCC_MAJOR
+   // silence the useless HP aCC 6 remark 4244: extern storage class
+   // used with a function definition on the "extern _RWSTD_EXPORT"
+   // macro argument below where the redundant "extern" is there to
+   // silence HP aCC 3 Warning (suggestion) 933: Null macro argument #1
+#  pragma diag_suppress 4244
+#endif   // aCC 6
+
+
 _RWSTD_SPECIALIZE_FACET_ID (num_put, TARGS_C);
 _RWSTD_DEFINE_FACET_FACTORY (extern _RWSTD_EXPORT, num_put, TARGS_C, num_put);
 _RWSTD_SPECIALIZE_USE_FACET (num_put);

Modified: stdcxx/branches/4.3.x/src/ti_numpunct.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/ti_numpunct.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/ti_numpunct.cpp (original)
+++ stdcxx/branches/4.3.x/src/ti_numpunct.cpp Mon May 26 18:51:19 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -45,6 +45,15 @@
 #include "use_facet.h"
 
 
+#if 6 == _RWSTD_HP_aCC_MAJOR
+   // silence the useless HP aCC 6 remark 4244: extern storage class
+   // used with a function definition on the "extern _RWSTD_EXPORT"
+   // macro argument below where the redundant "extern" is there to
+   // silence HP aCC 3 Warning (suggestion) 933: Null macro argument #1
+#  pragma diag_suppress 4244
+#endif   // aCC 6
+
+
 _RWSTD_SPECIALIZE_FACET_ID (numpunct, <char>);
 _RWSTD_DEFINE_FACET_FACTORY (extern _RWSTD_EXPORT, numpunct, <char>, numpunct);
 _RWSTD_SPECIALIZE_USE_FACET (numpunct);

Modified: stdcxx/branches/4.3.x/src/version.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/src/version.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/src/version.cpp (original)
+++ stdcxx/branches/4.3.x/src/version.cpp Mon May 26 18:51:19 2008
@@ -35,6 +35,7 @@
 #ifdef _RWSTD_VER_STR
 
 extern const char __rw_ident[] = {
+    // %Z% keyword ("@(#)") retrieved by the POSIX what utility
     "@(#) Apache C++ Standard Library version " _RWSTD_VER_STR
 };
 

Modified: stdcxx/branches/4.3.x/tests/include/rw_thread.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/include/rw_thread.h?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/include/rw_thread.h (original)
+++ stdcxx/branches/4.3.x/tests/include/rw_thread.h Mon May 26 18:51:19 2008
@@ -33,6 +33,8 @@
 
 
 extern "C" {
+    typedef void* rw_thread_proc (void*);
+}    // extern "C"
 
 struct rw_thread_attr_t;
 
@@ -48,7 +50,7 @@
 _TEST_EXPORT int
 rw_thread_create (rw_thread_t*,
                   rw_thread_attr_t*,
-                  void* (*)(void*),
+                  rw_thread_proc*,
                   void*);
 
 
@@ -62,6 +64,13 @@
 // array with their id's; if (tidarray == 0), waits for all
 // threads to join and fills the aragarray with the result
 // returned from each thread
+// if (timeout != 0), then a timer will be started, and the function
+// rw_thread_pool_timeout_expired() will return true after that number
+// of seconds has passed. there is only one timer, so use timeouts
+// with caution. if you provide tidarray, you should join threads
+// before starting another pool, otherwise threads from the first
+// pool may not exit until the threads from a later second pool are
+// signalled to stop.
 // if (nthreads == SIZE_MAX), sets nthreads to the positive result
 // of rw_get_processors() plus 1, or to 2 otherwise
 // returns 0 on success, or a non-zero value indicating the thread
@@ -70,15 +79,20 @@
 rw_thread_pool (rw_thread_t*      /* tidarray */,
                 _RWSTD_SIZE_T     /* nthreads */,
                 rw_thread_attr_t* /* attr */,
-                void* (*)(void*)  /* thr_proc */,
-                void**            /* argarray */);
+                rw_thread_proc*   /* thr_proc */,
+                void**            /* argarray */,
+                _RWSTD_SIZE_T     /* timeout  */ = 0);
+
+// returns non-zero if the thread timeout flag has been set. should
+// be polled periodically by threads created by rw_thread_pool() so
+// that they know that the soft timeout has expired
+// see notes above for details
+_TEST_EXPORT int
+rw_thread_pool_timeout_expired ();
 
 // returns the number of logical processors/cores on the system,
 // or -1 on error
 _TEST_EXPORT int
 rw_get_cpus ();
 
-
-}   // extern "C"
-
 #endif   // RW_RWTHREAD_H_INCLUDED

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.codecvt.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.codecvt.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.codecvt.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.codecvt.mt.cpp Mon May 26 18:51:19 2008
@@ -45,18 +45,21 @@
 
 // default number of threads (will be adjusted to the number
 // of processors/cores later)
-int rw_opt_nthreads = 1;
+int opt_nthreads = 1;
 
 // the number of times each thread should iterate (unless specified
 // otherwise on the command line)
-int rw_opt_nloops = 5000;
+int opt_nloops = 5000;
 
 // number of locales to use
-int rw_opt_nlocales = MAX_THREADS;
+int opt_nlocales = MAX_THREADS;
 
 // should all threads share the same set of locale objects instead
 // of creating their own?
-int rw_opt_shared_locale;
+int opt_shared_locale;
+
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
 
 /**************************************************************************/
 
@@ -314,7 +317,10 @@
     const int ni = RW_COUNT_OF (nsrc);
     const int wi = RW_COUNT_OF (wsrc);
 
-    for (int i = 0; i != rw_opt_nloops; ++i) {
+    for (int i = 0; i != opt_nloops; ++i) {
+
+        if (rw_thread_pool_timeout_expired ())
+            break;
 
         const int inx = i % nlocales;
         const MyCodecvtData& data = my_codecvt_data [inx];
@@ -322,8 +328,8 @@
         // construct a named locale, get a reference to the codecvt
         // facet from it and use it to format a random money value
         const std::locale loc =
-            rw_opt_shared_locale ? data.locale_
-                                 : std::locale (data.locale_name_);
+            opt_shared_locale ? data.locale_
+                              : std::locale (data.locale_name_);
 
         const MyCodecvtData::CvtId op =
             MyCodecvtData::CvtId (i % MyCodecvtData::cvt_max);
@@ -460,7 +466,7 @@
             run_test_fill<wchar_t>
                 (loc, wsrc [inx % wi], nsrc [inx % ni], data.wchar_data_);
 
-            if (rw_opt_shared_locale)
+            if (opt_shared_locale)
                 data.locale_ = loc;
 
             nlocales += 1;
@@ -471,7 +477,7 @@
                      "failed to create locale(%#s)", name);
         }
 
-        if (nlocales == maxinx || nlocales == std::size_t (rw_opt_nlocales))
+        if (nlocales == maxinx || nlocales == std::size_t (opt_nlocales))
             break;
     }
 
@@ -482,8 +488,8 @@
     rw_info (0, 0, 0,
              "testing std::codecvt<charT> with %d thread%{?}s%{;}, "
              "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
-             rw_opt_nthreads, 1 != rw_opt_nthreads,
-             rw_opt_nloops, 1 != rw_opt_nloops,
+             opt_nthreads, 1 != opt_nthreads,
+             opt_nloops, 1 != opt_nloops,
              nlocales, int (nlocales), "%#s", locales);
 
     ///////////////////////////////////////////////////////////////////////
@@ -495,11 +501,12 @@
 
     // create and start a pool of threads and wait for them to finish
     int result = 
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     ///////////////////////////////////////////////////////////////////////
 
@@ -509,11 +516,12 @@
     test_wchar  = true;
 
     result = 
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     ///////////////////////////////////////////////////////////////////////
 
@@ -524,11 +532,12 @@
     test_wchar  = true;
 
     result = 
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     return result;
 }
@@ -541,24 +550,26 @@
 
     // set nthreads to the greater of the number of processors
     // and 2 (for uniprocessor systems) by default
-    rw_opt_nthreads = rw_get_cpus ();
-    if (rw_opt_nthreads < 2)
-        rw_opt_nthreads = 2;
+    opt_nthreads = rw_get_cpus ();
+    if (opt_nthreads < 2)
+        opt_nthreads = 2;
 
 #endif   // _RWSTD_REENTRANT
 
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.codecvt",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // must be provided
                     "|-shared-locale# ",
-                    &rw_opt_nloops,
+                    &opt_timeout,
+                    &opt_nloops,
                     int (MAX_THREADS),
-                    &rw_opt_nthreads,
-                    &rw_opt_nlocales,
+                    &opt_nthreads,
+                    &opt_nlocales,
                     &rw_opt_setlocales,
-                    &rw_opt_shared_locale);
+                    &opt_shared_locale);
 }

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.cons.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.cons.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.cons.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.cons.mt.cpp Mon May 26 18:51:19 2008
@@ -50,6 +50,9 @@
 // command line option
 int opt_combine;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -85,6 +88,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // compute an index into the array of locales
         const std::size_t linx = i % nlocales;
 
@@ -183,7 +189,7 @@
 
     // create and start a pool of threads and wait for them to finish
     result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
-                                 test_ctors, 0);
+                             test_ctors, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -210,10 +216,12 @@
                     "lib.locale.cons",
                     "thread safety", run_test,
                     "|-combine~ "
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-locales=",        // must be provided
                     &opt_combine,
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.ctype.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.ctype.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.ctype.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.ctype.mt.cpp Mon May 26 18:51:19 2008
@@ -66,6 +66,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -118,6 +121,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         const std::size_t inx = std::size_t (i) % nlocales;
 
         // save the name of the locale
@@ -260,7 +266,8 @@
 
     // create and start a pool of threads and wait for them to finish
     int result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -276,7 +283,8 @@
     // start a pool of threads to exercise the thread safety
     // of the wchar_t specialization
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -293,7 +301,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -321,11 +330,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.ctype",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // arg must be non-negative
                     "|-nthreads#0-* "    // arg must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // arg must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.globals.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.globals.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.globals.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.globals.mt.cpp Mon May 26 18:51:19 2008
@@ -73,6 +73,9 @@
 // disable exceptions?
 int opt_no_exceptions;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -149,6 +152,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const char* const locale_name = locales [i % nlocales];
 
@@ -395,6 +401,10 @@
     const std::locale classic (std::locale::classic ());
 
     for (int i = 0; i != opt_nloops; ++i) {
+
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         try {
             use_facet_loop (classic, i);
         }
@@ -510,7 +520,7 @@
 
         // create and start a pool of threads and wait for them to finish
         result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
-                                 test_has_facet, 0);
+                                 test_has_facet, 0, std::size_t (opt_timeout));
 
         rw_error (result == 0, 0, __LINE__,
                   "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -554,7 +564,7 @@
 
         // create and start a pool of threads and wait for them to finish
         result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
-                                 test_use_facet, 0);
+                                 test_use_facet, 0, std::size_t (opt_timeout));
 
         rw_error (result == 0, 0, __LINE__,
                   "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -586,6 +596,7 @@
                     "thread safety", run_test,
                     "|-has_facet~ "
                     "|-use_facet~ "
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // arg must be non-negative
                     "|-nthreads#0-* "    // arg must be in [0, MAX_THREADS]
                     "|-locales= "        // argument must be provided
@@ -605,6 +616,7 @@
                     "|-time_put~ ",
                     &opt_has_facet,
                     &opt_use_facet,
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.messages.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.messages.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.messages.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.messages.mt.cpp Mon May 26 18:51:19 2008
@@ -30,44 +30,76 @@
 
 #include <driver.h>      // for rw_test()
 #include <rw_locale.h>   // for rw_create_catalog()
-#include <rw_thread.h>
+#include <rw_thread.h>   // for rw_thread_pool()
+#include <rw_process.h>  // for rw_system()
+#include <file.h>        // for SHELL_RM_F
 #include <valcmp.h>      // for rw_strncmp ()
 
 #include <cstring>   // for strlen()
 #include <cstdio>    // for remove()
 
 // maximum number of threads allowed by the command line interface
+#define MAX_CATALOGS     32
 #define MAX_THREADS      32
 #define MAX_LOOPS    100000
 
+// deault number of catalogs
+int opt_ncatalogs = 11;
+
 // default number of threads (will be adjusted to the number
 // of processors/cores later)
-int rw_opt_nthreads = 1;
+int opt_nthreads = 1;
 
 // the number of times each thread should iterate (unless specified
 // otherwise on the command line)
-int rw_opt_nloops = 100000;
+int opt_nloops = 10000;
+
+#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
+
+// number of locales to use
+int opt_nlocales = MAX_THREADS;
+
+#else   // HP-UX in LP64 mode
 
-// locale for threads to share
-static const
-std::locale locale;
-
-// message catalog for threads to share
-static
-std::messages_base::catalog catalog;
+// work around a small cache size on HP-UX in LP64 mode
+// in LP64 mode (see STDCXX-812)
+int opt_nlocales = 9;
 
-static
-std::messages_base::catalog wcatalog;
+#endif   // HP-UX 32/64 bit mode
+
+// should all threads share the same set of locale objects instead
+// of creating their own?
+int opt_shared_locale;
+
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
 
 /**************************************************************************/
 
-#ifndef _WIN32
-#  define CAT_NAME "./rwstdmessages.cat"
-#  define MSG_NAME "rwstdmessages.msg"
-#else
-#  define CAT_NAME "rwstdmessages.dll"
-#  define MSG_NAME "rwstdmessages.rc"
-#endif
+// array of locale names to use for testing
+static const char*
+locales [MAX_THREADS];
+
+// number of locale names in the array
+static std::size_t
+nlocales;
+
+/**************************************************************************/
+
+//
+struct MyMessageData
+{
+    // name of the locale the data corresponds to
+    const char* locale_name_;
+
+    // optionally set to the named locale for threads to share
+    std::locale locale_;
+
+} my_message_data [MAX_THREADS];
+
+char my_catalog_names [64][MAX_CATALOGS];
+
+/**************************************************************************/
 
 #define MAX_SETS 5
 #define MAX_MESSAGES  5
@@ -123,38 +155,6 @@
     }
 };
 
-static std::string str_messages;
-
-/**************************************************************************/
-
-template <class T>
-void test_open_close (const std::locale& loc,
-                      const std::messages<T>& msgs,
-                      const std::string& name)
-{
-    std::messages_base::catalog cat =
-        (msgs.open) (name, loc);
-
-    RW_ASSERT (! (cat < 0));
-
-    (msgs.close) (cat);
-}
-
-template <class T>
-void test_get (const std::messages<T>& msgs,
-               const std::messages_base::catalog cat,
-               int set, int msgid,
-               const std::basic_string<T>& dflt)
-{
-    // the msg_id() thing seems like a bug to me. if anything, the user
-    // should never need to write or call msg_id().
-
-    const typename std::messages<T>::string_type res =
-        msgs.get (cat, set, msg_id (set, msgid), dflt);
-
-    RW_ASSERT (!rw_strncmp (messages [set-1][msgid-1], res.c_str ()));
-}
-
 /**************************************************************************/
 
 extern "C" {
@@ -165,50 +165,146 @@
 static void*
 thread_func (void*)
 {
-    const std::string name (CAT_NAME);
-
-    const std::messages<char>& nmsgs =
-        std::use_facet<std::messages<char> >(locale);
-
     const std::string ndflt ("\1\2\3\4");
 
+    struct {
+        std::messages_base::catalog cat;
+        std::locale loc;
+    } ncatalogs [4];
+
+    const unsigned n_ncatalogs = sizeof (ncatalogs) / sizeof (*ncatalogs);
+
+    // 22.2.7.1.2 says values less than 0 returned if catalog can't
+    // be opened, so we use -1 as a sentinel.
+    for (unsigned c = 0; c < n_ncatalogs; ++c)
+        ncatalogs [c].cat = -1;
+
 #ifndef _RWSTD_NO_WCHAR_T
-    const std::messages<wchar_t>& wmsgs =
-        std::use_facet<std::messages<wchar_t> >(locale);
 
     const std::wstring wdflt (L"\1\2\3\4");
-#endif // _RWSTD_NO_WCHAR_T
 
-    for (int i = 0; i != rw_opt_nloops; ++i) {
+    struct {
+        std::messages_base::catalog cat;
+        std::locale loc;
+    } wcatalogs [5];
+
+    const unsigned n_wcatalogs = sizeof (wcatalogs) / sizeof (*wcatalogs);
 
-        int set   = 1 + i % MAX_SETS;
-        int msgid = 1 + i % MAX_MESSAGES;
+    for (unsigned c = 0; c < n_wcatalogs; ++c)
+        wcatalogs [c].cat = -1;
+
+#endif   // _RWSTD_NO_WCHAR_T
+
+    ///////////////////////////////////////////////////////////////////////
+
+    for (int i = 0; i < opt_nloops; ++i) {
+
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
+        const MyMessageData& data = my_message_data [i % nlocales];
+
+        // construct a named locale, get a reference to the money_get
+        // facet from it and use it to format a random money value
+        const std::locale loc = 
+            opt_shared_locale ? data.locale_
+                              : std::locale (data.locale_name_);
+
+        const int set   = 1 + i % MAX_SETS;
+        const int msgid = 1 + i % MAX_MESSAGES;
 
         if (test_char) {
-            if (i & 1) {
-                test_get<char>(nmsgs, catalog, set, msgid, ndflt);
+            // exercise the narrow char specialization of the facet
+
+            const std::messages<char> &nm =
+                std::use_facet<std::messages<char> >(loc);
+
+            const unsigned cat_idx = i % n_ncatalogs;
+            if (! (ncatalogs [cat_idx].cat < 0)) {
+                (nm.close)(ncatalogs [cat_idx].cat);
             }
-            else {
-                test_open_close<char>(locale, nmsgs, name);
+
+            const unsigned name_idx = i % opt_ncatalogs;
+
+            const std::messages_base::catalog cat = 
+                (nm.open)(my_catalog_names [name_idx], loc);
+
+            ncatalogs [cat_idx].cat = cat;
+            ncatalogs [cat_idx].loc = loc;
+
+            if (i & 1) {
+
+                // get a message from the catalog every odd iteration
+                const std::messages<char>::string_type res =
+                        nm.get (cat, set, msg_id (set, msgid), ndflt);
+
             }
         }
 
+#ifndef _RWSTD_NO_WCHAR_T
+
         if (test_wchar) {
+            // exercise the wide char specialization of the facet
 
-#ifndef _RWSTD_NO_WCHAR_T
+            const std::messages<wchar_t> &wm =
+                std::use_facet<std::messages<wchar_t> >(loc);
 
-            if (i & 1) {
-                test_get<wchar_t>(wmsgs, wcatalog, set, msgid, wdflt);
+            const unsigned cat_idx = i % n_wcatalogs;
+            if (! (wcatalogs [cat_idx].cat < 0)) {
+                (wm.close)(wcatalogs [cat_idx].cat);
             }
-            else {
-                test_open_close<wchar_t>(locale, wmsgs, name);
+
+            const unsigned name_idx = i % opt_ncatalogs;
+
+            const std::messages_base::catalog cat = 
+                (wm.open)(my_catalog_names [name_idx], loc);
+
+            RW_ASSERT (! (cat < 0));
+
+            wcatalogs [cat_idx].cat = cat;
+            wcatalogs [cat_idx].loc = loc;
+
+            if (! (i & 1)) {
+
+                // get a message from the catalog every even iteration
+                const std::messages<wchar_t>::string_type res =
+                        wm.get (cat, set, msg_id (set, msgid), wdflt);
+
             }
+        }
 
-#endif // _RWSTD_NO_WCHAR_T
+#endif   // _RWSTD_NO_WCHAR_T
+
+    }
+
+    ///////////////////////////////////////////////////////////////////////
+
+    // close any catalogs that are still open
+
+    for (unsigned c = 0; c < n_ncatalogs; ++c) {
+        if (! (ncatalogs [c].cat < 0)) {
+
+            const std::messages<char> &nm =
+                std::use_facet<std::messages<char> >(ncatalogs[c].loc);
+
+            (nm.close)(ncatalogs [c].cat);
+        }
+    }
+
+#ifndef _RWSTD_NO_WCHAR_T
 
+    for (unsigned c = 0; c < n_wcatalogs; ++c) {
+        if (! (wcatalogs [c].cat < 0)) {
+
+            const std::messages<wchar_t> &wm =
+                std::use_facet<std::messages<wchar_t> >(wcatalogs[c].loc);
+
+            (wm.close)(wcatalogs [c].cat);
         }
     }
 
+#endif   // _RWSTD_NO_WCHAR_T
+
     return 0;
 }
 
@@ -219,36 +315,96 @@
 static int
 run_test (int, char**)
 {
+    std::string catalog;
+
+    // initialize the catalog data
     for (int i = 0; i < MAX_SETS; ++i) {
-        for (int j = 0; j < MAX_MESSAGES; ++j)
-            str_messages.append (messages [i][j], std::strlen (messages [i][j]) + 1);
 
-        str_messages.append (1, '\0');
+        for (int j = 0; j < MAX_MESSAGES; ++j) {
+            catalog.append (messages [i][j],
+                            std::strlen (messages [i][j]) + 1);
+        }
+
+        catalog.append (1, '\0');
     }
 
-    // generate a message catalog
-    rw_create_catalog (MSG_NAME, str_messages.c_str ());
-    const std::string name (CAT_NAME);
+    ///////////////////////////////////////////////////////////////////////
 
-    const std::messages<char>& nmsgs =
-        std::use_facet<std::messages<char> >(locale);
+    // create the catalogs and initialize array of catalog names
+    for (int i = 0; i < opt_ncatalogs; ++i) {
 
-    catalog = (nmsgs.open) (name, locale);
+        char* msg_name = my_catalog_names [i];
 
-#ifndef _RWSTD_NO_WCHAR_T
-
-    const std::messages<wchar_t>& wmsgs =
-        std::use_facet<std::messages<wchar_t> >(locale);
+#ifndef _WIN32
+        std::sprintf (msg_name, "rwstdmessages_%d.msg", i);
+#else
+        std::sprintf (msg_name, "rwstdmessages_%d.rc", i);
+#endif
 
-    wcatalog = (wmsgs.open) (name, locale);
+        const int failed = rw_create_catalog (msg_name, catalog.c_str ());
+        rw_fatal (!failed, 0, __LINE__,
+                  "failed to create message catalog from %s",
+                  msg_name);
 
+#ifndef _WIN32
+        std::sprintf (msg_name, "./rwstdmessages_%d.cat", i);
+#else
+        std::sprintf (msg_name, "rwstdmessages_%d.dll", i);
 #endif
+    }
+
+    ///////////////////////////////////////////////////////////////////////
+
+    // find all installed locales for which setlocale (LC_ALL) succeeds
+    const char* const locale_list =
+        rw_opt_locales ? rw_opt_locales : rw_locales (_RWSTD_LC_ALL);
+
+    const std::size_t maxinx = RW_COUNT_OF (locales);
+
+    for (const char* name = locale_list;
+         *name;
+         name += std::strlen (name) + 1) {
+
+        const std::size_t inx = nlocales;
+        locales [inx] = name;
+
+        // fill in the money and results for this locale
+        MyMessageData& data = my_message_data [inx];
+        data.locale_name_ = name;
+
+        try {
+            const std::locale loc (data.locale_name_);
+
+            const std::messages<char>& nm =
+                std::use_facet<std::messages<char> >(loc);
+
+#ifdef _RWSTD_NO_WCHAR_T
+
+            const std::messages<wchar_t>& nm =
+                std::use_facet<std::messages<wchar_t> >(loc);
+
+#endif // _RWSTD_NO_WCHAR_T
+
+            if (opt_shared_locale)
+                data.locale_ = loc;
+
+            nlocales += 1;
+
+        }
+        catch (...) {
+            rw_warn (!rw_opt_locales, 0, __LINE__,
+                     "unable to use locale(%#s)", name);
+        }
+
+        if (nlocales == maxinx || nlocales == std::size_t (opt_nlocales))
+            break;
+    }
 
     rw_info (0, 0, 0,
              "testing std::messages<charT> with %d thread%{?}s%{;}, "
              "%d iteration%{?}s%{;} each",
-             rw_opt_nthreads, 1 != rw_opt_nthreads,
-             rw_opt_nloops, 1 != rw_opt_nloops);
+             opt_nthreads, 1 != opt_nthreads,
+             opt_nloops, 1 != opt_nloops);
 
     ///////////////////////////////////////////////////////////////////////
 
@@ -258,12 +414,12 @@
     rw_info (0, 0, 0, "exercising std::messages<char>");
 
     int result = 
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0,
-                        thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     ///////////////////////////////////////////////////////////////////////
 
@@ -275,12 +431,12 @@
     rw_info (0, 0, 0, "exercising std::messages<wchar_t>");
 
     result = 
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0,
-                        thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     ///////////////////////////////////////////////////////////////////////
 
@@ -291,26 +447,18 @@
                       "std::messages<wchar_t>");
 
     result = 
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0,
-                        thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
 #endif // _RWSTD_NO_WCHAR_T
 
     ///////////////////////////////////////////////////////////////////////
 
-    (nmsgs.close) (catalog);
-
-#ifndef _RWSTD_NO_WCHAR_T
-
-    (wmsgs.close) (wcatalog);
-    
-#endif // _RWSTD_NO_WCHAR_T
-
-    std::remove (CAT_NAME);
+    rw_system (SHELL_RM_F "rwstdmessages_*");
 
     return result;
 }
@@ -323,18 +471,23 @@
 
     // set nthreads to the greater of the number of processors
     // and 2 (for uniprocessor systems) by default
-    rw_opt_nthreads = rw_get_cpus ();
-    if (rw_opt_nthreads < 2)
-        rw_opt_nthreads = 2;
+    opt_nthreads = rw_get_cpus ();
+    if (opt_nthreads < 2)
+        opt_nthreads = 2;
 
 #endif   // _RWSTD_REENTRANT
 
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.messages",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
+                    "|-ncatalogs#0-* "   // must be non-negative
                     "|-nthreads#0-* ",    // must be in [0, MAX_THREADS]
-                    &rw_opt_nloops,
+                    &opt_timeout,
+                    &opt_nloops,
+                    int (MAX_CATALOGS),
+                    &opt_ncatalogs,
                     int (MAX_THREADS),
-                    &rw_opt_nthreads);
+                    &opt_nthreads);
 }

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.money.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.money.get.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.money.get.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.money.get.mt.cpp Mon May 26 18:51:19 2008
@@ -67,6 +67,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -176,6 +179,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const MyMoneyData& data = my_money_data [i % nlocales];
 
@@ -183,7 +189,7 @@
         // facet from it and use it to format a random money value
         const std::locale loc =
             opt_shared_locale ? data.locale_
-                                 : std::locale (data.locale_name_);
+                              : std::locale (data.locale_name_);
 
         if (test_char) {
             // exercise the narrow char specialization of the facet
@@ -403,7 +409,8 @@
 
     // create and start a pool of threads and wait for them to finish
     int result = 
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -418,7 +425,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -436,7 +444,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -464,11 +473,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.money.get",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.money.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.money.put.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.money.put.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.money.put.mt.cpp Mon May 26 18:51:19 2008
@@ -67,6 +67,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -184,6 +187,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // save the name of the locale
         const MyMoneyData& data = my_money_data [i % nlocales];
 
@@ -191,7 +197,7 @@
         // facet from it and use it to format a random money value
         const std::locale loc =
             opt_shared_locale ? data.locale_
-                                 : std::locale (data.locale_name_);
+                              : std::locale (data.locale_name_);
 
         if (test_char) {
             // exercise the narrow char specialization of the facet
@@ -409,7 +415,8 @@
 
     // create and start a pool of threads and wait for them to finish
     int result = 
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -424,7 +431,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -442,7 +450,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -470,11 +479,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.money.put",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // must be non-negative
                     "|-nthreads#0-* "    // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "      // arg must be non-negative
                     "|-locales= "        // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.moneypunct.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.moneypunct.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.moneypunct.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.moneypunct.mt.cpp Mon May 26 18:51:19 2008
@@ -43,14 +43,17 @@
 
 // default number of threads (will be adjusted to the number
 // of processors/cores later)
-int rw_opt_nthreads = 1;
+int opt_nthreads = 1;
 
 // the default number of times for each thread to iterate
 #define DFLT_LOOPS   10000
 
 // the number of times each thread should iterate (will be set to
 // DFLT_LOOPS unless explicitly specified on the command line)
-int rw_opt_nloops = -1;
+int opt_nloops = -1;
+
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
 
 /**************************************************************************/
 
@@ -240,7 +243,10 @@
 static void*
 thread_func (void*)
 {
-    for (int i = 0; i != rw_opt_nloops; ++i) {
+    for (int i = 0; i != opt_nloops; ++i) {
+
+        if (rw_thread_pool_timeout_expired ())
+            break;
 
         thread_loop_body (std::size_t (i));
     }
@@ -388,13 +394,13 @@
     // unless the number of iterations was explicitly specified
     // on the command line, decrease the number to equal the number
     // of excericsed locales when only one thread is being tested
-    if (1 == rw_opt_nthreads && rw_opt_nloops < 0)
-        rw_opt_nloops = int (nlocales);
+    if (1 == opt_nthreads && opt_nloops < 0)
+        opt_nloops = int (nlocales);
 
     // when the number of iterations wasn't explicitly specified
     // on the command line set it to the default value
-    if (rw_opt_nloops < 0)
-        rw_opt_nloops = DFLT_LOOPS;
+    if (opt_nloops < 0)
+        opt_nloops = DFLT_LOOPS;
 
     rw_fatal (0 < nlocales, 0, __LINE__,
               "must have at least one valid locale to test");
@@ -402,8 +408,8 @@
     rw_info (0, 0, 0,
              "testing std::moneypunct<charT> with %d thread%{?}s%{;}, "
              "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
-             rw_opt_nthreads, 1 != rw_opt_nthreads,
-             rw_opt_nloops, 1 != rw_opt_nloops,
+             opt_nthreads, 1 != opt_nthreads,
+             opt_nloops, 1 != opt_nloops,
              nlocales, int (nlocales), "%#s", locales);
 
     rw_info (0, 0, 0, "exercising std::moneypunct<char>");
@@ -413,11 +419,12 @@
 
     // create and start a pool of threads and wait for them to finish
     int result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
 #ifndef _RWSTD_NO_WCHAR_T
 
@@ -429,11 +436,12 @@
     // start a pool of threads to exercise the thread safety
     // of the wchar_t specialization
     result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     // exercise both the char and the wchar_t specializations
     // at the same time
@@ -447,11 +455,12 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
 #endif   // _RWSTD_NO_WCHAR_T
 
@@ -466,20 +475,22 @@
 
     // set nthreads to the greater of the number of processors
     // and 2 (for uniprocessor systems) by default
-    rw_opt_nthreads = rw_get_cpus ();
-    if (rw_opt_nthreads < 2)
-        rw_opt_nthreads = 2;
+    opt_nthreads = rw_get_cpus ();
+    if (opt_nthreads < 2)
+        opt_nthreads = 2;
 
 #endif   // _RWSTD_REENTRANT
 
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.moneypunct",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-locales=",       // must be provided
-                    &rw_opt_nloops,
+                    &opt_timeout,
+                    &opt_nloops,
                     int (MAX_THREADS),
-                    &rw_opt_nthreads,
+                    &opt_nthreads,
                     &rw_opt_setlocales);
 }

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.num.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.num.get.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.num.get.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.num.get.mt.cpp Mon May 26 18:51:19 2008
@@ -42,10 +42,10 @@
 
 // default number of threads (will be adjusted to the number
 // of processors/cores later)
-int rw_opt_nthreads = 1;
+int opt_nthreads = 1;
 
 // the number of times each thread should iterate
-int rw_opt_nloops = MAX_LOOPS;
+int opt_nloops = MAX_LOOPS;
 
 #if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
 
@@ -62,7 +62,10 @@
 
 // should all threads share the same set of locale objects instead
 // of creating their own?
-int rw_opt_shared_locale;
+int opt_shared_locale;
+
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
 
 /**************************************************************************/
 
@@ -117,11 +120,13 @@
 
     // holds the narrow/wide character representation of value_ and
     // the number of used 'charT' in each buffer.
-    char    ncs_ [BufferSize];
+    char        ncs_ [BufferSize];
+    std::size_t nlen_;   // number of valid characters in buffer
 
 #ifndef _RWSTD_NO_WCHAR_T
 
-    wchar_t wcs_ [BufferSize];
+    wchar_t     wcs_ [BufferSize];
+    std::size_t wlen_;   // number of valid characters in buffer
 
 #endif  // _RWSTD_NO_WCHAR_T
 
@@ -338,7 +343,10 @@
     wio.rdbuf (&wsb);
 #endif // _RWSTD_NO_WCHAR_T
 
-    for (int i = 0; i != rw_opt_nloops; ++i) {
+    for (int i = 0; i != opt_nloops; ++i) {
+
+        if (rw_thread_pool_timeout_expired ())
+            break;
 
         // fill in the value and results for this locale
         const MyNumData& data = my_num_data [i % nlocales];
@@ -346,8 +354,8 @@
         // construct a named locale and imbue it in the ios object
         // so that the locale is used not only by the num_put facet
         const std::locale loc =
-            rw_opt_shared_locale ? data.locale_
-                                 : std::locale (data.locale_name_);
+            opt_shared_locale ? data.locale_
+                              : std::locale (data.locale_name_);
 
         if (test_char) {
             // exercise the narrow char specialization of the facet
@@ -356,7 +364,7 @@
                 std::use_facet<std::num_get<char> >(loc);
 
             nio.imbue (loc);
-            nsb.pubsetg (data.ncs_, Traits::length (data.ncs_));
+            nsb.pubsetg (data.ncs_, data.nlen_);
 
             test_get_data (data, ng,
                            std::istreambuf_iterator<char>(&nsb),
@@ -377,7 +385,7 @@
                 std::use_facet<std::num_get<wchar_t> >(loc);
 
             wio.imbue (loc);
-            wsb.pubsetg (data.wcs_, WTraits::length (data.wcs_));
+            wsb.pubsetg (data.wcs_, data.wlen_);
 
             test_get_data (data, wp,
                            std::istreambuf_iterator<wchar_t>(&wsb),
@@ -445,6 +453,8 @@
             test_put_data (data, np, std::ostreambuf_iterator<char>(&nsb),
                            nio, ' ', '\0');
 
+            data.nlen_ = std::char_traits<char>::length (data.ncs_);
+
             rw_fatal (!nio.fail (), __FILE__, __LINE__,
                       "num_put<char>::put(...) failed for locale(%#s)",
                       data.locale_name_);
@@ -460,13 +470,15 @@
             test_put_data (data, wp, std::ostreambuf_iterator<wchar_t>(&wsb),
                            wio, L' ', L'\0');
 
+            data.wlen_ = std::char_traits<wchar_t>::length (data.wcs_);
+
             rw_fatal (!wio.fail (), __FILE__, __LINE__,
                       "num_put<wchar_t>::put(...) failed for locale(%#s)",
                       data.locale_name_);
 
 #endif // _RWSTD_NO_WCHAR_T
 
-            if (rw_opt_shared_locale)
+            if (opt_shared_locale)
                 data.locale_ = loc;
 
             nlocales += 1;
@@ -487,8 +499,8 @@
     rw_info (0, 0, 0,
              "testing std::num_get<charT> with %d thread%{?}s%{;}, "
              "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
-             rw_opt_nthreads, 1 != rw_opt_nthreads,
-             rw_opt_nloops, 1 != rw_opt_nloops,
+             opt_nthreads, 1 != opt_nthreads,
+             opt_nloops, 1 != opt_nloops,
              nlocales, int (nlocales), "%#s", locales);
 
     rw_info (0, 0, 0, "exercising std::num_get<char>");
@@ -498,11 +510,12 @@
 
     // create and start a pool of threads and wait for them to finish
     int result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
 #ifndef _RWSTD_NO_WCHAR_T
 
@@ -513,11 +526,12 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
     // exercise both the char and the wchar_t specializations
     // at the same time
@@ -530,11 +544,12 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
-              rw_opt_nthreads, thread_func);
+              opt_nthreads, thread_func);
 
 #endif   // _RWSTD_NO_WCHAR_T
 
@@ -549,24 +564,26 @@
 
     // set nthreads to the greater of the number of processors
     // and 2 (for uniprocessor systems) by default
-    rw_opt_nthreads = rw_get_cpus ();
-    if (rw_opt_nthreads < 2)
-        rw_opt_nthreads = 2;
+    opt_nthreads = rw_get_cpus ();
+    if (opt_nthreads < 2)
+        opt_nthreads = 2;
 
 #endif   // _RWSTD_REENTRANT
 
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.num.get",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
-                    &rw_opt_nloops,
+                    &opt_timeout,
+                    &opt_nloops,
                     int (MAX_THREADS),
-                    &rw_opt_nthreads,
+                    &opt_nthreads,
                     &opt_nlocales,
                     &rw_opt_setlocales,
-                    &rw_opt_shared_locale);
+                    &opt_shared_locale);
 }

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.num.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.num.put.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.num.put.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.num.put.mt.cpp Mon May 26 18:51:19 2008
@@ -64,6 +64,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -238,6 +241,9 @@
 
     for (int i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         // fill in the value and results for this locale
         const MyNumData& data = my_num_data [i % nlocales];
 
@@ -245,7 +251,7 @@
         // so that the locale is used not only by the num_put facet
         const std::locale loc =
             opt_shared_locale ? data.locale_
-                                 : std::locale (data.locale_name_);
+                              : std::locale (data.locale_name_);
 
         if (test_char) {
             // exercise the narrow char specialization of the facet
@@ -394,7 +400,8 @@
 
     // create and start a pool of threads and wait for them to finish
     int result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -409,7 +416,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -426,7 +434,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -454,11 +463,13 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.num.put",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.numpunct.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.numpunct.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.numpunct.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.numpunct.mt.cpp Mon May 26 18:51:19 2008
@@ -47,7 +47,7 @@
 
 // the number of times each thread should iterate (unless specified
 // otherwise on the command line)
-int rw_opt_nloops = 200000;
+int opt_nloops = 200000;
 
 #if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
 
@@ -66,6 +66,9 @@
 // of creating their own?
 int opt_shared_locale;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale names to use for testing
@@ -111,7 +114,10 @@
 static void*
 thread_func (void*)
 {
-    for (int i = 0; i != rw_opt_nloops; ++i) {
+    for (int i = 0; i != opt_nloops; ++i) {
+
+        if (rw_thread_pool_timeout_expired ())
+            break;
 
         const std::size_t inx = std::size_t (i) % nlocales;
 
@@ -120,7 +126,7 @@
         // construct a named locale
         const std::locale loc =
             opt_shared_locale ? data.locale_
-                                 : std::locale (data.locale_name_);
+                              : std::locale (data.locale_name_);
 
         if (test_char) {
             // exercise the narrow char specialization of the facet
@@ -250,7 +256,7 @@
              "testing std::numpunct<charT> with %d thread%{?}s%{;}, "
              "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
              opt_nthreads, 1 != opt_nthreads,
-             rw_opt_nloops, 1 != rw_opt_nloops,
+             opt_nloops, 1 != opt_nloops,
              nlocales, int (nlocales), "%#s", locales);
 
     rw_info (0, 0, 0, "exercising std::numpunct<char>");
@@ -260,7 +266,8 @@
 
     // create and start a pool of threads and wait for them to finish
     int result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -276,7 +283,8 @@
     // start a pool of threads to exercise the thread safety
     // of the wchar_t specialization
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -293,7 +301,8 @@
 
     // start a pool of threads to exercise wstring thread safety
     result =
-        rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
+        rw_thread_pool (0, std::size_t (opt_nthreads), 0,
+                        thread_func, 0, std::size_t (opt_timeout));
 
     rw_error (result == 0, 0, __LINE__,
               "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -321,12 +330,14 @@
     return rw_test (argc, argv, __FILE__,
                     "lib.locale.numpunct",
                     "thread safety", run_test,
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "       // must be non-negative
                     "|-nthreads#0-* "   // must be in [0, MAX_THREADS]
                     "|-nlocales#0 "     // arg must be non-negative
                     "|-locales= "       // must be provided
                     "|-shared-locale# ",
-                    &rw_opt_nloops,
+                    &opt_timeout,
+                    &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,
                     &opt_nlocales,

Modified: stdcxx/branches/4.3.x/tests/localization/22.locale.statics.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/localization/22.locale.statics.mt.cpp?rev=660350&r1=660349&r2=660350&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/localization/22.locale.statics.mt.cpp (original)
+++ stdcxx/branches/4.3.x/tests/localization/22.locale.statics.mt.cpp Mon May 26 18:51:19 2008
@@ -50,6 +50,9 @@
 int opt_classic;
 int opt_global;
 
+// default timeout used by each threaded section of this test
+int opt_timeout = 60;
+
 /**************************************************************************/
 
 // array of locale objects to use for testing
@@ -92,6 +95,9 @@
 {
     for (std::size_t i = 0; i != opt_nloops; ++i) {
 
+        if (rw_thread_pool_timeout_expired ())
+            break;
+
         const std::size_t inx = i % nlocales;
 
         const std::locale last (std::locale::global (locales [inx]));
@@ -125,7 +131,7 @@
 
         // create and start a pool of threads and wait for them to finish
         result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
-                                 test_classic, 0);
+                                 test_classic, 0, std::size_t (opt_timeout));
     }
 
     if (rw_note (0 <= opt_global, 0, __LINE__,
@@ -161,7 +167,7 @@
 
         // create and start a pool of threads and wait for them to finish
         result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
-                                 test_global, 0);
+                                 test_global, 0, std::size_t (opt_timeout));
     }
 
     return result;
@@ -187,11 +193,13 @@
                     run_test,
                     "|-classic~ "
                     "|-global~ "
+                    "|-soft-timeout#0 "  // must be non-negative
                     "|-nloops#0 "        // arg must be non-negative
                     "|-nthreads#0-* "    // arg must be in [0, MAX_THREADS]
                     "|-locales= ",       // argument must be provided
                     &opt_classic,
                     &opt_global,
+                    &opt_timeout,
                     &opt_nloops,
                     int (MAX_THREADS),
                     &opt_nthreads,



Mime
View raw message