Chrono fixes for VS Update 2

This commit is contained in:
seelabs
2016-02-23 20:21:16 -05:00
parent d3b43bfa37
commit 3605bf1f60
24 changed files with 34 additions and 898 deletions

View File

@@ -86,7 +86,7 @@
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug.classic|x64'">
<ClCompile>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;-DBOOST_NO_AUTO_PTR;DEBUG;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEBUG;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4244;4267;4018</DisableSpecificWarnings>
<ExceptionHandling>Async</ExceptionHandling>
@@ -123,7 +123,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
<ClCompile>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;-DBOOST_NO_AUTO_PTR;DEBUG;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEBUG;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4244;4267;4018</DisableSpecificWarnings>
<ExceptionHandling>Async</ExceptionHandling>
@@ -160,7 +160,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release.classic|x64'">
<ClCompile>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;-DBOOST_NO_AUTO_PTR;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NDEBUG;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NDEBUG;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4244;4267;4018</DisableSpecificWarnings>
<ExceptionHandling>Async</ExceptionHandling>
@@ -195,7 +195,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
<ClCompile>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;-DBOOST_NO_AUTO_PTR;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NDEBUG;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NDEBUG;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4800;4244;4267;4018</DisableSpecificWarnings>
<ExceptionHandling>Async</ExceptionHandling>
@@ -282,20 +282,13 @@
<ClCompile Include="..\..\src\beast\beast\chrono\Chrono.unity.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\chrono\chrono_io.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\chrono\chrono_util.h">
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\chrono\impl\chrono_io.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\chrono\impl\RelativeTime.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\chrono\manual_clock.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\chrono\ratio_io.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\chrono\RelativeTime.h">
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\chrono\tests\abstract_clock.test.cpp">

View File

@@ -627,24 +627,15 @@
<ClCompile Include="..\..\src\beast\beast\chrono\Chrono.unity.cpp">
<Filter>beast\chrono</Filter>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\chrono\chrono_io.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\chrono\chrono_util.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\chrono\impl\chrono_io.cpp">
<Filter>beast\chrono\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\chrono\impl\RelativeTime.cpp">
<Filter>beast\chrono\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\chrono\manual_clock.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\chrono\ratio_io.h">
<Filter>beast\chrono</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\chrono\RelativeTime.h">
<Filter>beast\chrono</Filter>
</ClInclude>

View File

@@ -359,7 +359,7 @@ def config_base(env):
,{'HAVE_USLEEP' : '1'}
,{'SOCI_CXX_C11' : '1'}
,'_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS'
,'-DBOOST_NO_AUTO_PTR'
,'BOOST_NO_AUTO_PTR'
])
if Beast.system.windows:

View File

@@ -22,7 +22,6 @@
#include <beast/chrono/abstract_clock.h>
#include <beast/chrono/basic_seconds_clock.h>
#include <beast/chrono/chrono_io.h>
#include <beast/chrono/chrono_util.h>
#include <beast/chrono/manual_clock.h>
#include <beast/chrono/ratio_io.h>

View File

@@ -23,7 +23,6 @@
#include <beast/Config.h>
#include <beast/chrono/impl/chrono_io.cpp>
#include <beast/chrono/impl/RelativeTime.cpp>
#include <beast/chrono/tests/abstract_clock.test.cpp>

View File

@@ -107,6 +107,7 @@ public:
for (auto iter : workers_)
iter->sample();
using namespace std::chrono;
clock_type::time_point const when (
floor <seconds> (
clock_type::now().time_since_epoch()) +

View File

@@ -1,803 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
// chrono_io
//
// (C) Copyright Howard Hinnant
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
#ifndef BEAST_CHRONO_CHRONO_IO_H_INCLUDED
#define BEAST_CHRONO_CHRONO_IO_H_INCLUDED
#include <beast/Config.h>
#include <ctime>
#include <locale>
/*
chrono_io synopsis
#include <chrono>
#include <ratio_io>
namespace std
{
namespace chrono
{
enum duration_style {prefix, symbol};
enum timezone {utc, local};
// facets
class durationpunct
: public locale::facet
{
public:
static locale::id id;
explicit durationpunct(size_t refs = 0);
explicit durationpunct(duration_style fmt, size_t refs = 0);
bool is_symbol_name() const noexcept;
bool is_prefix_name() const noexcept;
};
template <class charT>
class timepunct
: public locale::facet
{
public:
typedef basic_string<charT> string_type;
static locale::id id;
explicit timepunct(size_t refs = 0);
timepunct(timezone tz, string_type fmt, size_t refs = 0);
const string_type& fmt() const noexcept;
std::chrono::timezone timezone() const noexcept;
};
// manipulators
class duration_fmt
{
public:
explicit duration_fmt(duration_style f) noexcept;
explicit operator duration_style() const noexcept;
};
unspecified time_fmt(timezone tz);
template<class charT>
unspecified time_fmt(timezone tz, basic_string<charT> fmt);
template<class charT>
unspecified time_fmt(timezone tz, const charT* fmt);
template<class charT, class traits>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, duration_fmt d);
template<class charT, class traits>
std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is, duration_fmt d);
// duration I/O
template <class charT, class Traits, class Rep, class Period>
basic_ostream<charT, Traits>&
operator<<(basic_ostream<charT, Traits>& os, const duration<Rep, Period>& d);
template <class charT, class Traits, class Rep, class Period>
basic_istream<charT, Traits>&
operator>>(basic_istream<charT, Traits>& is, duration<Rep, Period>& d);
// system_clock I/O
template <class charT, class Traits, class Duration>
basic_ostream<charT, Traits>&
operator<<(basic_ostream<charT, Traits>& os,
const time_point<system_clock, Duration>& tp);
template <class charT, class Traits, class Duration>
basic_istream<charT, Traits>&
operator>>(basic_istream<charT, Traits>& is,
time_point<system_clock, Duration>& tp);
// steady_clock I/O
template <class charT, class Traits, class Duration>
basic_ostream<charT, Traits>&
operator<<(basic_ostream<charT, Traits>& os,
const time_point<steady_clock, Duration>& tp);
template <class charT, class Traits, class Duration>
basic_istream<charT, Traits>&
operator>>(basic_istream<charT, Traits>& is,
time_point<steady_clock, Duration>& tp);
// high_resolution_clock I/O
template <class charT, class Traits, class Duration>
basic_ostream<charT, Traits>&
operator<<(basic_ostream<charT, Traits>& os,
const time_point<high_resolution_clock, Duration>& tp);
template <class charT, class Traits, class Duration>
basic_istream<charT, Traits>&
operator>>(basic_istream<charT, Traits>& is,
time_point<high_resolution_clock, Duration>& tp);
} // chrono
} // std
*/
#include <chrono>
#include <beast/chrono/ratio_io.h>
//_LIBCPP_BEGIN_NAMESPACE_STD
namespace std {
namespace chrono
{
template <class To, class Rep, class Period>
To
round(const duration<Rep, Period>& d)
{
To t0 = duration_cast<To>(d);
To t1 = t0;
++t1;
typedef typename common_type<To, duration<Rep, Period> >::type _D;
_D diff0 = d - t0;
_D diff1 = t1 - d;
if (diff0 == diff1)
{
if (t0.count() & 1)
return t1;
return t0;
}
else if (diff0 < diff1)
return t0;
return t1;
}
enum duration_style {prefix, symbol};
enum timezone {utc, local};
class durationpunct
: public locale::facet
{
private:
duration_style __style_;
public:
static locale::id id;
explicit durationpunct(size_t refs = 0)
: locale::facet(refs), __style_(prefix) {}
explicit durationpunct(duration_style fmt, size_t refs = 0)
: locale::facet(refs), __style_(fmt) {}
bool is_symbol_name() const noexcept {return __style_ == symbol;}
bool is_prefix_name() const noexcept {return __style_ == prefix;}
};
class duration_fmt
{
duration_style form_;
public:
explicit duration_fmt(duration_style f) noexcept : form_(f) {}
// VFALCO NOTE disabled this for MSVC
/*explicit*/
operator duration_style() const noexcept {return form_;}
};
template<class charT, class traits>
basic_ostream<charT, traits>&
operator <<(basic_ostream<charT, traits>& os, duration_fmt d)
{
os.imbue(locale(os.getloc(), new durationpunct(static_cast<duration_style>(d))));
return os;
}
template<class charT, class traits>
basic_istream<charT, traits>&
operator >>(basic_istream<charT, traits>& is, duration_fmt d)
{
is.imbue(locale(is.getloc(), new durationpunct(static_cast<duration_style>(d))));
return is;
}
template <class _CharT, class _Rep, class _Period>
basic_string<_CharT>
__get_unit(bool __is_long, const duration<_Rep, _Period>& d)
{
if (__is_long)
{
_CharT __p[] = {'s', 'e', 'c', 'o', 'n', 'd', 's', 0};
basic_string<_CharT> s = ratio_string<_Period, _CharT>::prefix() + __p;
if (d.count() == 1 || d.count() == -1)
s.pop_back();
return s;
}
return ratio_string<_Period, _CharT>::symbol() + 's';
}
template <class _CharT, class _Rep>
basic_string<_CharT>
__get_unit(bool __is_long, const duration<_Rep, ratio<1> >& d)
{
if (__is_long)
{
_CharT __p[] = {'s', 'e', 'c', 'o', 'n', 'd', 's'};
basic_string<_CharT> s = basic_string<_CharT>(__p, __p + sizeof(__p) / sizeof(_CharT));
if (d.count() == 1 || d.count() == -1)
s.pop_back();
return s;
}
return basic_string<_CharT>(1, 's');
}
template <class _CharT, class _Rep>
basic_string<_CharT>
__get_unit(bool __is_long, const duration<_Rep, ratio<60> >& d)
{
if (__is_long)
{
_CharT __p[] = {'m', 'i', 'n', 'u', 't', 'e', 's'};
basic_string<_CharT> s = basic_string<_CharT>(__p, __p + sizeof(__p) / sizeof(_CharT));
if (d.count() == 1 || d.count() == -1)
s.pop_back();
return s;
}
_CharT __p[] = {'m', 'i', 'n'};
return basic_string<_CharT>(__p, __p + sizeof(__p) / sizeof(_CharT));
}
template <class _CharT, class _Rep>
basic_string<_CharT>
__get_unit(bool __is_long, const duration<_Rep, ratio<3600> >& d)
{
if (__is_long)
{
_CharT __p[] = {'h', 'o', 'u', 'r', 's'};
basic_string<_CharT> s = basic_string<_CharT>(__p, __p + sizeof(__p) / sizeof(_CharT));
if (d.count() == 1 || d.count() == -1)
s.pop_back();
return s;
}
return basic_string<_CharT>(1, 'h');
}
template <class _CharT, class _Traits, class _Rep, class _Period>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const duration<_Rep, _Period>& __d)
{
typename basic_ostream<_CharT, _Traits>::sentry ok(__os);
if (ok)
{
typedef durationpunct _F;
typedef basic_string<_CharT> string_type;
bool failed = false;
try
{
bool __is_long = true;
locale __loc = __os.getloc();
if (has_facet<_F>(__loc))
{
const _F& f = use_facet<_F>(__loc);
__is_long = f.is_prefix_name();
}
string_type __unit = __get_unit<_CharT>(__is_long, __d);
__os << __d.count() << ' ' << __unit;
}
catch (...)
{
failed = true;
}
if (failed)
__os.setstate(ios_base::failbit | ios_base::badbit);
}
return __os;
}
template <class _Rep, bool = is_scalar<_Rep>::value>
struct __duration_io_intermediate
{
typedef _Rep type;
};
template <class _Rep>
struct __duration_io_intermediate<_Rep, true>
{
typedef typename conditional
<
is_floating_point<_Rep>::value,
long double,
typename conditional
<
is_signed<_Rep>::value,
long long,
unsigned long long
>::type
>::type type;
};
template <class T>
T
__gcd(T x, T y)
{
while (y != 0)
{
T old_x = x;
x = y;
y = old_x % y;
}
return x;
}
template <>
long double
inline
__gcd(long double, long double)
{
return 1;
}
template <class _CharT, class _Traits, class _Rep, class _Period>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, duration<_Rep, _Period>& __d)
{
// These are unused and generate warnings
//typedef basic_string<_CharT> string_type;
//typedef durationpunct _F;
typedef typename __duration_io_intermediate<_Rep>::type _IR;
_IR __r;
// read value into __r
__is >> __r;
if (__is.good())
{
// now determine unit
typedef istreambuf_iterator<_CharT, _Traits> _I;
_I __i(__is);
_I __e;
if (__i != __e && *__i == ' ') // mandatory ' ' after value
{
++__i;
if (__i != __e)
{
locale __loc = __is.getloc();
// unit is num / den (yet to be determined)
unsigned long long num = 0;
unsigned long long den = 0;
ios_base::iostate __err = ios_base::goodbit;
if (*__i == '[')
{
// parse [N/D]s or [N/D]seconds format
++__i;
_CharT __x;
__is >> num >> __x >> den;
if (!__is.good() || __x != '/')
{
__is.setstate(__is.failbit);
return __is;
}
__i = _I(__is);
if (*__i != ']')
{
__is.setstate(__is.failbit);
return __is;
}
++__i;
const basic_string<_CharT> __units[] =
{
__get_unit<_CharT>(true, seconds(2)),
__get_unit<_CharT>(true, seconds(1)),
__get_unit<_CharT>(false, seconds(1))
};
const basic_string<_CharT>* __k = __scan_keyword(__i, __e,
__units, __units + sizeof(__units)/sizeof(__units[0]),
use_facet<ctype<_CharT> >(__loc),
__err);
switch ((__k - __units) / 3)
{
case 0:
break;
default:
__is.setstate(__err);
return __is;
}
}
else
{
// parse SI name, short or long
const basic_string<_CharT> __units[] =
{
__get_unit<_CharT>(true, duration<_Rep, atto>(2)),
__get_unit<_CharT>(true, duration<_Rep, atto>(1)),
__get_unit<_CharT>(false, duration<_Rep, atto>(1)),
__get_unit<_CharT>(true, duration<_Rep, femto>(2)),
__get_unit<_CharT>(true, duration<_Rep, femto>(1)),
__get_unit<_CharT>(false, duration<_Rep, femto>(1)),
__get_unit<_CharT>(true, duration<_Rep, pico>(2)),
__get_unit<_CharT>(true, duration<_Rep, pico>(1)),
__get_unit<_CharT>(false, duration<_Rep, pico>(1)),
__get_unit<_CharT>(true, duration<_Rep, nano>(2)),
__get_unit<_CharT>(true, duration<_Rep, nano>(1)),
__get_unit<_CharT>(false, duration<_Rep, nano>(1)),
__get_unit<_CharT>(true, duration<_Rep, micro>(2)),
__get_unit<_CharT>(true, duration<_Rep, micro>(1)),
__get_unit<_CharT>(false, duration<_Rep, micro>(1)),
__get_unit<_CharT>(true, duration<_Rep, milli>(2)),
__get_unit<_CharT>(true, duration<_Rep, milli>(1)),
__get_unit<_CharT>(false, duration<_Rep, milli>(1)),
__get_unit<_CharT>(true, duration<_Rep, centi>(2)),
__get_unit<_CharT>(true, duration<_Rep, centi>(1)),
__get_unit<_CharT>(false, duration<_Rep, centi>(1)),
__get_unit<_CharT>(true, duration<_Rep, deci>(2)),
__get_unit<_CharT>(true, duration<_Rep, deci>(1)),
__get_unit<_CharT>(false, duration<_Rep, deci>(1)),
__get_unit<_CharT>(true, duration<_Rep, deca>(2)),
__get_unit<_CharT>(true, duration<_Rep, deca>(1)),
__get_unit<_CharT>(false, duration<_Rep, deca>(1)),
__get_unit<_CharT>(true, duration<_Rep, hecto>(2)),
__get_unit<_CharT>(true, duration<_Rep, hecto>(1)),
__get_unit<_CharT>(false, duration<_Rep, hecto>(1)),
__get_unit<_CharT>(true, duration<_Rep, kilo>(2)),
__get_unit<_CharT>(true, duration<_Rep, kilo>(1)),
__get_unit<_CharT>(false, duration<_Rep, kilo>(1)),
__get_unit<_CharT>(true, duration<_Rep, mega>(2)),
__get_unit<_CharT>(true, duration<_Rep, mega>(1)),
__get_unit<_CharT>(false, duration<_Rep, mega>(1)),
__get_unit<_CharT>(true, duration<_Rep, giga>(2)),
__get_unit<_CharT>(true, duration<_Rep, giga>(1)),
__get_unit<_CharT>(false, duration<_Rep, giga>(1)),
__get_unit<_CharT>(true, duration<_Rep, tera>(2)),
__get_unit<_CharT>(true, duration<_Rep, tera>(1)),
__get_unit<_CharT>(false, duration<_Rep, tera>(1)),
__get_unit<_CharT>(true, duration<_Rep, peta>(2)),
__get_unit<_CharT>(true, duration<_Rep, peta>(1)),
__get_unit<_CharT>(false, duration<_Rep, peta>(1)),
__get_unit<_CharT>(true, duration<_Rep, exa>(2)),
__get_unit<_CharT>(true, duration<_Rep, exa>(1)),
__get_unit<_CharT>(false, duration<_Rep, exa>(1)),
__get_unit<_CharT>(true, duration<_Rep, ratio<1> >(2)),
__get_unit<_CharT>(true, duration<_Rep, ratio<1> >(1)),
__get_unit<_CharT>(false, duration<_Rep, ratio<1> >(1)),
__get_unit<_CharT>(true, duration<_Rep, ratio<60> >(2)),
__get_unit<_CharT>(true, duration<_Rep, ratio<60> >(1)),
__get_unit<_CharT>(false, duration<_Rep, ratio<60> >(1)),
__get_unit<_CharT>(true, duration<_Rep, ratio<3600> >(2)),
__get_unit<_CharT>(true, duration<_Rep, ratio<3600> >(1)),
__get_unit<_CharT>(false, duration<_Rep, ratio<3600> >(1))
};
const basic_string<_CharT>* __k = __scan_keyword(__i, __e,
__units, __units + sizeof(__units)/sizeof(__units[0]),
use_facet<ctype<_CharT> >(__loc),
__err);
switch (__k - __units)
{
case 0:
case 1:
case 2:
num = 1ULL;
den = 1000000000000000000ULL;
break;
case 3:
case 4:
case 5:
num = 1ULL;
den = 1000000000000000ULL;
break;
case 6:
case 7:
case 8:
num = 1ULL;
den = 1000000000000ULL;
break;
case 9:
case 10:
case 11:
num = 1ULL;
den = 1000000000ULL;
break;
case 12:
case 13:
case 14:
num = 1ULL;
den = 1000000ULL;
break;
case 15:
case 16:
case 17:
num = 1ULL;
den = 1000ULL;
break;
case 18:
case 19:
case 20:
num = 1ULL;
den = 100ULL;
break;
case 21:
case 22:
case 23:
num = 1ULL;
den = 10ULL;
break;
case 24:
case 25:
case 26:
num = 10ULL;
den = 1ULL;
break;
case 27:
case 28:
case 29:
num = 100ULL;
den = 1ULL;
break;
case 30:
case 31:
case 32:
num = 1000ULL;
den = 1ULL;
break;
case 33:
case 34:
case 35:
num = 1000000ULL;
den = 1ULL;
break;
case 36:
case 37:
case 38:
num = 1000000000ULL;
den = 1ULL;
break;
case 39:
case 40:
case 41:
num = 1000000000000ULL;
den = 1ULL;
break;
case 42:
case 43:
case 44:
num = 1000000000000000ULL;
den = 1ULL;
break;
case 45:
case 46:
case 47:
num = 1000000000000000000ULL;
den = 1ULL;
break;
case 48:
case 49:
case 50:
num = 1;
den = 1;
break;
case 51:
case 52:
case 53:
num = 60;
den = 1;
break;
case 54:
case 55:
case 56:
num = 3600;
den = 1;
break;
default:
__is.setstate(__err);
return __is;
}
}
// unit is num/den
// __r should be multiplied by (num/den) / _Period
// Reduce (num/den) / _Period to lowest terms
unsigned long long __gcd_n1_n2 = __gcd<unsigned long long>(num, _Period::num);
unsigned long long __gcd_d1_d2 = __gcd<unsigned long long>(den, _Period::den);
num /= __gcd_n1_n2;
den /= __gcd_d1_d2;
unsigned long long __n2 = _Period::num / __gcd_n1_n2;
unsigned long long __d2 = _Period::den / __gcd_d1_d2;
if (num > numeric_limits<unsigned long long>::max() / __d2 ||
den > numeric_limits<unsigned long long>::max() / __n2)
{
// (num/den) / _Period overflows
__is.setstate(__is.failbit);
return __is;
}
num *= __d2;
den *= __n2;
// num / den is now factor to multiply by __r
typedef typename common_type<_IR, unsigned long long>::type _CT;
if (is_integral<_IR>::value)
{
// Reduce __r * num / den
_CT __t = __gcd<_CT>(__r, den);
__r /= __t;
den /= __t;
if (den != 1)
{
// Conversion to _Period is integral and not exact
__is.setstate(__is.failbit);
return __is;
}
}
if (__r > duration_values<_CT>::max() / num)
{
// Conversion to _Period overflowed
__is.setstate(__is.failbit);
return __is;
}
_CT __t = __r * num;
__t /= den;
if (duration_values<_Rep>::max() < __t)
{
// Conversion to _Period overflowed
__is.setstate(__is.failbit);
return __is;
}
// Success! Store it.
__r = _Rep(__t);
__d = duration<_Rep, _Period>(__r);
__is.setstate(__err);
}
else
__is.setstate(__is.failbit | __is.eofbit);
}
else
{
if (__i == __e)
__is.setstate(__is.eofbit);
__is.setstate(__is.failbit);
}
}
else
__is.setstate(__is.failbit);
return __is;
}
template <class charT>
class timepunct
: public locale::facet
{
public:
typedef basic_string<charT> string_type;
private:
string_type fmt_;
chrono::timezone tz_;
public:
static locale::id id;
explicit timepunct(size_t refs = 0)
: locale::facet(refs), tz_(utc) {}
timepunct(timezone tz, string_type fmt, size_t refs = 0)
: locale::facet(refs), fmt_(std::move(fmt)), tz_(tz) {}
const string_type& fmt() const noexcept {return fmt_;}
chrono::timezone get_timezone() const noexcept {return tz_;}
};
template <class CharT>
locale::id
timepunct<CharT>::id;
template <class _CharT, class _Traits, class _Duration>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os,
const time_point<steady_clock, _Duration>& __tp)
{
return __os << __tp.time_since_epoch() << " since boot";
}
template<class charT>
struct __time_manip
{
basic_string<charT> fmt_;
timezone tz_;
__time_manip(timezone tz, basic_string<charT> fmt)
: fmt_(std::move(fmt)),
tz_(tz) {}
};
template<class charT, class traits>
basic_ostream<charT, traits>&
operator <<(basic_ostream<charT, traits>& os, __time_manip<charT> m)
{
os.imbue(locale(os.getloc(), new timepunct<charT>(m.tz_, std::move(m.fmt_))));
return os;
}
template<class charT, class traits>
basic_istream<charT, traits>&
operator >>(basic_istream<charT, traits>& is, __time_manip<charT> m)
{
is.imbue(locale(is.getloc(), new timepunct<charT>(m.tz_, std::move(m.fmt_))));
return is;
}
template<class charT>
inline
__time_manip<charT>
time_fmt(timezone tz, const charT* fmt)
{
return __time_manip<charT>(tz, fmt);
}
template<class charT>
inline
__time_manip<charT>
time_fmt(timezone tz, basic_string<charT> fmt)
{
return __time_manip<charT>(tz, std::move(fmt));
}
class __time_man
{
timezone form_;
public:
explicit __time_man(timezone f) : form_(f) {}
// explicit
operator timezone() const {return form_;}
};
template<class charT, class traits>
basic_ostream<charT, traits>&
operator <<(basic_ostream<charT, traits>& os, __time_man m)
{
os.imbue(locale(os.getloc(), new timepunct<charT>(static_cast<timezone>(m), basic_string<charT>())));
return os;
}
template<class charT, class traits>
basic_istream<charT, traits>&
operator >>(basic_istream<charT, traits>& is, __time_man m)
{
is.imbue(locale(is.getloc(), new timepunct<charT>(static_cast<timezone>(m), basic_string<charT>())));
return is;
}
inline
__time_man
time_fmt(timezone f)
{
return __time_man(f);
}
} // chrono
}
#endif

