Added boost header
This commit is contained in:
120
test/external/boost/chrono/detail/inlined/posix/chrono.hpp
vendored
Normal file
120
test/external/boost/chrono/detail/inlined/posix/chrono.hpp
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
// 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
|
||||
{
|
||||
|
||||
system_clock::time_point system_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
timespec ts;
|
||||
if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
|
||||
return time_point(duration(
|
||||
static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
system_clock::time_point system_clock::now(system::error_code & ec)
|
||||
{
|
||||
timespec ts;
|
||||
if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
errno,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::system_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(duration(
|
||||
static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
|
||||
}
|
||||
#endif
|
||||
|
||||
std::time_t system_clock::to_time_t(const system_clock::time_point& t) BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
return static_cast<std::time_t>( t.time_since_epoch().count() / 1000000000 );
|
||||
}
|
||||
|
||||
system_clock::time_point system_clock::from_time_t(std::time_t t) BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
return time_point(duration(static_cast<system_clock::rep>(t) * 1000000000));
|
||||
}
|
||||
|
||||
#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
|
||||
|
||||
steady_clock::time_point steady_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
timespec ts;
|
||||
if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
|
||||
return time_point(duration(
|
||||
static_cast<steady_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
steady_clock::time_point steady_clock::now(system::error_code & ec)
|
||||
{
|
||||
timespec ts;
|
||||
if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
errno,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::steady_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(duration(
|
||||
static_cast<steady_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} // namespace chrono
|
||||
} // namespace boost
|
||||
|
||||
|
||||
352
test/external/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp
vendored
Normal file
352
test/external/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp
vendored
Normal file
@@ -0,0 +1,352 @@
|
||||
// boost process_cpu_clocks.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_cpu_clocks.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <sys/times.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h> // for clock_gettime
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
tms tm;
|
||||
clock_t c = ::times( &tm );
|
||||
if ( c == clock_t(-1) ) // error
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
return time_point(
|
||||
microseconds(c*chrono_detail::tick_factor()));
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
}
|
||||
return time_point();
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
process_real_cpu_clock::time_point process_real_cpu_clock::now(
|
||||
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_real_cpu_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(
|
||||
microseconds(c*chrono_detail::tick_factor()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
errno,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::process_real_cpu_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
process_user_cpu_clock::time_point process_user_cpu_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
tms tm;
|
||||
clock_t c = ::times( &tm );
|
||||
if ( c == clock_t(-1) ) // error
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
return time_point(
|
||||
microseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor()));
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
}
|
||||
return time_point();
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
process_user_cpu_clock::time_point process_user_cpu_clock::now(
|
||||
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_user_cpu_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(
|
||||
microseconds((tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
errno,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::process_user_cpu_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
process_system_cpu_clock::time_point process_system_cpu_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
tms tm;
|
||||
clock_t c = ::times( &tm );
|
||||
if ( c == clock_t(-1) ) // error
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
return time_point();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
return time_point(
|
||||
microseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor()));
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
process_system_cpu_clock::time_point process_system_cpu_clock::now(
|
||||
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_system_cpu_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(
|
||||
microseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
errno,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::process_system_cpu_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
process_cpu_clock::time_point process_cpu_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
tms tm;
|
||||
clock_t c = ::times( &tm );
|
||||
if ( c == clock_t(-1) ) // error
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
time_point::rep r(
|
||||
1000*c*chrono_detail::tick_factor(),
|
||||
1000*(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
|
||||
1000*(tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
|
||||
return time_point(duration(r));
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
}
|
||||
return time_point();
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
process_cpu_clock::time_point process_cpu_clock::now(
|
||||
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 );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( chrono_detail::tick_factor() != -1 )
|
||||
{
|
||||
time_point::rep r(
|
||||
1000*c*chrono_detail::tick_factor(),
|
||||
1000*(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
|
||||
1000*(tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
|
||||
return time_point(duration(r));
|
||||
}
|
||||
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 );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
} }
|
||||
88
test/external/boost/chrono/detail/inlined/posix/thread_clock.hpp
vendored
Normal file
88
test/external/boost/chrono/detail/inlined/posix/thread_clock.hpp
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
// boost thread_clock.cpp -----------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 1994, 2006, 2008
|
||||
// Copyright Vicente J. Botet Escriba 2009-2011
|
||||
|
||||
// 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/thread_clock.hpp>
|
||||
#include <cassert>
|
||||
|
||||
# include <sys/times.h>
|
||||
# include <unistd.h>
|
||||
|
||||
namespace boost { namespace chrono {
|
||||
|
||||
thread_clock::time_point thread_clock::now( ) BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
struct timespec ts;
|
||||
#if defined CLOCK_THREAD_CPUTIME_ID
|
||||
// get the timespec associated to the thread clock
|
||||
if ( ::clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ) )
|
||||
#else
|
||||
// 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
|
||||
if ( ::clock_gettime( clock_id, &ts ) )
|
||||
#endif
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
|
||||
// transform to nanoseconds
|
||||
return time_point(duration(
|
||||
static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
|
||||
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
thread_clock::time_point thread_clock::now( system::error_code & ec )
|
||||
{
|
||||
struct timespec ts;
|
||||
#if defined CLOCK_THREAD_CPUTIME_ID
|
||||
// get the timespec associated to the thread clock
|
||||
if ( ::clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ) )
|
||||
#else
|
||||
// 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
|
||||
if ( ::clock_gettime( clock_id, &ts ) )
|
||||
#endif
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
errno,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::thread_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
// transform to nanoseconds
|
||||
return time_point(duration(
|
||||
static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
|
||||
|
||||
}
|
||||
#endif
|
||||
} }
|
||||
Reference in New Issue
Block a user