Opened 11 years ago

Closed 11 years ago

#5543 closed Bugs (fixed)

Thread clock compatibility problems on Android

Reported by: Libor Bus <libor.bus@…> Owned by: viboes
Milestone: Boost 1.47.0 Component: chrono
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

There are compatibility problems of chrono library on Android (Android 2.2, NDK-r5b, chrono v0.71, rev #71693):

1) Sources with boost::chrono::thread_clock does not compile, since _POSIX_THREAD_CPUTIME is not defined on Android. My workaround is to hack chrono/config.hpp: # if 1 defined(_POSIX_THREAD_CPUTIME) # define BOOST_CHRONO_HAS_THREAD_CLOCK # define BOOST_CHRONO_THREAD_CLOCK_IS_MONOTONIC true # endif

2) ::clock_gettime() fails when called with clock ID got from pthread_getcpuclockid. My workaround is to call ::clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ) in chrono/detail/inlined/posix/thread_clock.hpp.

Change History (3)

comment:2 by Peter Schueller <ps@…>, 11 years ago

did this perhaps break something in the trunk?

Starting sometime after revision 71950 I can no longer build the trunk, I get

    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -fPIC -Wextra -Wno-long-long -pedantic -DBOOST_ALL_DYN_LINK=1 -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_NO_DEPRECATED -DNDEBUG  -I"." -c -o "bin.v2/libs/chrono/build/gcc-4.4.5/release/threading-multi/thread_clock.o" "libs/chrono/src/thread_clock.cpp"

In file included from ./boost/chrono/detail/inlined/thread_clock.hpp:39,
                 from libs/chrono/src/thread_clock.cpp:18:
./boost/chrono/detail/inlined/posix/thread_clock.hpp: In static member function ‘static boost::chrono::time_point<boost::chrono::thread_clock, boost::chrono::duration<long int, boost::ratio<1l, 1000000000l> > > boost::chrono::thread_clock::now()’:
./boost/chrono/detail/inlined/posix/thread_clock.hpp:26: error: ‘ts’ was not declared in this scope
./boost/chrono/detail/inlined/posix/thread_clock.hpp:47: error: ‘ts’ was not declared in this scope
./boost/chrono/detail/inlined/posix/thread_clock.hpp: In static member function ‘static boost::chrono::time_point<boost::chrono::thread_clock, boost::chrono::duration<long int, boost::ratio<1l, 1000000000l> > > boost::chrono::thread_clock::now(boost::system::error_code&)’:
./boost/chrono/detail/inlined/posix/thread_clock.hpp:54: error: ‘ts’ was not declared in this scope
./boost/chrono/detail/inlined/posix/thread_clock.hpp:86: error: ‘ts’ was not declared in this scope

comment:3 by viboes, 11 years ago

Milestone: To Be DeterminedBoost 1.47.0
Resolution: fixed
Status: newclosed

Solution merged to release branch: Committed revision 72239.

Note: See TracTickets for help on using tickets.