View File

@@ -23,6 +23,7 @@
// From Howard Hinnant
// http://home.roadrunner.com/~hinnant/duration_io/chrono_util.html
#if !defined(_MSC_FULL_VER) || (_MSC_FULL_VER <= 190023506)
// round down
template <class To, class Rep, class Period>
To floor(std::chrono::duration <Rep, Period> const& d)
@@ -62,5 +63,6 @@ To ceil (std::chrono::duration <Rep, Period> const& d)
++t;
return t;
}
#endif
#endif

View File

@@ -1,41 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of Beast: https://github.com/vinniefalco/Beast
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
// chrono_io
//
// (C) Copyright Howard Hinnant
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
#include <beast/chrono/chrono_io.h>
//_LIBCPP_BEGIN_NAMESPACE_STD
namespace std {
namespace chrono
{
locale::id
durationpunct::id;
} // chrono
//_LIBCPP_END_NAMESPACE_STD
}

View File

@@ -42,9 +42,9 @@ public:
std::stringstream ss;
ss <<
"t1= " << t1.time_since_epoch() <<
", t2= " << t2.time_since_epoch() <<
", elapsed= " << (t2 - t1);
"t1= " << t1.time_since_epoch().count() <<
", t2= " << t2.time_since_epoch().count() <<
", elapsed= " << (t2 - t1).count();
log << ss.str();
}
}
@@ -56,13 +56,13 @@ public:
std::stringstream ss;
ss << "now() = " << c.now().time_since_epoch() << std::endl;
ss << "now() = " << c.now().time_since_epoch().count() << std::endl;
c.set (clock_type::time_point (std::chrono::seconds(1)));
ss << "now() = " << c.now().time_since_epoch() << std::endl;
ss << "now() = " << c.now().time_since_epoch().count() << std::endl;
c.set (clock_type::time_point (std::chrono::seconds(2)));
ss << "now() = " << c.now().time_since_epoch() << std::endl;
ss << "now() = " << c.now().time_since_epoch().count() << std::endl;
log << ss.str();
}

