Opened 10 years ago

Closed 10 years ago

#7042 closed Feature Requests (fixed)

Avoiding time_point and duration dependency on time.h and CLOCK_REALTIME

Reported by: 1czajnik@… Owned by: viboes
Milestone: Boost 1.51.0 Component: chrono
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

Hello,

The file chrono/config.hpp enforces that time.h defines CLOCK_REALTIME:

# if defined( BOOST_CHRONO_POSIX_API )
#   define BOOST_CHRONO_HAS_PROCESS_CLOCKS
#   include <time.h>  //to check for CLOCK_REALTIME and CLOCK_MONOTONIC and _POSIX_THREAD_CPUTIME
#   if defined(CLOCK_REALTIME)
#     if defined(CLOCK_MONOTONIC)
#        define BOOST_CHRONO_HAS_CLOCK_STEADY
#     endif
#   else
#     error <time.h> does not supply CLOCK_REALTIME
#   endif
...
# endif

It seems that files: chrono/duration.hpp and chrono/time_point.hpp don't need to depend on <time.h> or CLOCK_REALTIME. If a compiler provides a <time.h>, which doesn't define CLOCK_REALTIME, or even doesn't provide <time.h>, it would be nice to still be able to use chrono/duration.hpp or chrono/time_point.hpp.

Regards, Kris

Attachments (2)

7042.patch (1.4 KB ) - added by viboes 10 years ago.
7042.2.patch (1.6 KB ) - added by viboes 10 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by 1czajnik@…, 10 years ago

As a workaround, I was able to use time_point.hpp and duration.hpp by defining CLOCK_REALTIME in my project. Of course, I am not using any clocks provided by Chrono.

by viboes, 10 years ago

Attachment: 7042.patch added

comment:2 by viboes, 10 years ago

Please, could you tell me if the attached patch 7042.2.patch solves the issue with CLOCK_REALTIME?

Last edited 10 years ago by viboes (previous) (diff)

by viboes, 10 years ago

Attachment: 7042.2.patch added

comment:3 by 1czajnik@…, 10 years ago

Yes, I confirm, patch 7042.2.patch solves the issue with CLOCK_REALTIME.

Cheers, Kris

comment:4 by viboes, 10 years ago

Milestone: To Be DeterminedBoost 1.51.0
Status: newassigned

comment:5 by viboes, 10 years ago

Resolution: fixed
Status: assignedclosed

Committed revision 79371.

Note: See TracTickets for help on using tickets.