C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Obtaining the low-level clock used by std::chrono::steady_clock

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 20 Apr 2023 08:10:32 -0700
On Thursday, 20 April 2023 04:49:51 PDT Jonathan Wakely via Std-Proposals
wrote:
> But even that isn't always used, and the decision of whether to use it
> might depend on the version of the std::lib that you dynamically link to at
> runtime:
> https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/src/c%2B%2B11/c
> hrono.cc;h=8f869df5696473ebd0157e9edb4875af8c1381ce;hb=HEAD#l50
>
> A compile-time constant in the headers cannot accurately represent that
> behaviour.

Strictly speaking, it *can* represent the behaviour of the link above, so long
as libstdc++ decides that the clock source is ABI. The constant can be added
to bits/c++config.h, which is a compile-time generated header. So long as the
operating system itself doesn't regress, all new builds should have the same
macros defined.

We'll see when the discussion on CLOCK_MONOTONIC_RAW concludes whether it is
right to be ABI. Right now, there may be code that depends on steady_clock
being CLOCK_MONOTONIC; making a change could result in subtly broken code
because of the micro- to millisecond-wide difference between the two clocks.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-04-20 15:10:34