Skip to content

Commit

Permalink
timer: proper way to check POSIX timers support
Browse files Browse the repository at this point in the history
The _POSIX_TIMERS macros can be used to determine the degree of a
host's support for the posix timers API.

The POSIX definition (2018 edition) says that:

_POSIX_TIMERS

The implementation supports timers. This symbol shall always
be set to the value 200809L.

It's defined in the <unistd.h> header.

Tested on esp32, pico and teensy4.

Signed-off-by: Thomas Chou <[email protected]>
  • Loading branch information
hippo5329 committed May 28, 2024
1 parent 48096f8 commit 1cc3601
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions platform_code/arduino/clock_gettime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <sys/time.h>
#define micro_rollover_useconds 4294967295

#ifndef WITH_POSIX
#ifndef _POSIX_TIMERS

extern "C" int clock_gettime(clockid_t unused, struct timespec *tp)
{
Expand All @@ -22,4 +22,4 @@ extern "C" int clock_gettime(clockid_t unused, struct timespec *tp)
return 0;
}

#endif // ifndef WITH_POSIX
#endif // ifndef _POSIX_TIMERS

0 comments on commit 1cc3601

Please sign in to comment.