Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74436 - in trunk/boost/chrono: . detail/inlined/mac detail/inlined/posix detail/inlined/win
From: vicente.botet_at_[hidden]
Date: 2011-09-17 07:30:51


Author: viboes
Date: 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
New Revision: 74436
URL: http://svn.boost.org/trac/boost/changeset/74436

Log:
Chrono: Inspect + cleanup
Removed:
   trunk/boost/chrono/detail/inlined/mac/process_clock.hpp
   trunk/boost/chrono/detail/inlined/posix/process_clock.hpp
   trunk/boost/chrono/detail/inlined/win/process_clock.hpp
Text files modified:
   trunk/boost/chrono/chrono_io.hpp | 10 ++------
   trunk/boost/chrono/config.hpp | 5 ++++
   trunk/boost/chrono/detail/inlined/win/chrono.hpp | 32 +++++++++++++++---------------
   trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp | 42 ++++++++++++++++++++--------------------
   trunk/boost/chrono/process_cpu_clocks.hpp | 5 ++++
   5 files changed, 50 insertions(+), 44 deletions(-)

Modified: trunk/boost/chrono/chrono_io.hpp
==============================================================================
--- trunk/boost/chrono/chrono_io.hpp (original)
+++ trunk/boost/chrono/chrono_io.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
@@ -838,10 +838,6 @@
 
             return result;
         }
- //~ #else
- //~ time_t internal_timegm(std::tm *t)
- //~ return timegm(t);
- //~ }
         #endif
 } // detail
 
@@ -1071,7 +1067,7 @@
                 const _CharT z[2] = {'%', 'z'};
                 const _CharT* fz = std::search(pb, pe, z, z+2);
                 tg.get(is, 0, is, err, &tm, pb, fz);
- minutes min(0);
+ minutes minu(0);
                 if (fz != pe)
                 {
                     if (err != std::ios_base::goodbit)
@@ -1081,7 +1077,7 @@
                     }
                     _I i(is);
                     _I eof;
- min = extract_z(i, eof, err, ct);
+ minu = extract_z(i, eof, err, ct);
                     if (err & std::ios_base::failbit)
                         goto exit;
                     if (fz+2 != pe)
@@ -1106,7 +1102,7 @@
                 #endif
                 else
                     t = mktime(&tm);
- tp = system_clock::from_time_t(t) - min;
+ tp = system_clock::from_time_t(t) - minu;
             }
         }
         catch (...)

Modified: trunk/boost/chrono/config.hpp
==============================================================================
--- trunk/boost/chrono/config.hpp (original)
+++ trunk/boost/chrono/config.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
@@ -73,6 +73,11 @@
 #undef BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
 #endif
 
+#ifdef UNDER_CE
+#else
+#define BOOST_CHRONO_HAS_PROCESS_CLOCKS
+#endif
+
 // unicode support ------------------------------//
 
 #if defined(BOOST_NO_UNICODE_LITERALS) || defined(BOOST_NO_CHAR16_T) || defined(BOOST_NO_CHAR32_T)