View File

@@ -24,7 +24,6 @@
#include <beast/hash/endian.h>
#include <beast/hash/tests/hash_metrics.h>
#include <beast/hash/hash_append.h>
#include <beast/chrono/chrono_io.h>
#include <beast/xor_shift_engine.h>
#include <beast/unit_test/suite.h>
#include <beast/utility/type_name.h>

View File

@@ -166,15 +166,15 @@ windowed_score (FwdIter first, FwdIter last)
int maxwidth = 20;
// We need at least 5 keys per bin to reliably test distribution biases
// down to 1%, so don't bother to test sparser distributions than that
while (static_cast<double>(size) / (1 << maxwidth) < 5.0)
while (static_cast<double>(size) / (1ull << maxwidth) < 5.0)
maxwidth--;
double worst = 0;
std::vector <int> bins (1 << maxwidth);
std::vector <int> bins (1ull << maxwidth);
int const hashbits = sizeof(std::size_t) * CHAR_BIT;
for (int start = 0; start < hashbits; ++start)
{
int width = maxwidth;
bins.assign (1 << width, 0);
bins.assign (1ull << width, 0);
for (auto iter (first); iter != last; ++iter)
++bins[detail::window(&*iter, start, width)];
// Test the distribution, then fold the bins in half,

View File

@@ -23,7 +23,6 @@
#include <beast/hash/fnv1a.h>
#include <beast/hash/siphash.h>
#include <beast/hash/xxhasher.h>
#include <beast/chrono/chrono_io.h>
#include <beast/rngfill.h>
#include <beast/xor_shift_engine.h>
#include <beast/unit_test/suite.h>
@@ -61,7 +60,7 @@ public:
}
auto const elapsed = clock_type::now() - start;
log << setw(12) << what << " " <<
duration<double>(elapsed) << "s";
duration<double>(elapsed).count() << "s";
}
void

