
Libor Bus wrote:
Vicente Botet wrote:
Is CLOCK_THREAD_CPUTIME_ID a macro on this platform? I would prefer to check if CLOCK_THREAD_CPUTIME_ID is defined and use it. Would it be the correct behavior?
Yes, is defined like: #define CLOCK_THREAD_CPUTIME_ID 3 in time.h.
Great. I will use this macro then, which seems to be more general.
Vicente Botet wrote:
could you try this patch
// chrono/config.hpp
# if defined(_POSIX_THREAD_CPUTIME) && !defined(BOOST_DISABLE_THREADS) # define BOOST_CHRONO_HAS_THREAD_CLOCK # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true # endif # if defined(CLOCK_THREAD_CPUTIME_ID) && !defined(BOOST_DISABLE_THREADS) # define BOOST_CHRONO_HAS_THREAD_CLOCK # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true # endif
This causes compilation error because BOOST_CHRONO_THREAD_CLOCK_IS_MONOTONIC is undefined in chrono/thread_clock.hpp: BOOST_CHRONO_STATIC_CONSTEXPR bool is_monotonic = BOOST_CHRONO_THREAD_CLOCK_IS_MONOTONIC;
However following patch works for me: # if defined(_POSIX_THREAD_CPUTIME) && !defined(BOOST_DISABLE_THREADS) # define BOOST_CHRONO_HAS_THREAD_CLOCK # define BOOST_CHRONO_THREAD_CLOCK_IS_MONOTONIC true # endif # if defined(CLOCK_THREAD_CPUTIME_ID) && !defined(BOOST_DISABLE_THREADS) # define BOOST_CHRONO_HAS_THREAD_CLOCK # define BOOST_CHRONO_THREAD_CLOCK_IS_MONOTONIC true # endif I'm not sure about BOOST_DISABLE_THREADS.
Oh, I see. You are not using the lib in the trunk which has replaced monotonic clocks by steady clocks.
Vicente Botet wrote:
// posix/thread_clock.hpp ... #if defined CLOCK_THREAD_CPUTIME_ID 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
On Android works fine for me.
I have committed it on trunk. I will see how this behaves on the regression compilers before moving it to the release branch. I would appreciate if you create a ticket on the Trac system. Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/chrono-Thread-clock-compatibility-problem... Sent from the Boost - Dev mailing list archive at Nabble.com.