summaryrefslogtreecommitdiff
path: root/src/xterm.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-09-27 11:23:59 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2025-09-27 12:26:24 -0700
commit5e06aa209bc906cf16f2e3de622a189bec34aa78 (patch)
tree0d5541355f0f4d7777475f2534a20795e9302ff5 /src/xterm.c
parent3cdc615218458729b51a715bedc899e3df5bfa64 (diff)
Prefer coarse timestamps when using X sync
They are good enough for this purpose, and are cheaper to get. * src/timefns.c (monotonic_coarse_timespec): New function. * src/xterm.c [HAVE_XSYNC && !USE_GTK && HAVE_CLOCK_GETTIME]: (x_sync_current_monotonic_time): Use it. (CLOCK_MONOTONIC): Remove; no longer uneeded here.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/xterm.c b/src/xterm.c
index d520ac1bdf5..e47a836713a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7067,22 +7067,15 @@ x_sync_get_monotonic_time (struct x_display_info *dpyinfo,
return ckd_sub (&t, timestamp, dpyinfo->server_time_offset) ? 0 : t;
}
-# ifndef CLOCK_MONOTONIC
-# define CLOCK_MONOTONIC CLOCK_REALTIME
-# endif
-
/* Return the current monotonic time in the same format as a
high-resolution server timestamp, or 0 if not available. */
static uint_fast64_t
x_sync_current_monotonic_time (void)
{
- struct timespec time;
+ struct timespec time = monotonic_coarse_timespec ();
uint_fast64_t t;
- return (((clock_gettime (CLOCK_MONOTONIC, &time) != 0
- && (CLOCK_MONOTONIC == CLOCK_REALTIME
- || clock_gettime (CLOCK_REALTIME, &time) != 0))
- || ckd_mul (&t, time.tv_sec, 1000000)
+ return ((ckd_mul (&t, time.tv_sec, 1000000)
|| ckd_add (&t, t, time.tv_nsec / 1000))
? 0 : t);
}