Added boost header
This commit is contained in:
241
test/external/boost/chrono/detail/inlined/mac/chrono.hpp
vendored
Normal file
241
test/external/boost/chrono/detail/inlined/mac/chrono.hpp
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
// mac/chrono.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
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// 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
|
||||
system_clock::time_point
|
||||
system_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
system_clock::time_point
|
||||
system_clock::now(system::error_code & ec)
|
||||
{
|
||||
timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
|
||||
}
|
||||
#endif
|
||||
// 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.
|
||||
time_t
|
||||
system_clock::to_time_t(const time_point& t) BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
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.
|
||||
system_clock::time_point
|
||||
system_clock::from_time_t(time_t t) BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
return system_clock::time_point(seconds(t));
|
||||
}
|
||||
|
||||
namespace chrono_detail
|
||||
{
|
||||
|
||||
// steady_clock
|
||||
|
||||
// Note, in this implementation steady_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
|
||||
steady_clock::rep
|
||||
steady_simplified()
|
||||
{
|
||||
return mach_absolute_time();
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
BOOST_CHRONO_STATIC
|
||||
steady_clock::rep
|
||||
steady_simplified_ec(system::error_code & ec)
|
||||
{
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return mach_absolute_time();
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_CHRONO_STATIC
|
||||
double
|
||||
compute_steady_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
|
||||
steady_clock::rep
|
||||
steady_full()
|
||||
{
|
||||
static kern_return_t err;
|
||||
static const double factor = chrono_detail::compute_steady_factor(err);
|
||||
if (err != 0)
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
return static_cast<steady_clock::rep>(mach_absolute_time() * factor);
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
BOOST_CHRONO_STATIC
|
||||
steady_clock::rep
|
||||
steady_full_ec(system::error_code & ec)
|
||||
{
|
||||
static kern_return_t err;
|
||||
static const double factor = chrono_detail::compute_steady_factor(err);
|
||||
if (err != 0)
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
err,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::steady_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return steady_clock::rep();
|
||||
}
|
||||
}
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return static_cast<steady_clock::rep>(mach_absolute_time() * factor);
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef steady_clock::rep (*FP)();
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
typedef steady_clock::rep (*FP_ec)(system::error_code &);
|
||||
#endif
|
||||
|
||||
BOOST_CHRONO_STATIC
|
||||
FP
|
||||
init_steady_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 &chrono_detail::steady_simplified;
|
||||
}
|
||||
return &chrono_detail::steady_full;
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
BOOST_CHRONO_STATIC
|
||||
FP_ec
|
||||
init_steady_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 &chrono_detail::steady_simplified_ec;
|
||||
}
|
||||
return &chrono_detail::steady_full_ec;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
steady_clock::time_point
|
||||
steady_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
static kern_return_t err;
|
||||
static chrono_detail::FP fp = chrono_detail::init_steady_clock(err);
|
||||
if ( err != 0 )
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
return time_point(duration(fp()));
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
steady_clock::time_point
|
||||
steady_clock::now(system::error_code & ec)
|
||||
{
|
||||
static kern_return_t err;
|
||||
static chrono_detail::FP_ec fp = chrono_detail::init_steady_clock_ec(err);
|
||||
if ( err != 0 )
|
||||
{
|
||||
if (BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
boost::throw_exception(
|
||||
system::system_error(
|
||||
err,
|
||||
BOOST_CHRONO_SYSTEM_CATEGORY,
|
||||
"chrono::steady_clock" ));
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.assign( err, BOOST_CHRONO_SYSTEM_CATEGORY );
|
||||
return time_point();
|
||||
}
|
||||
}
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(duration(fp(ec)));
|
||||
}
|
||||
#endif
|
||||
} // namespace chrono
|
||||
} // namespace boost
|
||||
331
test/external/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp
vendored
Normal file
331
test/external/boost/chrono/detail/inlined/mac/process_cpu_clocks.hpp
vendored
Normal file
@@ -0,0 +1,331 @@
|
||||
// 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/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 <= 1000000000l); // doesn't handle large ticks
|
||||
factor = 1000000000l / factor; // compute factor
|
||||
if (!factor)
|
||||
factor = -1;
|
||||
}
|
||||
}
|
||||
return factor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_CHRONO_NOEXCEPT
|
||||
{
|
||||
#if 0
|
||||
tms tm;
|
||||
clock_t c = ::times(&tm);
|
||||
if (c == clock_t(-1)) // error
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
} else
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
return time_point(nanoseconds(c * factor));
|
||||
} else
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
}
|
||||
return time_point();
|
||||
#else
|
||||
clock_t c = ::clock();
|
||||
if (c == clock_t(-1)) // error
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
return time_point(
|
||||
duration(c*(1000000000l/CLOCKS_PER_SEC))
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
process_real_cpu_clock::time_point process_real_cpu_clock::now(system::error_code & ec)
|
||||
{
|
||||
|
||||
#if 0
|
||||
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
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(nanoseconds(c * 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
clock_t c = ::clock();
|
||||
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();
|
||||
}
|
||||
}
|
||||
return time_point(
|
||||
duration(c*(1000000000l/CLOCKS_PER_SEC))
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(nanoseconds((tm.tms_utime + tm.tms_cutime) * 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_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
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
return time_point(nanoseconds((tm.tms_utime + tm.tms_cutime)
|
||||
* factor));
|
||||
} else
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
}
|
||||
return time_point();
|
||||
}
|
||||
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");
|
||||
} else
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
return time_point(nanoseconds((tm.tms_stime + tm.tms_cstime)
|
||||
* factor));
|
||||
} else
|
||||
{
|
||||
BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
|
||||
}
|
||||
}
|
||||
return time_point();
|
||||
}
|
||||
|
||||
#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
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
if (!BOOST_CHRONO_IS_THROWS(ec))
|
||||
{
|
||||
ec.clear();
|
||||
}
|
||||
return time_point(nanoseconds((tm.tms_stime + tm.tms_cstime) * 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
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
time_point::rep
|
||||
r(c * factor, (tm.tms_utime + tm.tms_cutime) * factor, (tm.tms_stime
|
||||
+ tm.tms_cstime) * 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
|
||||
{
|
||||
long factor = chrono_detail::tick_factor();
|
||||
if (factor != -1)
|
||||
{
|
||||
time_point::rep
|
||||
r(c * factor, (tm.tms_utime + tm.tms_cutime) * factor, (tm.tms_stime
|
||||
+ tm.tms_cstime) * 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
|
||||
|
||||
}
|
||||
}
|
||||
15
test/external/boost/chrono/detail/inlined/mac/thread_clock.hpp
vendored
Normal file
15
test/external/boost/chrono/detail/inlined/mac/thread_clock.hpp
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#include <boost/chrono/config.hpp>
|
||||
#include <boost/chrono/detail/inlined/posix/thread_clock.hpp>
|
||||
#include <cassert>
|
||||
|
||||
Reference in New Issue
Block a user