Commit ef939833 authored by Paul Eggert's avatar Paul Eggert

Adjust to TIMESPEC_HZ renaming

Adjust to lib/timespec.h’s renaming of TIMESPEC_RESOLUTION and
LOG10_TIMESPEC_RESOLUTION to TIMESPEC_HZ and
LOG10_TIMESPEC_HZ.  The old names were misnomers.
All uses changed.
parent fc389d3a
......@@ -43,7 +43,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
static struct timespec TV1;
static int watch_not_started = 1; /* flag */
static char time_string[INT_STRLEN_BOUND (uintmax_t) + sizeof "."
+ LOG10_TIMESPEC_RESOLUTION];
+ LOG10_TIMESPEC_HZ];
/* Reset the stopwatch to zero. */
......@@ -66,7 +66,7 @@ get_time (void)
int ns = TV2.tv_nsec;
if (watch_not_started)
exit (EXIT_FAILURE); /* call reset_watch first ! */
sprintf (time_string, "%"PRIuMAX".%0*d", s, LOG10_TIMESPEC_RESOLUTION, ns);
sprintf (time_string, "%"PRIuMAX".%0*d", s, LOG10_TIMESPEC_HZ, ns);
return time_string;
}
......
......@@ -1867,7 +1867,7 @@ xg_maybe_add_timer (gpointer data)
if (timespec_valid_p (next_time))
{
time_t s = next_time.tv_sec;
int per_ms = TIMESPEC_RESOLUTION / 1000;
int per_ms = TIMESPEC_HZ / 1000;
int ms = (next_time.tv_nsec + per_ms - 1) / per_ms;
if (s <= ((guint) -1 - ms) / 1000)
dd->timerid = g_timeout_add (s * 1000 + ms, xg_maybe_add_timer, dd);
......
......@@ -252,7 +252,7 @@ static EMACS_INT update_tick;
# define HAVE_SEQPACKET
#endif
#define READ_OUTPUT_DELAY_INCREMENT (TIMESPEC_RESOLUTION / 100)
#define READ_OUTPUT_DELAY_INCREMENT (TIMESPEC_HZ / 100)
#define READ_OUTPUT_DELAY_MAX (READ_OUTPUT_DELAY_INCREMENT * 5)
#define READ_OUTPUT_DELAY_MAX_MAX (READ_OUTPUT_DELAY_INCREMENT * 7)
......@@ -5478,7 +5478,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
have waited a long amount of time due to repeated
timers. */
struct timespec huge_timespec
= make_timespec (TYPE_MAXIMUM (time_t), 2 * TIMESPEC_RESOLUTION);
= make_timespec (TYPE_MAXIMUM (time_t), 2 * TIMESPEC_HZ);
struct timespec cmp_time = huge_timespec;
if (wait < TIMEOUT
|| (wait_proc
......
......@@ -3078,16 +3078,15 @@ time_from_jiffies (unsigned long long tval, long hz)
if (TYPE_MAXIMUM (time_t) < s)
time_overflow ();
if (LONG_MAX - 1 <= ULLONG_MAX / TIMESPEC_RESOLUTION
|| frac <= ULLONG_MAX / TIMESPEC_RESOLUTION)
ns = frac * TIMESPEC_RESOLUTION / hz;
if (LONG_MAX - 1 <= ULLONG_MAX / TIMESPEC_HZ
|| frac <= ULLONG_MAX / TIMESPEC_HZ)
ns = frac * TIMESPEC_HZ / hz;
else
{
/* This is reachable only in the unlikely case that HZ * HZ
exceeds ULLONG_MAX. It calculates an approximation that is
guaranteed to be in range. */
long hz_per_ns = (hz / TIMESPEC_RESOLUTION
+ (hz % TIMESPEC_RESOLUTION != 0));
long hz_per_ns = hz / TIMESPEC_HZ + (hz % TIMESPEC_HZ != 0);
ns = frac / hz_per_ns;
}
......@@ -3123,16 +3122,16 @@ get_up_time (void)
if (TYPE_MAXIMUM (time_t) < upsec)
{
upsec = TYPE_MAXIMUM (time_t);
upfrac = TIMESPEC_RESOLUTION - 1;
upfrac = TIMESPEC_HZ - 1;
}
else
{
int upfraclen = upfrac_end - upfrac_start;
for (; upfraclen < LOG10_TIMESPEC_RESOLUTION; upfraclen++)
for (; upfraclen < LOG10_TIMESPEC_HZ; upfraclen++)
upfrac *= 10;
for (; LOG10_TIMESPEC_RESOLUTION < upfraclen; upfraclen--)
for (; LOG10_TIMESPEC_HZ < upfraclen; upfraclen--)
upfrac /= 10;
upfrac = min (upfrac, TIMESPEC_RESOLUTION - 1);
upfrac = min (upfrac, TIMESPEC_HZ - 1);
}
up = make_timespec (upsec, upfrac);
}
......
......@@ -58,8 +58,8 @@ invalid_timespec (void)
}
/* Return true if TIME is a valid timespec. This currently doesn't worry
about whether tv_nsec is less than TIMESPEC_RESOLUTION; leap seconds
might cause a problem if it did. */
about whether tv_nsec is less than TIMESPEC_HZ; leap seconds might
cause a problem if it did. */
INLINE bool
timespec_valid_p (struct timespec t)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment