Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65934 - in sandbox/chrono/boost/chrono: . detail detail/inlined detail/inlined/mac detail/inlined/posix detail/inlined/win
From: vicente.botet_at_[hidden]
Date: 2010-10-12 19:31:19


Author: viboes
Date: 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
New Revision: 65934
URL: http://svn.boost.org/trac/boost/changeset/65934

Log:
Chrono: Make configurable header-only library

Added:
   sandbox/chrono/boost/chrono/detail/inlined/
   sandbox/chrono/boost/chrono/detail/inlined/chrono.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/mac/
   sandbox/chrono/boost/chrono/detail/inlined/mac/chrono.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/mac/process_clock.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/mac/thread_clock.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/posix/
   sandbox/chrono/boost/chrono/detail/inlined/posix/chrono.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/posix/process_clock.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/posix/thread_clock.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/process_clock.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/process_cpu_clocks.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/run_timer.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/run_timer_static.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/thread_clock.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/win/
   sandbox/chrono/boost/chrono/detail/inlined/win/chrono.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/win/process_clock.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/detail/inlined/win/thread_clock.hpp (contents, props changed)
Text files modified:
   sandbox/chrono/boost/chrono/chrono_io.hpp | 8 ++++----
   sandbox/chrono/boost/chrono/config.hpp | 31 ++++++++++++++++++++-----------
   sandbox/chrono/boost/chrono/detail/scan_keyword.hpp | 11 +----------
   sandbox/chrono/boost/chrono/process_cpu_clocks.hpp | 15 +++++++++++----
   sandbox/chrono/boost/chrono/process_times.hpp | 12 ++++++++++--
   sandbox/chrono/boost/chrono/system_clocks.hpp | 19 +++++++++++++------
   sandbox/chrono/boost/chrono/thread_clock.hpp | 10 ++++++++--
   7 files changed, 67 insertions(+), 39 deletions(-)

Modified: sandbox/chrono/boost/chrono/chrono_io.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/chrono_io.hpp (original)
+++ sandbox/chrono/boost/chrono/chrono_io.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -525,8 +525,8 @@
                 den /= gcd_d1_d2;
                 unsigned long long n2 = Period::num / gcd_n1_n2;
                 unsigned long long d2 = Period::den / gcd_d1_d2;
- if (num > std::numeric_limits<unsigned long long>::max() / d2 ||
- den > std::numeric_limits<unsigned long long>::max() / n2)
+ if (num > (std::numeric_limits<unsigned long long>::max)() / d2 ||
+ den > (std::numeric_limits<unsigned long long>::max)() / n2)
                 {
                     // (num/den) / Period overflows
                     is.setstate(is.failbit);
@@ -549,7 +549,7 @@
                         return is;
                     }
                 }
- if (r > (duration_values<common_type_t>::max() / num))
+ if (r > ((duration_values<common_type_t>::max)() / num))
                 {
                     // Conversion to Period overflowed
                     is.setstate(is.failbit);
@@ -557,7 +557,7 @@
                 }
                 common_type_t t = r * num;
                 t /= den;
