diff options
author | nicm <nicm> | 2020-06-02 08:17:27 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-06-02 08:17:27 +0000 |
commit | f3931497f8aee291bce132fb106cedb55c5b3fa9 (patch) | |
tree | 2acdacdac20714ab521508b93e362e35478ea06a /tmux.c | |
parent | 563b7331da2d31aca470389817c282a46da7c872 (diff) | |
download | rtmux-f3931497f8aee291bce132fb106cedb55c5b3fa9.tar.gz rtmux-f3931497f8aee291bce132fb106cedb55c5b3fa9.tar.bz2 rtmux-f3931497f8aee291bce132fb106cedb55c5b3fa9.zip |
Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.
Diffstat (limited to 'tmux.c')
-rw-r--r-- | tmux.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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) { |