Search code examples
clinuxunixposix

Which standard defines the value of "sysconf()" options like "_SC_MONOTONIC_CLOCK"?


(This is a follow-up question for how to check if monotonic clock is supported )

I tried printing the value of _SC_MONOTONIC_CLOCK and got 149. I tried Google search on POSIX site and got no results.

(Update after the answer: 149 is on Debian. Just tried on macOS and FreeBSD and both are using value 74.)


Solution

  • POSIX states that the symbolic constants _SC_* are defined in the unistd.h header:

    The unistd.h header shall define the following symbolic constants for sysconf(): [...] _SC_MONOTONIC_CLOCK

    However, it does not define what is the value of such symbolic constant -- it shouldn't be important for your application (and you should not depend on which the value is).

    For instance, the GNU C Library lists all of them in an enum; while newlib defines explicit values. OpenBSD and NetBSD also use explicit, but different, values.