View File

@@ -65,6 +65,7 @@ public:
void
notify (std::chrono::duration <Rep, Period> const& value) const
{
using namespace std::chrono;
if (m_impl)
m_impl->notify (ceil <value_type> (value));
}

View File

@@ -184,7 +184,7 @@ checkConsensus (
"checkConsensus: prop=" << currentProposers <<
"/" << previousProposers <<
" agree=" << currentAgree << " validated=" << currentFinished <<
" time=" << currentAgreeTime << "/" << previousAgreeTime;
" time=" << currentAgreeTime.count() << "/" << previousAgreeTime.count();
if (currentAgreeTime <= LEDGER_MIN_CONSENSUS)
return ConsensusState::No;

View File

@@ -272,6 +272,7 @@ private:
template <class Duration>
void operator() (Duration const& elapsed)
{
using namespace std::chrono;
auto const ms (ceil <std::chrono::milliseconds> (elapsed));
{
@@ -284,7 +285,7 @@ private:
if (ms.count() >= 500)
{
JLOG(m_journal.warning) <<
"io_service latency = " << ms;
"io_service latency = " << ms.count();
}
}

View File

@@ -23,7 +23,6 @@
#include <ripple/basics/hardened_hash.h>
#include <ripple/basics/UnorderedContainers.h>
#include <beast/chrono/abstract_clock.h>
#include <beast/chrono/chrono_io.h>
#include <beast/Insight.h>
#include <mutex>

View File

@@ -23,7 +23,6 @@
#include <ripple/basics/hardened_hash.h>
#include <ripple/basics/UnorderedContainers.h>
#include <beast/chrono/abstract_clock.h>
#include <beast/chrono/chrono_io.h>
#include <beast/Insight.h>
#include <functional>
#include <mutex>
@@ -124,7 +123,7 @@ public:
lock_guard lock (m_mutex);
m_target_age = std::chrono::seconds (s);
if (m_journal.debug) m_journal.debug <<
m_name << " target age set to " << m_target_age;
m_name << " target age set to " << m_target_age.count();
}
int getCacheSize () const
@@ -194,7 +193,7 @@ public:
if (m_journal.trace) m_journal.trace <<
m_name << " is growing fast " << m_cache.size () << " of " << m_target_size <<
" aging at " << (now - when_expire) << " of " << m_target_age;
" aging at " << (now - when_expire).count() << " of " << m_target_age.count();
}
stuffToSweep.reserve (m_cache.size ());