- if (duration_values<Rep>::max() < t)
+ if ((duration_values<Rep>::max)() < t)
                 {
                     // Conversion to Period overflowed
                     is.setstate(is.failbit);

Modified: sandbox/chrono/boost/chrono/config.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/config.hpp (original)
+++ sandbox/chrono/boost/chrono/config.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -60,8 +60,27 @@
 # endif
 # endif
 
+// define constexpr related macros ------------------------------//
+
+//~ #include <boost/config.hpp>
+#if defined(BOOST_NO_CONSTEXPR)
+#define BOOST_CHRONO_CONSTEXPR
+#define BOOST_CHRONO_CONST_REF const&
+#else
+#define BOOST_CHRONO_CONSTEXPR constexpr
+#define BOOST_CHRONO_CONST_REF
+#endif
 
 
+#ifdef BOOST_CHRONO_INLINED
+#define BOOST_CHRONO_INLINE inline
+#define BOOST_CHRONO_STATIC
+#define BOOST_CHRONO_DECL
+
+#else
+#define BOOST_CHRONO_INLINE
+#define BOOST_CHRONO_STATIC static
+
 // enable dynamic linking on Windows ---------------------------------------//
 
 //# if (defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CHRONO_DYN_LINK)) && defined(__BORLANDC__) && defined(__WIN32__)
@@ -88,16 +107,6 @@
 #define BOOST_CHRONO_DECL
 #endif
 
-// define constexpr related macros ------------------------------//
-
-//~ #include <boost/config.hpp>
-#if defined(BOOST_NO_CONSTEXPR)
-#define BOOST_CHRONO_CONSTEXPR
-#define BOOST_CHRONO_CONST_REF const&
-#else
-#define BOOST_CHRONO_CONSTEXPR constexpr
-#define BOOST_CHRONO_CONST_REF
-#endif
 
 // enable automatic library variant selection ------------------------------//
 
@@ -118,6 +127,6 @@
 //
 #include <boost/config/auto_link.hpp>
 #endif // auto-linking disabled
-
+#endif // BOOST_CHRONO_INLINED
 #endif // BOOST_CHRONO_CONFIG_HPP
 

Added: sandbox/chrono/boost/chrono/detail/inlined/chrono.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/chrono.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,42 @@
+// chrono.cpp --------------------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+// Copyright Vicente J. Botet Escriba 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// define BOOST_CHRONO_SOURCE so that <boost/filesystem/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/version.hpp>
+#include <boost/chrono/chrono.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/throw_exception.hpp>
+
+//----------------------------------------------------------------------------//
+// //
+// Platform-specific Implementations //
+// //
+//----------------------------------------------------------------------------//
+
+//----------------------------------------------------------------------------//
+// Windows //
+//----------------------------------------------------------------------------//
+#if defined(BOOST_CHRONO_WINDOWS_API)
+#include <boost/chrono/detail/inlined/win/chrono.hpp>
+
+//----------------------------------------------------------------------------//
+// Mac //
+//----------------------------------------------------------------------------//
+#elif defined(BOOST_CHRONO_MAC_API)
+#include <boost/chrono/detail/inlined/mac/chrono.hpp>
+
+//----------------------------------------------------------------------------//
+// POSIX //
+//----------------------------------------------------------------------------//
+#elif defined(BOOST_CHRONO_POSIX_API)
+#include <boost/chrono/detail/inlined/posix/chrono.hpp>
+
+#endif // POSIX

Added: sandbox/chrono/boost/chrono/detail/inlined/mac/chrono.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/mac/chrono.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,201 @@
+// mac/chrono.cpp --------------------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+
+//----------------------------------------------------------------------------//
+// Mac //
+//----------------------------------------------------------------------------//
+
+#include <sys/time.h> //for gettimeofday and timeval
+#include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t
+
+namespace boost
+{
+namespace chrono
+{
+
+// system_clock
+
+// gettimeofday is the most precise "system time" available on this platform.
+// It returns the number of microseconds since New Years 1970 in a struct called timeval
+// which has a field for seconds and a field for microseconds.
+// Fill in the timeval and then convert that to the time_point
+BOOST_CHRONO_INLINE system_clock::time_point
+system_clock::now()
+{
+ timeval tv;
+ gettimeofday(&tv, 0);
+ return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+}
+
+BOOST_CHRONO_INLINE system_clock::time_point
+system_clock::now(system::error_code & ec)
+{
+ timeval tv;
+ gettimeofday(&tv, 0);
+ ec.clear();
+ return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+}
+
+// Take advantage of the fact that on this platform time_t is nothing but
+// an integral count of seconds since New Years 1970 (same epoch as timeval).
+// Just get the duration out of the time_point and truncate it to seconds.
+BOOST_CHRONO_INLINE time_t
+system_clock::to_time_t(const time_point& t)
+{
+ return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
+}
+
+// Just turn the time_t into a count of seconds and construct a time_point with it.
+BOOST_CHRONO_INLINE system_clock::time_point
+system_clock::from_time_t(time_t t)
+{
+ return system_clock::time_point(seconds(t));
+}
+
+// monotonic_clock
+
+// Note, in this implementation monotonic_clock and high_resolution_clock
+// are the same clock. They are both based on mach_absolute_time().
+// mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
+// nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom
+// are run time constants supplied by the OS. This clock has no relationship
+// to the Gregorian calendar. It's main use is as a high resolution timer.
+
+// MachInfo.numer / MachInfo.denom is often 1 on the latest equipment. Specialize
+// for that case as an optimization.
+BOOST_CHRONO_STATIC
+monotonic_clock::rep
+monotonic_simplified()
+{
+ return mach_absolute_time();
+}
+
+BOOST_CHRONO_STATIC
+monotonic_clock::rep
+monotonic_simplified_ec(system::error_code & ec)
+{
+ ec.clear();
+ return mach_absolute_time();
+}
+
+
+BOOST_CHRONO_STATIC
+double
+compute_monotonic_factor(kern_return_t& err)
+{
+ mach_timebase_info_data_t MachInfo;
+ err = mach_timebase_info(&MachInfo);
+ if( err != 0 ) {
+ return 0;
+ }
+ return static_cast<double>(MachInfo.numer) / MachInfo.denom;
+}
+
+BOOST_CHRONO_STATIC
+monotonic_clock::rep
+monotonic_full()
+{
+ static kern_return_t err;
+ static const double factor = compute_monotonic_factor(err);
+ if (err != 0)
+ boost::throw_exception(
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ system::system_error( err, system::system_category, "chrono::monotonic_clock" ));
+#else
+ system::system_error( err, system::system_category(), "chrono::monotonic_clock" ));
+#endif
+ return static_cast<monotonic_clock::rep>(mach_absolute_time() * factor);
+}
+
+BOOST_CHRONO_STATIC
+monotonic_clock::rep
+monotonic_full_ec(system::error_code & ec)
+{
+ static kern_return_t err;
+ static const double factor = compute_monotonic_factor(err);
+ if (err != 0) {
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( errno, system::system_category );
+#else
+ ec.assign( errno, system::system_category() );
+#endif
+ return monotonic_clock::rep();
+ }
+ ec.clear();
+ return static_cast<monotonic_clock::rep>(mach_absolute_time() * factor);
+}
+
+typedef monotonic_clock::rep (*FP)();
+typedef monotonic_clock::rep (*FP_ec)(system::error_code &);
+
+
+BOOST_CHRONO_STATIC
+FP_ec
+init_monotonic_clock(kern_return_t & err)
+{
+ mach_timebase_info_data_t MachInfo;
+ err = mach_timebase_info(&MachInfo);
+ if( err != 0 ) {
+ return 0;
+ }
+
+ if (MachInfo.numer == MachInfo.denom)
+ return &monotonic_simplified_ec;
+ return &monotonic_full_ec;
+}
+
+BOOST_CHRONO_STATIC
+FP_ec
+init_monotonic_clock_ec(kern_return_t & err)
+{
+ mach_timebase_info_data_t MachInfo;
+ err = mach_timebase_info(&MachInfo);
+ if( err != 0 ) {
+ return 0;
+ }
+
+ if (MachInfo.numer == MachInfo.denom)
+ return &monotonic_simplified_ec;
+ return &monotonic_full_ec;
+}
+
+BOOST_CHRONO_INLINE
+monotonic_clock::time_point
+monotonic_clock::now()
+{
+ static kern_return_t err;
+ static FP fp = init_monotonic_clock(err);
+ if( err != 0 ) boost::throw_exception(
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ system::system_error( err, system::system_category, "chrono::monotonic_clock" ));
+#else
+ system::system_error( err, system::system_category(), "chrono::monotonic_clock" ));
+#endif
+ return time_point(duration(fp()));
+}
+
+BOOST_CHRONO_INLINE
+monotonic_clock::time_point
+monotonic_clock::now(system::error_code & ec)
+{
+ static kern_return_t err;
+ static FP_ec fp = init_monotonic_clock(err);
+ if( err != 0 ) {
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( err, system::system_category );
+#else
+ ec.assign( err, system::system_category() );
+#endif
+ return time_point();
+ }
+ ec.clear();
+ return time_point(duration(fp(ec)));
+}
+
+} // namespace chrono
+} // namespace boost

