The `_POSIX_TIMERS` macro is defined to -1, indicating no support for
the POSIX timers option. This option indicates support for the
`clock_getres`, `clock_gettime`, `clock_settime`, `nanosleep`, and
`timer_*` functions. While the `timer_*` functions do not appear to be
supported by OpenBSD, the ubiquitous `clock_*` functions are, and their
man pages indicate that they conform to IEEE Std 1003.1-2008 POSIX.1.

Defining the `_POSIX_TIMERS` macro to -1 is problematic because
conforming POSIX programs cannot use the `clock_*` functions in any
capacity given that they may not be defined. It should not be defined to
1, however, because not all of the functions included in the timers
option are supported by OpenBSD. Thus I suggest that the `_POSIX_TIMERS`
macro is defined to 0, indicating conditional support, and that the
unsupported functions be implemented with stubs as suggested by POSIX.

It is worth noting that the timers option was moved to the base standard
in POSIX-2008, meaning that all implementations conforming to the latest
version of the POSIX standard must implement all interfaces included
with it. In theory a program could check if the `_POSIX_VERSION` macro
is defined with a value >= 200809, which OpenBSD does by default. This
seems unreasonable since clearly, this is not accurate either.

Similarly, the `_POSIX_MONOTONIC_CLOCK`, `_POSIX_CPUTIME`, and
`_POSIX_THREAD_CPUTIME` macros are all defined with values >= 1, even
though they imply `_POSIX_TIMERS` is >= 1 as well. The
`_POSIX_CLOCK_SELECTION` macro is also defined as -1, however both the
`pthread_condattr_getclock` and `pthread_condattr_setclock` functions
are supported while the additional `clock_nanosleep` function is not.

Reply via email to