[LTP] nanosleep: use POSIX runtime detection for CLOCK_MONOTONIC
Petr Vorel
pvorel@suse.cz
Thu Apr 16 13:58:01 CEST 2026
> Hi Andrea,
> On Thu, 16 Apr 2026 08:59:59 +0200, Andrea Cervesato wrote:
> > nanosleep: use POSIX runtime detection for CLOCK_MONOTONIC
> > -#include <unistd.h>
> > #include <sys/wait.h>
> > #include "posixtest.h"
> > -
> > -#ifdef _POSIX_MONOTONIC_CLOCK
> > -#define TEST_CLOCK CLOCK_MONOTONIC
> > -#else
> > -#define TEST_CLOCK CLOCK_REALTIME
> > -#endif
> > +#include "helpers.h"
> This applies to 1-2.c, 1-3.c, 3-2.c, and 7-2.c. These files call
> fork() and sleep() — both declared in <unistd.h> — but the explicit
> #include <unistd.h> is removed and now only arrives transitively via
> helpers.h. Each file should include the headers it directly uses;
> please keep #include <unistd.h> in these four files.
Hm, we happily use indirect includes in non-openPOSIX tests
(in testcases/kernel/syscalls/). It certainly does not harm to include
<unistd.h> on each place which uses _POSIX_MONOTONIC_CLOCK.
I'd hope agent would find other '#ifdef _POSIX_MONOTONIC_CLOCK' use without
<unistd.h> which is in
testcases/open_posix_testsuite/conformance/interfaces/clock_settime/helpers.h
Kind regards,
Petr
> ---
> Note:
> Our agent completed the review of the patch. 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.
More information about the ltp
mailing list