All errors that can be reported by Linux clock_gettime are not possible in the debugged implementation of std::chrono::steady_clock::now() .
Errors:
int clock_gettime(clockid_t clk_id, struct timespec *tp); EFAULT
tp points out of the available address space.
In std::chrono::steady_clock::now() no user tp that is not provided to the user. If std::chrono::steady_clock::now() passes the wrong tp to clock_gettime , this is just a steady_clock error that is easily fixed.
EINVAL
The specified clk_id is not supported on this system.
In std::chrono::steady_clock::now() no user clk_id . If std::chrono::steady_clock::now() passes the wrong clk_id to clock_gettime , this is just a steady_clock error that needs to be fixed.
Please note that the steady_clock implementation steady_clock not guaranteed to be portable and can be ported to any given platform and checked for correctness. It may turn out that steady_clock cannot be implemented in terms of clock_gettime on some platforms.
EPERM
clock_settime () is not allowed to set the specified hours.
Not applicable to steady_clock since there is no API to set the time.
source share