[LTP] [PATCH v2] clock_settime: use POSIX runtime detection for CLOCK_MONOTONIC
Petr Vorel
pvorel@suse.cz
Wed Apr 29 09:53:47 CEST 2026
Hi Andrea,
> +#include <unistd.h>
> +#include "clock.h"
> static int getBeforeTime(struct timespec *tpget)
> {
> @@ -37,53 +42,53 @@ static int setBackTime(struct timespec tpset)
> #define PTS_MONO_MAX_RETRIES 3
> -#ifdef _POSIX_MONOTONIC_CLOCK
> -static struct timespec _pts_mono_start;
> +static struct timespec pts_mono_start;
> static inline int pts_mono_time_start(void)
> {
> - if (clock_gettime(CLOCK_MONOTONIC, &_pts_mono_start) != 0) {
> + if (!pts_mono_available()) {
> + static int warned;
> +
> + if (!warned) {
> + printf("CLOCK_MONOTONIC unavailable, test may fail due to clock adjustment\n");
> + warned = 1;
> + }
Function with this warning could be in include/clock.h as well, because that
will be needed for nanosleep tests. But you can postpone it to nanosleep
changes.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> + return 0;
> + }
...
More information about the ltp
mailing list