Skip to content

Commit aa51cbd

Browse files
committed
Merge branch 'develop'
2 parents 5df1249 + fd5174a commit aa51cbd

File tree

6 files changed

+98
-46
lines changed

6 files changed

+98
-46
lines changed

CMakeLists.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2019 Mike Dev
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
4+
#
5+
# NOTE: CMake support for Boost.Chrono is currently experimental at best
6+
# and the interface is likely to change in the future
7+
8+
cmake_minimum_required( VERSION 3.5 )
9+
project( BoostChrono LANGUAGES CXX)
10+
11+
add_library( boost_chrono
12+
src/chrono.cpp
13+
src/process_cpu_clocks.cpp
14+
src/thread_clock.cpp
15+
)
16+
add_library( Boost::chrono ALIAS boost_chrono )
17+
18+
target_include_directories( boost_chrono PUBLIC include )
19+
target_compile_definitions( boost_chrono
20+
PUBLIC
21+
# NOTE:
22+
# We deactivate autolinking because cmake based builds don't need it
23+
# and we don't implement name mangling for the library file anyway.
24+
# Ususally the parent CMakeLists.txt file should already have globally defined BOOST_ALL_NO_LIB
25+
BOOST_CHRONO_NO_LIB
26+
$<$<STREQUAL:$<TARGET_PROPERTY:boost_chrono,TYPE>,SHARED_LIBRARY>:BOOST_CHRONO_DYN_LINK=1>
27+
$<$<STREQUAL:$<TARGET_PROPERTY:boost_chrono,TYPE>,STATIC_LIBRARY>:BOOST_CHRONO_STATIC_LINK=1>
28+
)
29+
30+
target_link_libraries( boost_chrono
31+
PUBLIC
32+
Boost::assert
33+
Boost::config
34+
Boost::core
35+
Boost::integer
36+
Boost::move
37+
Boost::mpl
38+
Boost::predef
39+
Boost::ratio
40+
Boost::static_assert
41+
Boost::system
42+
Boost::throw_exception
43+
Boost::type_traits
44+
Boost::typeof
45+
Boost::utility
46+
PRIVATE
47+
$<$<STREQUAL:Windows,$<PLATFORM_ID>>:Boost::winapi>
48+
)

appveyor.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ branches:
1414

1515
environment:
1616
matrix:
17-
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
17+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
1818
TOOLSET: msvc-12.0
1919
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
2020
TOOLSET: msvc-14.0
2121
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
2222
TOOLSET: msvc-14.1
23+
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
24+
TOOLSET: msvc-14.2
2325

2426
install:
2527
- set BOOST_BRANCH=develop
@@ -38,4 +40,4 @@ install:
3840
build: off
3941

4042
test_script:
41-
- b2 -j3 libs/chrono/test toolset=%TOOLSET%
43+
- b2 -j3 libs/chrono/test toolset=%TOOLSET% address-model=32,64 variant=debug,release

example/xtime.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,47 +47,48 @@ round_up(duration<Rep, Period> d)
4747

4848
// demonstrate interaction with xtime-like facility:
4949

50-
struct xtime
50+
// msvc defines ::xtime in <mutex>, so we use xtime_
51+
struct xtime_
5152
{
5253
long sec;
5354
unsigned long usec;
5455
};
5556

5657
template <class Rep, class Period>
57-
xtime
58+
xtime_
5859
to_xtime_truncate(duration<Rep, Period> d)
5960
{
60-
xtime xt;
61+
xtime_ xt;
6162
xt.sec = static_cast<long>(duration_cast<seconds>(d).count());
6263
xt.usec = static_cast<long>(duration_cast<microseconds>(d - seconds(xt.sec)).count());
6364
return xt;
6465
}
6566

6667
template <class Rep, class Period>
67-
xtime
68+
xtime_
6869
to_xtime_round_up(duration<Rep, Period> d)
6970
{
70-
xtime xt;
71+
xtime_ xt;
7172
xt.sec = static_cast<long>(duration_cast<seconds>(d).count());
7273
xt.usec = static_cast<unsigned long>(round_up<microseconds>(d - seconds(xt.sec)).count());
7374
return xt;
7475
}
7576

7677
microseconds
77-
from_xtime(xtime xt)
78+
from_xtime(xtime_ xt)
7879
{
7980
return seconds(xt.sec) + microseconds(xt.usec);
8081
}
8182

82-
void print(xtime xt)
83+
void print(xtime_ xt)
8384
{
8485
std::cout << '{' << xt.sec << ',' << xt.usec << "}\n";
8586
}
8687

