[LTP] nanosleep: use POSIX runtime detection for CLOCK_MONOTONIC

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Mon May 4 16:05:05 CEST 2026


Hi Andrea,

On Mon, 4 May 2026 15:20:18 +0200, Andrea Cervesato wrote:
> nanosleep: use POSIX runtime detection for CLOCK_MONOTONIC

> +static inline clockid_t pts_get_clock(void)
> +{
> +	if (pts_mono_available())
> +		return CLOCK_MONOTONIC;
> +
> +	printf("CLOCK_MONOTONIC unavailable, test may fail due to clock adjustment\n");
> +	return CLOCK_REALTIME;
> +}

Clean fix. Centralising the runtime detection into pts_get_clock() is the
right approach and correctly handles the Linux/glibc case where
_POSIX_MONOTONIC_CLOCK == 0 requires a sysconf() check.

Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>

---
Note:

Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp-agent/actions/runs/25323299867

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list