summaryrefslogtreecommitdiff
path: root/boost/interprocess/detail/os_thread_functions.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/interprocess/detail/os_thread_functions.hpp')
-rw-r--r--boost/interprocess/detail/os_thread_functions.hpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/boost/interprocess/detail/os_thread_functions.hpp b/boost/interprocess/detail/os_thread_functions.hpp
index 3ff0a402ba..8a0a47cc27 100644
--- a/boost/interprocess/detail/os_thread_functions.hpp
+++ b/boost/interprocess/detail/os_thread_functions.hpp
@@ -53,7 +53,12 @@
# include <sys/sysctl.h>
# endif
//According to the article "C/C++ tip: How to measure elapsed real time for benchmarking"
-# if defined(CLOCK_MONOTONIC_PRECISE) //BSD
+//Check MacOs first as macOS 10.12 SDK defines both CLOCK_MONOTONIC and
+//CLOCK_MONOTONIC_RAW and no clock_gettime.
+# if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
+# include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t
+# define BOOST_INTERPROCESS_MATCH_ABSOLUTE_TIME
+# elif defined(CLOCK_MONOTONIC_PRECISE) //BSD
# define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_MONOTONIC_PRECISE
# elif defined(CLOCK_MONOTONIC_RAW) //Linux
# define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW
@@ -61,9 +66,6 @@
# define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_HIGHRES
# elif defined(CLOCK_MONOTONIC) //POSIX (AIX, BSD, Linux, Solaris)
# define BOOST_INTERPROCESS_CLOCK_MONOTONIC CLOCK_MONOTONIC
-# elif !defined(CLOCK_MONOTONIC) && (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
-# include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t
-# define BOOST_INTERPROCESS_MATCH_ABSOLUTE_TIME
# else
# error "No high resolution steady clock in your system, please provide a patch"
# endif
@@ -112,8 +114,8 @@ inline bool equal_thread_id(OS_thread_id_t id1, OS_thread_id_t id2)
//return the system tick in ns
inline unsigned long get_system_tick_ns()
{
- unsigned long curres;
- winapi::set_timer_resolution(10000, 0, &curres);
+ unsigned long curres, ignore1, ignore2;
+ winapi::query_timer_resolution(&ignore1, &ignore2, &curres);
//Windows API returns the value in hundreds of ns
return (curres - 1ul)*100ul;
}
@@ -121,8 +123,8 @@ inline unsigned long get_system_tick_ns()
//return the system tick in us
inline unsigned long get_system_tick_us()
{
- unsigned long curres;
- winapi::set_timer_resolution(10000, 0, &curres);
+ unsigned long curres, ignore1, ignore2;
+ winapi::query_timer_resolution(&ignore1, &ignore2, &curres);
//Windows API returns the value in hundreds of ns
return (curres - 1ul)/10ul + 1ul;
}
@@ -132,8 +134,8 @@ typedef unsigned __int64 OS_highres_count_t;
inline unsigned long get_system_tick_in_highres_counts()
{
__int64 freq;
- unsigned long curres;
- winapi::set_timer_resolution(10000, 0, &curres);
+ unsigned long curres, ignore1, ignore2;
+ winapi::query_timer_resolution(&ignore1, &ignore2, &curres);
//Frequency in counts per second
if(!winapi::query_performance_frequency(&freq)){
//Tick resolution in ms