View File

@@ -436,6 +436,7 @@ template <class Rep, class Period>
void JobQueue::on_dequeue (JobType type,
std::chrono::duration <Rep, Period> const& value)
{
using namespace std::chrono;
auto const ms (ceil <std::chrono::milliseconds> (value));
if (ms.count() >= 10)
@@ -446,6 +447,7 @@ template <class Rep, class Period>
void JobQueue::on_execute (JobType type,
std::chrono::duration <Rep, Period> const& value)
{
using namespace std::chrono;
auto const ms (ceil <std::chrono::milliseconds> (value));
if (ms.count() >= 10)

View File

@@ -22,7 +22,6 @@
#include <ripple/basics/contract.h>
#include <ripple/nodestore/impl/codec.h>
#include <beast/chrono/basic_seconds_clock.h>
#include <beast/chrono/chrono_io.h>
#include <beast/http/rfc2616.h>
#include <beast/nudb/create.h>
#include <beast/nudb/detail/format.h>
@@ -105,7 +104,7 @@ pretty_time(std::ostream& os, std::chrono::duration<Rep, Period> d)
else
{
// use integral
os << std::chrono::round<nanoseconds>(d).count();
os << round<nanoseconds>(d).count();
}
os << "ns";
}
@@ -121,7 +120,7 @@ pretty_time(std::ostream& os, std::chrono::duration<Rep, Period> d)
else
{
// use integral
os << std::chrono::round<microseconds>(d).count();
os << round<microseconds>(d).count();
}
os << "us";
}
@@ -137,7 +136,7 @@ pretty_time(std::ostream& os, std::chrono::duration<Rep, Period> d)
else
{
// use integral
os << std::chrono::round<milliseconds>(d).count();
os << round<milliseconds>(d).count();
}
os << "ms";
}
@@ -153,7 +152,7 @@ pretty_time(std::ostream& os, std::chrono::duration<Rep, Period> d)
else
{
// use integral
os << std::chrono::round<seconds>(d).count();
os << round<seconds>(d).count();
}
os << "s";
}
@@ -169,7 +168,7 @@ pretty_time(std::ostream& os, std::chrono::duration<Rep, Period> d)
else
{
// use integral
os << std::chrono::round<minutes>(d).count();
os << round<minutes>(d).count();
}
os << "min";
}

