Boost logo

Boost :

Subject: Re: [boost] [chrono] Thread clock compatibility problems on Android
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-05-14 03:34:57


Libor Bus wrote:
>
> Hello Vicente,
> thanks for the fast answer and your great library!
>
> You can rely on #if defined ANDROID.
>
>

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?

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

// 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

Best,
Vicente
Best,
Vicente

--
View this message in context: http://boost.2283326.n4.nabble.com/chrono-Thread-clock-compatibility-problems-on-Android-tp3520310p3521896.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk