summaryrefslogtreecommitdiffstats
path: root/man2/clock_getres.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/clock_getres.2')
-rw-r--r--man2/clock_getres.226
1 files changed, 13 insertions, 13 deletions
diff --git a/man2/clock_getres.2 b/man2/clock_getres.2
index e744bc7ff..9fb7ef14d 100644
--- a/man2/clock_getres.2
+++ b/man2/clock_getres.2
@@ -226,11 +226,11 @@ dynamic clock ID.
#define CLOCKFD 3
#define FD_TO_CLOCKID(fd) ((\[ti](clockid_t) (fd) << 3) | CLOCKFD)
#define CLOCKID_TO_FD(clk) ((unsigned int) \[ti]((clk) >> 3))
-
+\&
struct timespec ts;
clockid_t clkid;
int fd;
-
+\&
fd = open("/dev/ptp0", O_RDWR);
clkid = FD_TO_CLOCKID(fd);
clock_gettime(clkid, &ts);
@@ -445,7 +445,7 @@ CLOCK_BOOTTIME : 72691.019 (20h 11m 31s)
.\" SRC BEGIN (clock_getres.c)
.EX
/* clock_times.c
-
+\&
Licensed under GNU General Public License v2 or later.
*/
#define _XOPEN_SOURCE 600
@@ -454,48 +454,48 @@ CLOCK_BOOTTIME : 72691.019 (20h 11m 31s)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-
+\&
#define SECS_IN_DAY (24 * 60 * 60)
-
+\&
static void
displayClock(clockid_t clock, const char *name, bool showRes)
{
long days;
struct timespec ts;
-
+\&
if (clock_gettime(clock, &ts) == \-1) {
perror("clock_gettime");
exit(EXIT_FAILURE);
}
-
+\&
printf("%\-15s: %10jd.%03ld (", name,
(intmax_t) ts.tv_sec, ts.tv_nsec / 1000000);
-
+\&
days = ts.tv_sec / SECS_IN_DAY;
if (days > 0)
printf("%ld days + ", days);
-
+\&
printf("%2dh %2dm %2ds",
(int) (ts.tv_sec % SECS_IN_DAY) / 3600,
(int) (ts.tv_sec % 3600) / 60,
(int) ts.tv_sec % 60);
printf(")\en");
-
+\&
if (clock_getres(clock, &ts) == \-1) {
perror("clock_getres");
exit(EXIT_FAILURE);
}
-
+\&
if (showRes)
printf(" resolution: %10jd.%09ld\en",
(intmax_t) ts.tv_sec, ts.tv_nsec);
}
-
+\&
int
main(int argc, char *argv[])
{
bool showRes = argc > 1;
-
+\&
displayClock(CLOCK_REALTIME, "CLOCK_REALTIME", showRes);
#ifdef CLOCK_TAI
displayClock(CLOCK_TAI, "CLOCK_TAI", showRes);