Added: sandbox/chrono/boost/chrono/detail/inlined/mac/process_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/mac/process_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,97 @@
+// boost process_timer.cpp -----------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <cassert>
+
+#include <sys/time.h> //for gettimeofday and timeval
+# include <unistd.h>
+
+namespace
+{
+ BOOST_CHRONO_INLINE long tick_factor() // multiplier to convert ticks
+ // to nanoseconds; -1 if unknown
+ {
+ static long factor = 0;
+ if ( !factor )
+ {
+ if ( (factor = ::sysconf( _SC_CLK_TCK )) <= 0 )
+ factor = -1;
+ else
+ {
+ assert( factor <= 1000000l ); // doesn't handle large ticks
+ factor = 1000000l / factor; // compute factor
+ if ( !factor ) factor = -1;
+ }
+ }
+ return factor;
+ }
+}
+
+#else
+# error unknown API
+#endif
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ BOOST_CHRONO_INLINE void process_clock::now( process_times & times_, system::error_code & ec )
+ {
+
+ tms tm;
+ clock_t c = ::times( &tm );
+ if ( c == -1 ) // error
+ {
+ assert( 0 && "error handling not implemented yet" );
+
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( errno, system::system_category );
+#else
+ ec.assign( errno, system::system_category() );
+#endif
+ times_.real = times_.system = times_.user = nanoseconds(-1);
+ }
+ else
+ {
+ times_.real = microseconds(c);
+ times_.system = microseconds(tm.tms_stime + tm.tms_cstime);
+ times_.user = microseconds(tm.tms_utime + tm.tms_cutime);
+ if ( tick_factor() != -1 )
+ {
+ times_.real *= tick_factor();
+ times_.user *= tick_factor();
+ times_.system *= tick_factor();
+ ec.clear();
+ }
+ else
+ {
+ assert( 0 && "error handling not implemented yet" );
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( errno, system::system_category );
+#else
+ ec.assign( errno, system::system_category() );
+#endif
+
+ times_.real = times_.user = times_.system = nanoseconds(-1);
+ }
+ }
+
+ }
+ } // namespace chrono
+} // namespace boost

Added: sandbox/chrono/boost/chrono/detail/inlined/mac/thread_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/mac/thread_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,19 @@
+// boost thread_clock.cpp -----------------------------------------------------------//
+
+// Copyright Vicente J. Botet Escriba 2010
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/detail/inlined/posix/thread_clock.hpp>
+#include <cassert>
+

