On Sun, Nov 20, 2022 at 2:32 AM Rich Felker wrote: > > On Sat, Nov 19, 2022 at 04:46:22AM +0800, 罗勇刚(Yonggang Luo) wrote: > > There is a concept called CLOCK_MONOTONIC_RAW (since Linux 2.6.28; > > Linux-specific), > > May C2x provide TIME_MONOTONIC_RAW in future or can we just implement > > TIME_MONOTONIC with > > CLOCK_MONOTONIC_RAW on Linux? When implement mesa vulkan driver, it's ask > > for CLOCK_MONOTONIC_RAW at > > > > https://gitlab.freedesktop.org/mesa/mesa/-/blob/c6c5949ff70a47c47795fe9161a7514173b5be24/src/vulkan/runtime/vk_device.c#L557 > > > > May intention is using C2x timespec_get to replace function > > vk_clock_gettime but it's lack of TIME_MONOTONIC_RAW, so I don't know > > what's the best way > > The code there is already doing exactly what it should do in the case > where CLOCK_MONOTONIC_RAW is not defined so I'm not sure what you're > trying to achieve. > > On a system where CLOCK_MONOTONIC_RAW is defined, the caller may have > (for likely-nonsensical reasons) chosen to pass CLOCK_MONOTONIC_RAW, > and they're handling the case where the kernel is too old to have that > extension clock by substituting CLOCK_MONOTONIC instead. That's the issue, when you access `CLOCK_MONOTONIC_RAW`, it's have to be defined, suppose we have standardized TIME_MONOTONIC_RAW, then we have no need get the time with, ``` #ifndef CLOCK_MONOTONIC_RAW // The code #endif ``` but with ``` if (timespec_get(ts, TIME_MONOTONIC_RAW) != 0) { } ``` > > If CLOCK_MONOTONIC_RAW is not defined, then most certainly the caller > did not pass it (since there's no such thing) and thus there is no > need for any fallback code. > > No action is needed at all here. > > Rich -- 此致 礼 罗勇刚 Yours sincerely, Yonggang Luo