Deleted: trunk/boost/chrono/detail/inlined/mac/process_clock.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/mac/process_clock.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
+++ (empty file)
@@ -1,104 +0,0 @@
-// 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.
-
-//--------------------------------------------------------------------------------------//
-
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/process_times.hpp>
-#include <boost/assert.hpp>
-
-#include <sys/time.h> //for gettimeofday and timeval
-#include <sys/times.h> //for times
-# include <unistd.h>
-
-namespace boost
-{
-namespace chrono
-{
-namespace chrono_detail
-{
- 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
- {
- BOOST_ASSERT( factor <= 1000000l ); // doesn't handle large ticks
- factor = 1000000l / factor; // compute factor
- if ( !factor ) factor = -1;
- }
- }
- return factor;
- }
-}
-
- void process_clock::now( process_times & times_, system::error_code & ec )
- {
-
- tms tm;
- clock_t c = ::times( &tm );
- if ( c == -1 ) // error
- {
- if (BOOST_CHRONO_IS_THROWS(ec))
- {
- boost::throw_exception(
- system::system_error(
- errno,
- BOOST_CHRONO_SYSTEM_CATEGORY,
- "chrono::process_clock" ));
- }
- else
- {
- ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
- 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 ( chrono_detail::tick_factor() != -1 )
- {
- times_.real *= chrono_detail::tick_factor();
- times_.user *= chrono_detail::tick_factor();
- times_.system *= chrono_detail::tick_factor();
- if (!BOOST_CHRONO_IS_THROWS(ec))
- {
- ec.clear();
- }
- }
- else
- {
- if (BOOST_CHRONO_IS_THROWS(ec))
- {
- boost::throw_exception(
- system::system_error(
- errno,
- BOOST_CHRONO_SYSTEM_CATEGORY,
- "chrono::process_clock" ));
- }
- else
- {
- ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
- times_.real = times_.user = times_.system = nanoseconds(-1);
- }
- }
- }
-
-}
-} // namespace chrono
-} // namespace boost

Deleted: trunk/boost/chrono/detail/inlined/posix/process_clock.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/posix/process_clock.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
+++ (empty file)
@@ -1,97 +0,0 @@
-// 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.
-
-//--------------------------------------------------------------------------------------//
-
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/process_times.hpp>
-#include <boost/assert.hpp>
-
-# include <sys/times.h>
-# include <unistd.h>
-
-
-namespace boost { namespace chrono {
-namespace chrono_detail
-{
- 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
- {
- BOOST_ASSERT( factor <= 1000000l ); // doesn't handle large ticks
- factor = 1000000l / factor; // compute factor
- if ( !factor ) factor = -1;
- }
- }
- return factor;
- }
-}
-
- void process_clock::now( process_times & times_, system::error_code & ec ) {
-
- tms tm;
- clock_t c = ::times( &tm );
- if ( c == clock_t(-1) ) // error
- {
- if (BOOST_CHRONO_IS_THROWS(ec))
- {
- boost::throw_exception(
- system::system_error(
- errno,
- BOOST_CHRONO_SYSTEM_CATEGORY,
- "chrono::process_clock" ));
- }
- else
- {
- ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
- 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 ( chrono_detail::tick_factor() != -1 )
- {
- if (!BOOST_CHRONO_IS_THROWS(ec))
- {
- ec.clear();
- }
- times_.real *= chrono_detail::tick_factor();
- times_.user *= chrono_detail::tick_factor();
- times_.system *= chrono_detail::tick_factor();
- }
- else
- {
- if (BOOST_CHRONO_IS_THROWS(ec))
- {
- boost::throw_exception(
- system::system_error(
- errno,
- BOOST_CHRONO_SYSTEM_CATEGORY,
- "chrono::process_clock" ));
- }
- else
- {
- ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
- times_.real = times_.user = times_.system = nanoseconds(-1);
- }
- }
- }
-
- }
-} }