8788
void test_with_xtime()
8889
{
8990
std::cout << "test_with_xtime\n";
90-
xtime xt = to_xtime_truncate(seconds(3) + milliseconds(251));
91+
xtime_ xt = to_xtime_truncate(seconds(3) + milliseconds(251));
9192
print(xt);
9293
milliseconds ms = duration_cast<milliseconds>(from_xtime(xt));
9394
std::cout << ms.count() << " milliseconds\n";

include/boost/chrono/detail/inlined/win/chrono.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <boost/winapi/time.hpp>
1616
#include <boost/winapi/timers.hpp>
1717
#include <boost/winapi/get_last_error.hpp>
18+
#include <boost/winapi/error_codes.hpp>
1819
#include <boost/assert.hpp>
1920

2021
namespace boost
@@ -70,7 +71,7 @@ namespace chrono_detail
7071
{
7172
boost::winapi::DWORD_ cause =
7273
((nanosecs_per_tic <= 0.0L)
73-
? ERROR_NOT_SUPPORTED
74+
? boost::winapi::ERROR_NOT_SUPPORTED_
7475
: boost::winapi::GetLastError());
7576
if (::boost::chrono::is_throws(ec)) {
7677
boost::throw_exception(

include/boost/chrono/detail/inlined/win/process_cpu_clocks.hpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
#include <time.h>
2020
#include <boost/assert.hpp>
2121

22-
#include <boost/detail/winapi/get_last_error.hpp>
23-
#include <boost/detail/winapi/get_current_process.hpp>
22+
#include <boost/winapi/get_last_error.hpp>
23+
#include <boost/winapi/get_current_process.hpp>
2424
#if BOOST_PLAT_WINDOWS_DESKTOP
25-
#include <boost/detail/winapi/get_process_times.hpp>
25+
#include <boost/winapi/get_process_times.hpp>
2626
#endif
2727

2828
namespace boost
@@ -72,10 +72,10 @@ process_user_cpu_clock::time_point process_user_cpu_clock::now() BOOST_NOEXCEPT
7272
{
7373

7474
// note that Windows uses 100 nanosecond ticks for FILETIME
75-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
75+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
7676

77-
if ( boost::detail::winapi::GetProcessTimes(
78-
boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
77+
if ( boost::winapi::GetProcessTimes(
78+
boost::winapi::GetCurrentProcess(), &creation, &exit,
7979
&system_time, &user_time ) )
8080
{
8181
return time_point(duration(
@@ -97,10 +97,10 @@ process_user_cpu_clock::time_point process_user_cpu_clock::now(
9797
{
9898

9999
// note that Windows uses 100 nanosecond ticks for FILETIME
100-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
100+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
101101

102-
if ( boost::detail::winapi::GetProcessTimes(
103-
boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
102+
if ( boost::winapi::GetProcessTimes(
103+
boost::winapi::GetCurrentProcess(), &creation, &exit,
104104
&system_time, &user_time ) )
105105
{
106106
if (!::boost::chrono::is_throws(ec))
@@ -114,7 +114,7 @@ process_user_cpu_clock::time_point process_user_cpu_clock::now(
114114
}
115115
else
116116
{
117-
boost::detail::winapi::DWORD_ cause = boost::detail::winapi::GetLastError();
117+
boost::winapi::DWORD_ cause = boost::winapi::GetLastError();
118118
if (::boost::chrono::is_throws(ec))
119119
{
120120
boost::throw_exception(
@@ -137,10 +137,10 @@ process_system_cpu_clock::time_point process_system_cpu_clock::now() BOOST_NOEXC
137137
{
138138

139139
// note that Windows uses 100 nanosecond ticks for FILETIME
140-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
140+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
141141

142-
if ( boost::detail::winapi::GetProcessTimes(
143-
boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
142+
if ( boost::winapi::GetProcessTimes(
143+
boost::winapi::GetCurrentProcess(), &creation, &exit,
144144
&system_time, &user_time ) )
145145
{
146146
return time_point(duration(
@@ -162,10 +162,10 @@ process_system_cpu_clock::time_point process_system_cpu_clock::now(
162162
{
163163

164164
// note that Windows uses 100 nanosecond ticks for FILETIME
165-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
165+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
166166

167-
if ( boost::detail::winapi::GetProcessTimes(
168-
boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
167+
if ( boost::winapi::GetProcessTimes(
168+
boost::winapi::GetCurrentProcess(), &creation, &exit,
169169
&system_time, &user_time ) )
170170
{
171171
if (!::boost::chrono::is_throws(ec))
@@ -179,7 +179,7 @@ process_system_cpu_clock::time_point process_system_cpu_clock::now(
179179
}
180180
else
181181
{
182-
boost::detail::winapi::DWORD_ cause = boost::detail::winapi::GetLastError();
182+
boost::winapi::DWORD_ cause = boost::winapi::GetLastError();
183183
if (::boost::chrono::is_throws(ec))
184184
{
185185
boost::throw_exception(
@@ -202,10 +202,10 @@ process_cpu_clock::time_point process_cpu_clock::now() BOOST_NOEXCEPT
202202
{
203203

204204
// note that Windows uses 100 nanosecond ticks for FILETIME
205-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
205+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
206206

207-
if ( boost::detail::winapi::GetProcessTimes(
208-
boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
207+
if ( boost::winapi::GetProcessTimes(
208+
boost::winapi::GetCurrentProcess(), &creation, &exit,
209209
&system_time, &user_time ) )
210210
{
211211
time_point::rep r(process_real_cpu_clock::now().time_since_epoch().count()
@@ -233,10 +233,10 @@ process_cpu_clock::time_point process_cpu_clock::now(
233233
{
234234

235235
// note that Windows uses 100 nanosecond ticks for FILETIME
236-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
236+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
237237

238-
if ( boost::detail::winapi::GetProcessTimes(
239-
boost::detail::winapi::GetCurrentProcess(), &creation, &exit,
238+
if ( boost::winapi::GetProcessTimes(
239+
boost::winapi::GetCurrentProcess(), &creation, &exit,
240240
&system_time, &user_time ) )
241241
{
242242
if (!::boost::chrono::is_throws(ec))
@@ -256,7 +256,7 @@ process_cpu_clock::time_point process_cpu_clock::now(
256256
}
257257
else
258258
{
259-
boost::detail::winapi::DWORD_ cause = boost::detail::winapi::GetLastError();
259+
boost::winapi::DWORD_ cause = boost::winapi::GetLastError();
260260
if (::boost::chrono::is_throws(ec))
261261
{
262262
boost::throw_exception(

include/boost/chrono/detail/inlined/win/thread_clock.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include <cassert>
1717
#include <boost/assert.hpp>
1818

19-
#include <boost/detail/winapi/get_last_error.hpp>
20-
#include <boost/detail/winapi/get_current_thread.hpp>
21-
#include <boost/detail/winapi/get_thread_times.hpp>
19+
#include <boost/winapi/get_last_error.hpp>
20+
#include <boost/winapi/get_current_thread.hpp>
21+
#include <boost/winapi/get_thread_times.hpp>
2222

2323
namespace boost
2424
{
@@ -29,10 +29,10 @@ namespace chrono
2929
thread_clock::time_point thread_clock::now( system::error_code & ec )
3030
{
3131
// note that Windows uses 100 nanosecond ticks for FILETIME
32-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
32+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
3333

34-
if ( boost::detail::winapi::GetThreadTimes(
35-
boost::detail::winapi::GetCurrentThread (), &creation, &exit,
34+
if ( boost::winapi::GetThreadTimes(
35+
boost::winapi::GetCurrentThread (), &creation, &exit,
3636
&system_time, &user_time ) )
3737
{
3838
duration user = duration(
@@ -56,13 +56,13 @@ thread_clock::time_point thread_clock::now( system::error_code & ec )
5656
{
5757
boost::throw_exception(
5858
system::system_error(
59-
boost::detail::winapi::GetLastError(),
59+
boost::winapi::GetLastError(),
6060
::boost::system::system_category(),
6161
"chrono::thread_clock" ));
6262
}
6363
else
6464
{
65-
ec.assign( boost::detail::winapi::GetLastError(), ::boost::system::system_category() );
65+
ec.assign( boost::winapi::GetLastError(), ::boost::system::system_category() );
6666
return thread_clock::time_point(duration(0));
6767
}
6868
}
@@ -73,10 +73,10 @@ thread_clock::time_point thread_clock::now() BOOST_NOEXCEPT
7373
{
7474

7575
// note that Windows uses 100 nanosecond ticks for FILETIME
76-
boost::detail::winapi::FILETIME_ creation, exit, user_time, system_time;
76+
boost::winapi::FILETIME_ creation, exit, user_time, system_time;
7777

78-
if ( boost::detail::winapi::GetThreadTimes(
79-
boost::detail::winapi::GetCurrentThread (), &creation, &exit,
78+
if ( boost::winapi::GetThreadTimes(
79+
boost::winapi::GetCurrentThread (), &creation, &exit,
8080
&system_time, &user_time ) )
8181
{
8282
duration user = duration(

0 commit comments

Comments
 (0)