From f3931497f8aee291bce132fb106cedb55c5b3fa9 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 2 Jun 2020 08:17:27 +0000 Subject: Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control mode %output blocks. --- tmux.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index cfc84cd0..a9aec43d 100644 --- a/tmux.c +++ b/tmux.c @@ -240,6 +240,20 @@ setblocking(int fd, int state) } } +uint64_t +get_timer(void) +{ + struct timespec ts; + + /* + * We want a timestamp in milliseconds suitable for time measurement, + * so prefer the monotonic clock. + */ + if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) + clock_gettime(CLOCK_REALTIME, &ts); + return ((ts.tv_sec * 1000ULL) + (ts.tv_nsec / 1000000ULL)); +} + const char * sig2name(int signo) { -- cgit