Hi,
According to tests/lib/libc/sys/t_clock_gettime.c
""These clocks aren't supported but are documented"
" in clock_gettime(2) for some reason"
thanks for the pointer. I am new to NetBSD
and am only getting into tests(7) so please bare with me.
According to these test results (random google hit, but a recent run)
https://www.netbsd.org/~martin/landisk-atf/last_atf.html#lib_libc_sys_t_clock_gettime_clock_getres
calling clock_getres() on these two clocks is expected to fail.
It seems a bit silly to test that NetBSD does _not_ support a clock.
(Isn't clock_gettime() also expected to fail, if they do not exist? :-)
Wouldn't it make more sense to just remove these from the documentation?
There's also a PR in about CLOCK_MONOTONIC & what it actually represents:
https://gnats.netbsd.org/60315
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <err.h>
void
show(clockid_t id, char* name)
{
struct timespec ts;
struct timespec cr;
if (clock_gettime(id, &ts) == -1)
err(1, NULL);
if (clock_getres(id, &cr) == -1)
err(1, NULL);
printf("%s %10lld.%09ld s, %8ld ns resolution\n",
name, ts.tv_sec, ts.tv_nsec, cr.tv_nsec);
}
int
main(void)
{
#ifdef __APPLE__
show(CLOCK_REALTIME, "real time");
show(CLOCK_MONOTONIC, "monotonic");
show(CLOCK_UPTIME_RAW, "up time ");
show(CLOCK_PROCESS_CPUTIME_ID, "proc time");
#elif __OpenBSD__
show(CLOCK_REALTIME, "real time");
show(CLOCK_MONOTONIC, "monotonic");
show(CLOCK_BOOTTIME, "boot time");
show(CLOCK_UPTIME, "up time ");
show(CLOCK_PROCESS_CPUTIME_ID, "proc time");
#elif __FreeBSD__
show(CLOCK_REALTIME, "real time");
show(CLOCK_MONOTONIC, "monotonic");
show(CLOCK_BOOTTIME, "boot time");
show(CLOCK_UPTIME, "up time ");
show(CLOCK_PROCESS_CPUTIME_ID, "proc time");
#elif __NetBSD__
show(CLOCK_REALTIME, "real time");
show(CLOCK_MONOTONIC, "monotonic");
show(CLOCK_PROCESS_CPUTIME_ID, "proc time");
#else
show(CLOCK_REALTIME, "real time");
show(CLOCK_MONOTONIC, "monotonic");
show(CLOCK_BOOTTIME, "boot time");
show(CLOCK_PROCESS_CPUTIME_ID, "proc time");
#endif
return 0;
}