Modified: trunk/boost/chrono/detail/inlined/win/chrono.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/win/chrono.hpp (original)
+++ trunk/boost/chrono/detail/inlined/win/chrono.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
@@ -95,14 +95,14 @@
   system_clock::time_point system_clock::now()
   {
     boost::detail::win32::FILETIME_ ft;
- #if defined(UNDER_CE)
- // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps.
- boost::detail::win32::SYSTEMTIME_ st;
- boost::detail::win32::GetSystemTime( &st );
- boost::detail::win32::SystemTimeToFileTime( &st, &ft );
- #else
- boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails
- #endif
+ #if defined(UNDER_CE)
+ // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps.
+ boost::detail::win32::SYSTEMTIME_ st;
+ boost::detail::win32::GetSystemTime( &st );
+ boost::detail::win32::SystemTimeToFileTime( &st, &ft );
+ #else
+ boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails
+ #endif
     return system_clock::time_point(system_clock::duration(
       (static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime));
   }
@@ -111,14 +111,14 @@
   system_clock::time_point system_clock::now( system::error_code & ec )
   {
     boost::detail::win32::FILETIME_ ft;
- #if defined(UNDER_CE)
- // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps.
- boost::detail::win32::SYSTEMTIME_ st;
- boost::detail::win32::GetSystemTime( &st );
- boost::detail::win32::SystemTimeToFileTime( &st, &ft );
- #else
- boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails
- #endif
+ #if defined(UNDER_CE)
+ // Windows CE does not define GetSystemTimeAsFileTime so we do it in two steps.
+ boost::detail::win32::SYSTEMTIME_ st;
+ boost::detail::win32::GetSystemTime( &st );
+ boost::detail::win32::SystemTimeToFileTime( &st, &ft );
+ #else
+ boost::detail::win32::GetSystemTimeAsFileTime( &ft ); // never fails
+ #endif
     if (!BOOST_CHRONO_IS_THROWS(ec))
     {
         ec.clear();

Deleted: trunk/boost/chrono/detail/inlined/win/process_clock.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/win/process_clock.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
+++ (empty file)
@@ -1,80 +0,0 @@
-// boost process_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.
-
-//--------------------------------------------------------------------------------------//
-#ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_PROCESS_CLOCK_HPP
-#define BOOST_CHRONO_DETAIL_INLINED_WIN_PROCESS_CLOCK_HPP
-
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/system_clocks.hpp>
-#include <boost/chrono/process_times.hpp>
-#include <cassert>
-
-#include <boost/detail/win/GetLastError.hpp>
-#include <boost/detail/win/GetCurrentProcess.hpp>
-#include <boost/detail/win/GetProcessTimes.hpp>
-
-namespace boost
-{
-namespace chrono
-{
-
-void process_clock::now( process_times & times_, system::error_code & ec )
-{
-
- // note that Windows uses 100 nanosecond ticks for FILETIME
- boost::detail::win32::FILETIME_ creation, exit, user_time, system_time;
-
- times_.real = duration( steady_clock::now().time_since_epoch().count() );
-
- #ifdef UNDER_CE
- // Windows CE does not support GetProcessTimes
- assert( 0 && "GetProcessTimes not supported under Windows CE" );
- times_.real = times_.system = times_.user = nanoseconds(-1);
- #else
- if ( boost::detail::win32::GetProcessTimes(
- boost::detail::win32::GetCurrentProcess(), &creation, &exit,
- &system_time, &user_time ) )
- {
- if (!BOOST_CHRONO_IS_THROWS(ec))
- {
- 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
- {
- boost::detail::win32::DWORD_ cause = boost::detail::win32::GetLastError();
- if (BOOST_CHRONO_IS_THROWS(ec))
- {
- boost::throw_exception(
- system::system_error(
- cause,
- BOOST_CHRONO_SYSTEM_CATEGORY,
- "chrono::process_clock" ));
- }
- else
- {
- ec.assign( cause, BOOST_CHRONO_SYSTEM_CATEGORY );
- times_.real = times_.system = times_.user = nanoseconds(-1);
- }
- }
- #endif
-}
-} // namespace chrono
-} // namespace boost
-
-#endif

Modified: trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp
==============================================================================
--- trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp (original)
+++ trunk/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
@@ -33,11 +33,11 @@
     // note that Windows uses 100 nanosecond ticks for FILETIME
     boost::detail::win32::FILETIME_ creation, exit, user_time, system_time;
 
- #ifdef UNDER_CE
- // Windows CE does not support GetProcessTimes
+ #ifdef UNDER_CE
+ // Windows CE does not support GetProcessTimes
     assert( 0 && "GetProcessTimes not supported under Windows CE" );
- return time_point();
- #else
+ return time_point();
+ #else
     if ( boost::detail::win32::GetProcessTimes(
             boost::detail::win32::GetCurrentProcess(), &creation, &exit,
             &system_time, &user_time ) )
@@ -65,7 +65,7 @@
             return time_point();
         }
     }
- #endif
+ #endif
 
 }
 process_user_cpu_clock::time_point process_user_cpu_clock::now(
@@ -75,11 +75,11 @@
     // note that Windows uses 100 nanosecond ticks for FILETIME
     boost::detail::win32::FILETIME_ creation, exit, user_time, system_time;
 
- #ifdef UNDER_CE
- // Windows CE does not support GetProcessTimes
+ #ifdef UNDER_CE
+ // Windows CE does not support GetProcessTimes
     assert( 0 && "GetProcessTimes not supported under Windows CE" );
- return time_point();
- #else
+ return time_point();
+ #else
     if ( boost::detail::win32::GetProcessTimes(
             boost::detail::win32::GetCurrentProcess(), &creation, &exit,
             &system_time, &user_time ) )
@@ -110,7 +110,7 @@
             return time_point();
         }
     }
- #endif
+ #endif
 
 }
 process_system_cpu_clock::time_point process_system_cpu_clock::now(
@@ -120,11 +120,11 @@
     // note that Windows uses 100 nanosecond ticks for FILETIME
     boost::detail::win32::FILETIME_ creation, exit, user_time, system_time;
 
- #ifdef UNDER_CE
- // Windows CE does not support GetProcessTimes
+ #ifdef UNDER_CE
+ // Windows CE does not support GetProcessTimes
     assert( 0 && "GetProcessTimes not supported under Windows CE" );
- return time_point();
- #else
+ return time_point();
+ #else
     if ( boost::detail::win32::GetProcessTimes(
             boost::detail::win32::GetCurrentProcess(), &creation, &exit,
             &system_time, &user_time ) )
@@ -155,8 +155,8 @@
             return time_point();
         }
     }