View File

@@ -23,7 +23,6 @@
#include <ripple/peerfinder/PeerfinderManager.h>
#include <ripple/peerfinder/impl/iosformat.h>
#include <ripple/peerfinder/impl/Tuning.h>
#include <beast/chrono/chrono_io.h>
#include <beast/container/aged_map.h>
#include <beast/utility/maybe_const.h>
#include <boost/intrusive/list.hpp>
@@ -477,7 +476,7 @@ Livecache <Allocator>::onWrite (beast::PropertyStream::Map& map)
item ["hops"] = e.endpoint.hops;
item ["address"] = e.endpoint.address.to_string ();
std::stringstream ss;
ss << iter.when() - expired;
ss << (iter.when() - expired).count();
item ["expires"] = ss.str();
}
}

View File

@@ -19,7 +19,6 @@
#include <BeastConfig.h>
#include <ripple/protocol/digest.h>
#include <beast/chrono/chrono_io.h>
#include <beast/rngfill.h>
#include <beast/xor_shift_engine.h>
#include <beast/unit_test/suite.h>

View File

@@ -21,7 +21,6 @@
#include <ripple/basics/chrono.h>
#include <ripple/basics/random.h>
#include <beast/unit_test/suite.h>
#include <beast/chrono/chrono_io.h>
#include <boost/utility/base_from_member.hpp>
namespace ripple {
@@ -214,7 +213,7 @@ public:
for (int i = 0; i < 128; ++i)
{
j.info <<
"Time= " << logic.clock().now().time_since_epoch() <<
"Time= " << logic.clock().now().time_since_epoch().count() <<
", Balance = " << c.balance();
logic.advance();
}
@@ -230,7 +229,7 @@ public:
{
c.charge (fee);
j.info <<
"Time= " << logic.clock().now().time_since_epoch() <<
"Time= " << logic.clock().now().time_since_epoch().count() <<
", Balance = " << c.balance();
logic.advance();
}

View File

@@ -21,7 +21,6 @@
#include <ripple/basics/contract.h>
#include <ripple/server/impl/ServerImpl.h>
#include <ripple/server/impl/BaseHTTPPeer.h>
#include <beast/chrono/chrono_io.h>
#include <boost/chrono/chrono_io.hpp>
#include <boost/utility/in_place_factory.hpp>
#include <cassert>