Modify

Opened 5 years ago

Closed 5 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 5 years ago.
7042.2.patch (1.6 KB) - added by viboes 5 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago by 1czajnik@…

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.

Changed 5 years ago by viboes

Attachment: 7042.patch added

comment:2 Changed 5 years ago by viboes

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

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

Changed 5 years ago by viboes

Attachment: 7042.2.patch added

comment:3 Changed 5 years ago by 1czajnik@…

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

Cheers, Kris

comment:4 Changed 5 years ago by viboes

Milestone: To Be DeterminedBoost 1.51.0
Status: newassigned

comment:5 Changed 5 years ago by viboes

Resolution: fixed
Status: assignedclosed

Committed revision 79371.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.