Added: sandbox/chrono/boost/chrono/detail/inlined/posix/chrono.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/posix/chrono.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,91 @@
+// posix/chrono.cpp --------------------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+// Copyright Vicente J. Botet Escriba 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+//----------------------------------------------------------------------------//
+// POSIX //
+//----------------------------------------------------------------------------//
+
+
+#include <time.h> // for clock_gettime
+
+namespace boost
+{
+namespace chrono
+{
+
+ BOOST_CHRONO_INLINE system_clock::time_point system_clock::now()
+ {
+ timespec ts;
+ if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
+ {
+ boost::throw_exception(
+ system::system_error( errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::system_clock" ));
+ }
+
+ return time_point(duration(
+ static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+ }
+
+ BOOST_CHRONO_INLINE system_clock::time_point system_clock::now(system::error_code & ec)
+ {
+ timespec ts;
+ if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
+ {
+ ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
+ return time_point();
+ }
+
+ ec.clear();
+ return time_point(duration(
+ static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+ }
+
+ BOOST_CHRONO_INLINE std::time_t system_clock::to_time_t(const system_clock::time_point& t)
+ {
+ return static_cast<std::time_t>( t.time_since_epoch().count() / 1000000000 );
+ }
+
+ BOOST_CHRONO_INLINE system_clock::time_point system_clock::from_time_t(std::time_t t)
+ {
+ return time_point(duration(static_cast<system_clock::rep>(t) * 1000000000));
+ }
+
+#ifdef BOOST_CHRONO_HAS_CLOCK_MONOTONIC
+
+ BOOST_CHRONO_INLINE monotonic_clock::time_point monotonic_clock::now()
+ {
+ timespec ts;
+ if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
+ {
+ boost::throw_exception(
+ system::system_error( errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::monotonic_clock" ));
+ }
+
+ return time_point(duration(
+ static_cast<monotonic_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+ }
+
+ BOOST_CHRONO_INLINE monotonic_clock::time_point monotonic_clock::now(system::error_code & ec)
+ {
+ timespec ts;
+ if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
+ {
+ ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
+ return time_point();
+ }
+
+ ec.clear();
+ return time_point(duration(
+ static_cast<monotonic_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+ }
+#endif
+
+} // namespace chrono
+} // namespace boost
+
+

Added: sandbox/chrono/boost/chrono/detail/inlined/posix/process_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/posix/process_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,85 @@
+// boost process_timer.cpp -----------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+// Copyright Vicente J. Botet Escriba 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <cassert>
+
+# include <sys/times.h>
+# include <unistd.h>
+
+namespace
+{
+ BOOST_CHRONO_INLINE long tick_factor() // multiplier to convert ticks
+ // to nanoseconds; -1 if unknown
+ {
+ static long factor = 0;
+ if ( !factor )
+ {
+ if ( (factor = ::sysconf( _SC_CLK_TCK )) <= 0 )
+ factor = -1;
+ else
+ {
+ assert( factor <= 1000000l ); // doesn't handle large ticks
+ factor = 1000000l / factor; // compute factor
+ if ( !factor ) factor = -1;
+ }
+ }
+ return factor;
+ }
+}
+
+namespace boost { namespace chrono {
+
+ BOOST_CHRONO_INLINE void process_clock::now( process_times & times_, system::error_code & ec ) {
+
+ tms tm;
+ clock_t c = ::times( &tm );
+ if ( c == clock_t(-1) ) // error
+ {
+ assert( 0 && "error handling not implemented yet" );
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( errno, system::system_category );
+#else
+ ec.assign( errno, system::system_category() );
+#endif
+ times_.real = times_.system = times_.user = nanoseconds(-1);
+ }
+ else
+ {
+ times_.real = microseconds(c);
+ times_.system = microseconds(tm.tms_stime + tm.tms_cstime);
+ times_.user = microseconds(tm.tms_utime + tm.tms_cutime);
+ if ( tick_factor() != -1 )
+ {
+ times_.real *= tick_factor();
+ times_.user *= tick_factor();
+ times_.system *= tick_factor();
+ }
+ else
+ {
+ assert( 0 && "error handling not implemented yet" );
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( errno, system::system_category );
+#else
+ ec.assign( errno, system::system_category() );
+#endif
+ times_.real = times_.user = times_.system = nanoseconds(-1);
+ }
+ }
+
+ }
+} }

Added: sandbox/chrono/boost/chrono/detail/inlined/posix/thread_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/posix/thread_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,72 @@
+// boost thread_clock.cpp -----------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+// Copyright Vicente J. Botet Escriba 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/thread_clock.hpp>
+#include <cassert>
+
+# include <sys/times.h>
+# include <unistd.h>
+
+namespace boost { namespace chrono {
+
+ BOOST_CHRONO_INLINE thread_clock::time_point thread_clock::now( ) {
+ // get the current thread
+ pthread_t pth=pthread_self();
+ // get the clock_id associated to the current thread
+ clockid_t clock_id;
+ pthread_getcpuclockid(pth, &clock_id);
+ // get the timespec associated to the thread clock
+ struct timespec ts;
+ if ( ::clock_gettime( clock_id, &ts ) )
+ {
+ boost::throw_exception(
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ system::system_error( errno, system::system_category, "chrono::thread_clock" ));
+#else
+ system::system_error( errno, system::system_category(), "chrono::thread_clock" ));
+#endif
+ }
+
+ // transform to nanoseconds
+ return time_point(duration(
+ static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+
+ }
+ BOOST_CHRONO_INLINE thread_clock::time_point thread_clock::now( system::error_code & ec ) {
+ // get the current thread
+ pthread_t pth=pthread_self();
+ // get the clock_id associated to the current thread
+ clockid_t clock_id;
+ pthread_getcpuclockid(pth, &clock_id);
+ // get the timespec associated to the thread clock
+ struct timespec ts;
+ if ( ::clock_gettime( clock_id, &ts ) )
+ {
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( errno, system::system_category );
+#else
+ ec.assign( errno, system::system_category() );
+#endif
+ return time_point();
+ }
+ ec.clear();
+ // transform to nanoseconds
+ return time_point(duration(
+ static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+
+ }
+} }

Added: sandbox/chrono/boost/chrono/detail/inlined/process_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/process_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,53 @@
+// boost process_timer.cpp -----------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/version.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <cassert>
+
+//----------------------------------------------------------------------------//
+// Windows //
+//----------------------------------------------------------------------------//
+#if defined(BOOST_CHRONO_WINDOWS_API)
+#include <boost/chrono/detail/inlined/win/process_clock.hpp>
+
+//----------------------------------------------------------------------------//
+// Mac //
+//----------------------------------------------------------------------------//
+#elif defined(BOOST_CHRONO_MAC_API)
+#include <boost/chrono/detail/inlined/mac/process_clock.hpp>
+
+//----------------------------------------------------------------------------//
+// POSIX //
+//----------------------------------------------------------------------------//
+#elif defined(BOOST_CHRONO_POSIX_API)
+#include <boost/chrono/detail/inlined/posix/process_clock.hpp>
+
+#endif // POSIX
+namespace boost { namespace chrono {
+
+ void process_clock::now( time_points & tps, system::error_code & ec ) {
+ process_times t;
+ process_clock::now(t,ec);
+ tps.real=process_clock::time_point(t.real);
+ tps.user=process_clock::time_point(t.user);
+ tps.system=process_clock::time_point(t.system);
+
+ }
+
+
+}}

Added: sandbox/chrono/boost/chrono/detail/inlined/process_cpu_clocks.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/process_cpu_clocks.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,52 @@
+// boost process_cpu_clocks.cpp -----------------------------------------------------------//
+
+// Copyright 2009-2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/version.hpp>
+#include <boost/chrono/process_cpu_clocks.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <cassert>
+
+namespace boost { namespace chrono {
+
+ process_real_cpu_clock::time_point process_real_cpu_clock::now(system::error_code & ec) {
+ process_times t;
+ process_clock::now(t, ec);
+ return process_real_cpu_clock::time_point(t.real);
+ }
+
+ process_user_cpu_clock::time_point process_user_cpu_clock::now(system::error_code & ec){
+ process_times t;
+ process_clock::now(t, ec);
+ return process_user_cpu_clock::time_point(t.user);
+ }
+
+ process_system_cpu_clock::time_point process_system_cpu_clock::now(system::error_code & ec) {
+ process_times t;
+ process_clock::now(t, ec);
+ return process_system_cpu_clock::time_point(t.system);
+ }
+
+ process_cpu_clock::time_point process_cpu_clock::now( system::error_code & ec ) {
+ process_times t;
+ process_clock::now(t,ec);
+ time_point::rep r(t.real.count(), t.user.count(), t.system.count());
+ return time_point(duration(r));
+ }
+
+} // namespace chrono
+} // namespace boost
+
+

Added: sandbox/chrono/boost/chrono/detail/inlined/run_timer.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/run_timer.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,182 @@
+// boost run_timer.cpp ---------------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+// Copyright 2009-2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/version.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/io/ios_state.hpp>
+#include <cstring>
+#include <cassert>
+
+using boost::chrono::nanoseconds;
+using boost::chrono::duration;
+
+namespace
+{
+ const char * default_format =
+ "\nreal %rs, cpu %cs (%p%), user %us, system %ss\n";
+
+ void show_time( const boost::chrono::process_times & times,
+ const char * format, int places, std::ostream & os )
+ // NOTE WELL: Will truncate least-significant digits to LDBL_DIG, which may
+ // be as low as 10, although will be 15 for many common platforms.
+ {
+ if ( times.real < nanoseconds(0) ) return;
+ if ( places > 9 )
+ places = 9; // sanity check
+ else if ( places < 0 )
+ places = 0;
+
+ boost::io::ios_flags_saver ifs( os );
+ os.setf( std::ios_base::fixed, std::ios_base::floatfield );
+ boost::io::ios_precision_saver ips( os );
+ os.precision( places );
+
+ nanoseconds total = times.system + times.user;
+
+ for ( ; *format; ++format )
+ {
+ if ( *format != '%' || !*(format+1) || !std::strchr("rcpus", *(format+1)) )
+ os << *format;
+ else
+ {
+ ++format;
+ switch ( *format )
+ {
+ case 'r':
+ os << duration<double>(times.real).count();
+ break;
+ case 'u':
+ os << duration<double>(times.user).count();
+ break;
+ case 's':
+ os << duration<double>(times.system).count();
+ break;
+ case 'c':
+ os << duration<double>(total).count();
+ break;
+ case 'p':
+ {
+ boost::io::ios_precision_saver ips( os );
+ os.precision( 1 );
+ if ( times.real.count() && total.count() )
+ os << duration<double>(total).count()
+ /duration<double>(times.real).count() * 100.0;
+ else
+ os << 0.0;
+ }
+ break;
+ default:
+ assert(0 && "run_timer internal logic error");
+ }
+ }
+ }
+ }
+
+} // unnamed namespace
+
+namespace boost
+{
+ namespace chrono
+ {
+
+
+ run_timer::run_timer( system::error_code & ec )
+ : m_places(m_default_places), m_os(m_cout()) { start(ec); }
+ run_timer::run_timer( std::ostream & os,
+ system::error_code & ec )
+ : m_places(m_default_places), m_os(os) { start(ec); }
+
+ run_timer::run_timer( const std::string & format,
+ system::error_code & ec )
+ : m_places(m_default_places), m_os(m_cout()), m_format(format) { start(ec); }
+ run_timer::run_timer( std::ostream & os, const std::string & format,
+ system::error_code & ec )
+ : m_places(m_default_places), m_os(os), m_format(format) { start(ec); }
+
+ run_timer::run_timer( const std::string & format, int places,
+ system::error_code & ec )
+ : m_places(places), m_os(m_cout()), m_format(format) { start(ec); }
+ run_timer::run_timer( std::ostream & os, const std::string & format,
+ int places, system::error_code & ec )
+ : m_places(places), m_os(os), m_format(format) { start(ec); }
+
+ run_timer::run_timer( int places,
+ system::error_code & ec )
+ : m_places(places), m_os(m_cout()) { start(ec); }
+ run_timer::run_timer( std::ostream & os, int places,
+ system::error_code & ec )
+ : m_places(places), m_os(os) { start(ec); }
+
+ run_timer::run_timer( int places, const std::string & format,
+ system::error_code & ec )
+ : m_places(places), m_os(m_cout()), m_format(format) { start(ec); }
+ run_timer::run_timer( std::ostream & os, int places, const std::string & format,
+ system::error_code & ec )
+ : m_places(places), m_os(os), m_format(format) { start(ec); }
+
+ // run_timer::report -------------------------------------------------------------//
+
+ void run_timer::report( system::error_code & ec )
+ {
+ m_reported = true;
+ if ( m_format.empty() ) m_format = default_format;
+
+ process_times times;
+ elapsed( times, ec );
+ if (ec) return;
+
+ if ( &ec == &system::throws )
+ {
+ show_time( times, m_format.c_str(), m_places, m_os );
+ }
+ else // non-throwing
+ {
+ try
+ {
+ show_time( times, m_format.c_str(), m_places, m_os );
+ ec.clear();
+ }
+
+ catch (...) // eat any exceptions
+ {
+ assert( 0 && "error reporting not fully implemented yet" );
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign(system::errc::success, system::generic_category);
+#else
+ ec.assign(system::errc::success, system::generic_category());
+#endif
+ //ec = error_code( EIO, errno_ecat );
+ }
+ }
+ }
+
+ // run_timer::test_report --------------------------------------------------------//
+
+ void run_timer::test_report( duration real_, duration user_, duration system_ )
+ {
+ if ( m_format.empty() ) m_format = default_format;
+
+ process_times times;
+ times.real = real_;
+ times.user = user_;
+ times.system = system_;
+
+ show_time( times, m_format.c_str(), m_places, m_os );
+ }
+
+ } // namespace chrono
+} // namespace boost

Added: sandbox/chrono/boost/chrono/detail/inlined/run_timer_static.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/run_timer_static.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,36 @@
+// boost run_timer_static.cpp --------------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+// Copyright 2009-2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// This function is defined in a separate translation so that it will not be linked
+// in except if actually used. This is more efficient because header <iostream> is
+// required, and it incurs the cost of the standard stream objects even if they are
+// not actually used.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/version.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <iostream>
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ std::ostream & run_timer::m_cout() { return std::cout; }
+
+ } // namespace chrono
+} // namespace boost

Added: sandbox/chrono/boost/chrono/detail/inlined/thread_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/thread_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,46 @@
+// boost thread_clock.cpp -----------------------------------------------------------//
+
+// Copyright 2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/version.hpp>
+#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
+#include <boost/chrono/thread_clock.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/system/system_error.hpp>
+#include <cassert>
+
+//----------------------------------------------------------------------------//
+// Windows //
+//----------------------------------------------------------------------------//
+#if defined(BOOST_CHRONO_WINDOWS_API)
+#include <boost/chrono/detail/inlined/win/thread_clock.hpp>
+
+//----------------------------------------------------------------------------//
+// Mac //
+//----------------------------------------------------------------------------//
+#elif defined(BOOST_CHRONO_MAC_API)
+#include <boost/chrono/detail/inlined/mac/thread_clock.hpp>
+
+//----------------------------------------------------------------------------//
+// POSIX //
+//----------------------------------------------------------------------------//
+#elif defined(BOOST_CHRONO_POSIX_API)
+#include <boost/chrono/detail/inlined/posix/thread_clock.hpp>
+
+#endif // POSIX
+
+
+#endif

Added: sandbox/chrono/boost/chrono/detail/inlined/win/chrono.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/win/chrono.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,126 @@
+// win/chrono.cpp --------------------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+//----------------------------------------------------------------------------//
+// Windows //
+//----------------------------------------------------------------------------//
+
+#include <windows.h>
+
+namespace
+{
+ BOOST_CHRONO_INLINE
+ double get_nanosecs_per_tic()
+ {
+ LARGE_INTEGER freq;
+ if ( !QueryPerformanceFrequency( &freq ) )
+ return 0.0L;
+ return double(1000000000.0L / freq.QuadPart);
+ }
+
+ const double nanosecs_per_tic = get_nanosecs_per_tic();
+}
+
+namespace boost
+{
+namespace chrono
+{
+
+ BOOST_CHRONO_INLINE
+ monotonic_clock::time_point monotonic_clock::now()
+ {
+
+ LARGE_INTEGER pcount;
+ if ( (nanosecs_per_tic <= 0.0L) || (!QueryPerformanceCounter( &pcount )) )
+ {
+ DWORD cause = (nanosecs_per_tic <= 0.0L ? ERROR_NOT_SUPPORTED : ::GetLastError());
+ boost::throw_exception(
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ system::system_error( cause, system::system_category, "chrono::monotonic_clock" ));
+#else
+ system::system_error( cause, system::system_category(), "chrono::monotonic_clock" ));
+#endif
+ }
+
+ return monotonic_clock::time_point(monotonic_clock::duration(
+ static_cast<monotonic_clock::rep>((nanosecs_per_tic) * pcount.QuadPart) ));
+ }
+
+ BOOST_CHRONO_INLINE
+ monotonic_clock::time_point monotonic_clock::now( system::error_code & ec )
+ {
+ static double nanosecs_per_tic = get_nanosecs_per_tic();
+
+ LARGE_INTEGER pcount;
+ if ( (nanosecs_per_tic <= 0.0L) || (!QueryPerformanceCounter( &pcount )) )
+ {
+ DWORD cause = ((nanosecs_per_tic <= 0.0L) ? ERROR_NOT_SUPPORTED : ::GetLastError());
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( cause, system::system_category );
+#else
+ ec.assign( cause, system::system_category() );
+#endif
+ return monotonic_clock::time_point(duration(0));
+ }
+
+ ec.clear();
+ return time_point(duration(
+ static_cast<monotonic_clock::rep>(nanosecs_per_tic * pcount.QuadPart) ));
+ }
+
+ BOOST_CHRONO_INLINE
+ system_clock::time_point system_clock::now()
+ {
+ FILETIME ft;
+ ::GetSystemTimeAsFileTime( &ft ); // never fails
+ return system_clock::time_point(system_clock::duration(
+ (static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime));
+ }
+
+ BOOST_CHRONO_INLINE
+ system_clock::time_point system_clock::now( system::error_code & ec )
+ {
+ FILETIME ft;
+ ::GetSystemTimeAsFileTime( &ft ); // never fails
+ ec.clear();
+ return time_point(duration(
+ (static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime));
+ }
+
+ BOOST_CHRONO_INLINE
+ std::time_t system_clock::to_time_t(const system_clock::time_point& t)
+ {
+ __int64 temp = t.time_since_epoch().count();
+
+ # if (!defined( BOOST_MSVC )) || (BOOST_MSVC > 1300) // > VC++ 7.0
+ temp -= 116444736000000000LL; // delta from epoch in microseconds
+ # else
+ temp -= 116444736000000000;
+ # endif
+
+ temp /= 10000000;
+ return static_cast<std::time_t>( temp );
+ }
+
+ BOOST_CHRONO_INLINE
+ system_clock::time_point system_clock::from_time_t(std::time_t t)
+ {
+ __int64 temp = t;
+ temp *= 10000000;
+
+ # if (!defined( BOOST_MSVC )) || (BOOST_MSVC > 1300) // > VC++ 7.0
+ temp += 116444736000000000LL;
+ # else
+ temp += 116444736000000000;
+ # endif
+
+ return time_point(duration(temp));
+ }
+
+} // namespace chrono
+} // namespace boost
+

Added: sandbox/chrono/boost/chrono/detail/inlined/win/process_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/win/process_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,62 @@
+// boost process_timer.cpp -----------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <cassert>
+
+# include <windows.h>
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ BOOST_CHRONO_INLINE
+ void process_clock::now( process_times & times_, system::error_code & ec )
+ {
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ FILETIME creation, exit, user_time, system_time;
+
+ times_.real = duration( monotonic_clock::now().time_since_epoch().count() );
+
+ if ( ::GetProcessTimes( ::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ ec.clear();
+ times_.user = duration(
+ ((static_cast<time_point::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100 );
+
+ times_.system = duration(
+ ((static_cast<time_point::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100 );
+ }
+ else
+ {
+ //~ assert( 0 && "error handling not implemented yet" );
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( ::GetLastError(), system::system_category );
+#else
+ ec.assign( ::GetLastError(), system::system_category() );
+#endif
+ times_.real = times_.system = times_.user = nanoseconds(-1);
+ }
+
+ }
+ } // namespace chrono
+} // namespace boost

Added: sandbox/chrono/boost/chrono/detail/inlined/win/thread_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/detail/inlined/win/thread_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -0,0 +1,99 @@
+// boost thread_clock.cpp -----------------------------------------------------------//
+
+// Copyright 2010 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+//--------------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/thread_clock.hpp>
+#include <cassert>
+
+# include <windows.h>
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ BOOST_CHRONO_INLINE
+ thread_clock::time_point thread_clock::now( system::error_code & ec )
+ {
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ FILETIME creation, exit, user_time, system_time;
+
+ if ( ::GetThreadTimes( ::GetCurrentThread (), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ duration user = duration(
+ ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100 );
+
+ duration system = duration(
+ ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100 );
+
+ ec.clear();
+ return time_point(system+user);
+
+ }
+ else
+ {
+ //~ assert( 0 && "error handling not implemented yet" );
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ ec.assign( ::GetLastError(), system::system_category );
+#else
+ ec.assign( ::GetLastError(), system::system_category() );
+#endif
+ return thread_clock::time_point(duration(0));
+ }
+
+ }
+
+
+ BOOST_CHRONO_INLINE
+ thread_clock::time_point thread_clock::now( )
+ {
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ FILETIME creation, exit, user_time, system_time;
+
+ if ( ::GetThreadTimes( ::GetCurrentThread (), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ duration user = duration(
+ ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100 );
+
+ duration system = duration(
+ ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100 );
+
+ return time_point(system+user);
+
+ }
+ else
+ {
+ boost::throw_exception(
+#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
+ system::system_error( ::GetLastError(), system::system_category, "chrono::monotonic_clock" ));
+#else
+ system::system_error( ::GetLastError(), system::system_category(), "chrono::monotonic_clock" ));
+#endif
+ }
+
+ }
+
+
+
+ } // namespace chrono
+} // namespace boost

Modified: sandbox/chrono/boost/chrono/detail/scan_keyword.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/scan_keyword.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/scan_keyword.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -1,18 +1,9 @@
 // scan_keyword.hpp --------------------------------------------------------------//
 
-// Copyright 2009-2010 Vicente J. Botet Escriba
+// Copyright 2010 Vicente J. Botet Escriba
 
 // Distributed under the Boost Software License, Version 1.0.
 // See http://www.boost.org/LICENSE_1_0.txt
-//===-------------------------- locale ------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-// This code was adapted to Boost by Vicente from locale file on llvm/libc++
 
 #ifndef BOOST_CHRONO_DETAIL_SCAN_KEYWORD_HPP
 #define BOOST_CHRONO_DETAIL_SCAN_KEYWORD_HPP

Modified: sandbox/chrono/boost/chrono/process_cpu_clocks.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/process_cpu_clocks.hpp (original)
+++ sandbox/chrono/boost/chrono/process_cpu_clocks.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -16,7 +16,10 @@
 #include <boost/operators.hpp>
 #include <boost/chrono/detail/system.hpp>
 
+
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_prefix.hpp> // must be the last #include
+#endif
 
 namespace boost { namespace chrono {
 
@@ -28,7 +31,7 @@
         typedef chrono::time_point<process_real_cpu_clock> time_point;
         static const bool is_monotonic = true;
 
- static time_point now( system::error_code & ec = system::throws );
+ static BOOST_CHRONO_INLINE time_point now( system::error_code & ec = system::throws );
     };
 
     class BOOST_CHRONO_DECL process_user_cpu_clock {
@@ -39,7 +42,7 @@
         typedef chrono::time_point<process_user_cpu_clock> time_point;
         static const bool is_monotonic = true;
 
- static time_point now( system::error_code & ec = system::throws );
+ static BOOST_CHRONO_INLINE time_point now( system::error_code & ec = system::throws );
     };
 
     class BOOST_CHRONO_DECL process_system_cpu_clock {
@@ -50,7 +53,7 @@
         typedef chrono::time_point<process_system_cpu_clock> time_point;
         static const bool is_monotonic = true;
 
- static time_point now( system::error_code & ec = system::throws );
+ static BOOST_CHRONO_INLINE time_point now( system::error_code & ec = system::throws );
     };
 
         struct process_cpu_clock_times : arithmetic<process_cpu_clock_times, multiplicative<process_cpu_clock_times, process_real_cpu_clock::rep, less_than_comparable<process_cpu_clock_times> > >
@@ -140,7 +143,7 @@
         typedef chrono::time_point<process_cpu_clock> time_point;
         static const bool is_monotonic = true;
 
- static time_point now( system::error_code & ec = system::throws );
+ static BOOST_CHRONO_INLINE time_point now( system::error_code & ec = system::throws );
     };
 
     template <typename OSTREAM>
@@ -228,6 +231,10 @@
     };
 }
 
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+#else
+#include <boost/chrono/detail/inlined/process_cpu_clocks.hpp>
+#endif
 
 #endif // BOOST_CHRONO_PROCESS_CPU_CLOCKS_HPP

Modified: sandbox/chrono/boost/chrono/process_times.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/process_times.hpp (original)
+++ sandbox/chrono/boost/chrono/process_times.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -17,7 +17,10 @@
 #include <string>
 #include <ostream>
 
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_prefix.hpp> // must be the last #include
+#endif
+
 
 namespace boost
 {
@@ -49,12 +52,13 @@
           process_clock::time_point system; // system cpu time
         };
 
- static void now( durations & times,
+ static BOOST_CHRONO_INLINE void now( durations & times,
                          system::error_code & ec = system::throws );
- static void now( time_points & times,
+ static BOOST_CHRONO_INLINE void now( time_points & times,
                          system::error_code & ec = system::throws );
     };
 
+
 //--------------------------------------------------------------------------------------//
 // process_times //
 //--------------------------------------------------------------------------------------//
@@ -184,6 +188,10 @@
   } // namespace chrono
 } // namespace boost
 
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+#else
+#include <boost/chrono/detail/inlined/process_clock.hpp>
+#endif
 
 #endif // BOOST_PROCESS_TIMES_HPP

Modified: sandbox/chrono/boost/chrono/system_clocks.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/system_clocks.hpp (original)
+++ sandbox/chrono/boost/chrono/system_clocks.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -74,7 +74,10 @@
 # define BOOST_SYSTEM_CLOCK_DURATION boost::chrono::nanoseconds
 #endif
 
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_prefix.hpp> // must be the last #include
+#endif
+
 
 //----------------------------------------------------------------------------//
 // //
@@ -124,11 +127,11 @@
       typedef chrono::time_point<system_clock> time_point;
       static const bool is_monotonic = false;
 
- static time_point now(); // throws on error
- static time_point now(system::error_code & ec); // never throws
+ static BOOST_CHRONO_INLINE time_point now(); // throws on error
+ static BOOST_CHRONO_INLINE time_point now(system::error_code & ec); // never throws
 
- static std::time_t to_time_t(const time_point& t);
- static time_point from_time_t(std::time_t t);
+ static BOOST_CHRONO_INLINE std::time_t to_time_t(const time_point& t);
+ static BOOST_CHRONO_INLINE time_point from_time_t(std::time_t t);
   };
 
 //----------------------------------------------------------------------------//
@@ -148,8 +151,8 @@
       typedef chrono::time_point<monotonic_clock> time_point;
       static const bool is_monotonic = true;
 
- static time_point now(); // throws on error
- static time_point now(system::error_code & ec); // never throws
+ static BOOST_CHRONO_INLINE time_point now(); // throws on error
+ static BOOST_CHRONO_INLINE time_point now(system::error_code & ec); // never throws
   };
 #endif
 //----------------------------------------------------------------------------//
@@ -163,6 +166,10 @@
 } // namespace chrono
 } // namespace boost
 
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+#else
+#include <boost/chrono/detail/inlined/chrono.hpp>
+#endif
 
 #endif // BOOST_CHRONO_SYSTEM_CLOCKS_HPP

Modified: sandbox/chrono/boost/chrono/thread_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/thread_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/thread_clock.hpp 2010-10-12 19:31:13 EDT (Tue, 12 Oct 2010)
@@ -16,7 +16,9 @@
 #include <boost/system/error_code.hpp>
 #include <boost/chrono/detail/system.hpp>
 
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_prefix.hpp> // must be the last #include
+#endif
 
 #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
 
@@ -30,14 +32,18 @@
     typedef chrono::time_point<thread_clock> time_point;
     static const bool is_monotonic = BOOST_CHRONO_THREAD_CLOCK_IS_MONOTONIC;
 
- static time_point now( );
- static time_point now( system::error_code & ec );
+ static BOOST_CHRONO_INLINE time_point now( );
+ static BOOST_CHRONO_INLINE time_point now( system::error_code & ec );
 };
 } // namespace chrono
 } // namespace boost
 
 #endif
 
+#ifndef BOOST_CHRONO_INLINED
 #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+#else
+#include <boost/chrono/detail/inlined/thread_clock.hpp>
+#endif
 
 #endif // BOOST_CHRONO_THREAD_CLOCK_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk