Enabling boost::date_time::posix_time::nanosec().
Hi. Is there a quick way to determine whether one's operating system supports the nanosecond precision clock? Also; I realise that BOOST_DATE_TIME_HAS_NANOSECONDS needs to be defined to use nanosec() method. But; should I be able (if my operating system supports it) to define support for nanosecond time resolution at installation time? I.e. would it suffice to use a bjam commandline parameter defining nanosecond support when building the Boost date_time libraries? Also; how do I configure nanosecond support for subsequent compilation of programs which use Boost and require nanosecond posix_time resolution? Greetings, Andre. [Non-text portions of this message have been removed]
Is there a quick way to determine whether one's operating system supports the nanosecond precision clock?
Most platforms only support microsecond resolution in the clock classes that measure the time. However, all the platforms can represent nanoseconds in the time representation. This separation of the precision of the representation from the precision of what the clock can produce on a given platform was one of the key design goals of the library. If you can find hardware to produce nano-second clock signals it is trivial to plug in.
Also; I realise that BOOST_DATE_TIME_HAS_NANOSECONDS needs to be defined to use nanosec() method. But; should I be able (if my operating system supports it) to define support for nanosecond time resolution at installation time? I.e.
This isn't really needed (see below).
would it suffice to use a bjam commandline parameter defining nanosecond support when building the Boost date_time libraries?
There is: BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG. Clients that set this macro definition during compilation will be able to access nano-seconds at the cost of increasing the posix_time::ptime to use 96 bits of space (instead of 64 bits). The library tests are normally compiled with this on. As for the library compilation itself, it turns out that it is built to support either configuration without changes.
Also; how do I configure nanosecond support for subsequent compilation of programs which use Boost and require nanosecond posix_time resolution?
Yes, set BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG. The jamfile under libs/date_time/test/ gives an example. Jeff
participants (2)
-
adutoit
-
Jeff Garland