- #endif
-
+ #endif
+
 }
 process_cpu_clock::time_point process_cpu_clock::now(
         system::error_code & ec )
@@ -165,11 +165,11 @@
     // note that Windows uses 100 nanosecond ticks for FILETIME
     boost::detail::win32::FILETIME_ creation, exit, user_time, system_time;
 
- #ifdef UNDER_CE
- // Windows CE does not support GetProcessTimes
+ #ifdef UNDER_CE
+ // Windows CE does not support GetProcessTimes
     assert( 0 && "GetProcessTimes not supported under Windows CE" );
- return time_point();
- #else
+ return time_point();
+ #else
     if ( boost::detail::win32::GetProcessTimes(
             boost::detail::win32::GetCurrentProcess(), &creation, &exit,
             &system_time, &user_time ) )
@@ -206,7 +206,7 @@
             return time_point();
         }
     }
- #endif
+ #endif
 
 }
 } // namespace chrono

Modified: trunk/boost/chrono/process_cpu_clocks.hpp
==============================================================================
--- trunk/boost/chrono/process_cpu_clocks.hpp (original)
+++ trunk/boost/chrono/process_cpu_clocks.hpp 2011-09-17 07:30:49 EDT (Sat, 17 Sep 2011)
@@ -10,6 +10,10 @@
 #ifndef BOOST_CHRONO_PROCESS_CPU_CLOCKS_HPP
 #define BOOST_CHRONO_PROCESS_CPU_CLOCKS_HPP
 
+
+
+#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
+
 #include <boost/chrono/duration.hpp>
 #include <boost/chrono/time_point.hpp>
 #include <boost/system/error_code.hpp>
@@ -296,5 +300,6 @@
 #else
 #include <boost/chrono/detail/inlined/process_cpu_clocks.hpp>
 #endif
+#endif
 
 #endif // BOOST_CHRONO_PROCESS_CPU_CLOCKS_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