Fix bug when time_t is unsigned and as wide as intmax_t.

* lisp.h (WAIT_READING_MAX): New macro.
* dispnew.c (Fsleep_for, sit_for):
* keyboard.c (kbd_buffer_get_event):
* process.c (Faccept_process_output):
Use it to avoid bogus compiler warnings with obsolescent GCC versions.
This improves on the previous patch, which introduced a bug
when time_t is unsigned and as wide as intmax_t.
See <http://bugs.gnu.org/9000#51>.
This commit is contained in:
Paul Eggert 2012-06-23 21:11:19 -07:00
parent b82c175521
commit f1dd807386
5 changed files with 25 additions and 12 deletions

View file

@ -1,3 +1,15 @@
2012-06-24 Paul Eggert <eggert@cs.ucla.edu>
Fix bug when time_t is unsigned and as wide as intmax_t (Bug#9000).
* lisp.h (WAIT_READING_MAX): New macro.
* dispnew.c (Fsleep_for, sit_for):
* keyboard.c (kbd_buffer_get_event):
* process.c (Faccept_process_output):
Use it to avoid bogus compiler warnings with obsolescent GCC versions.
This improves on the previous patch, which introduced a bug
when time_t is unsigned and as wide as intmax_t.
See <http://bugs.gnu.org/9000#51>.
2012-06-23 Eli Zaretskii <eliz@gnu.org>
* dispnew.c (sit_for, Fsleep_for):

View file

@ -5957,9 +5957,7 @@ additional wait period, in milliseconds; this is for backwards compatibility.
if (0 < duration)
{
EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration);
intmax_t secs = EMACS_SECS (t);
wait_reading_process_output (min (secs, INTMAX_MAX),
wait_reading_process_output (min (EMACS_SECS (t), WAIT_READING_MAX),
EMACS_NSECS (t), 0, 0, Qnil, NULL, 0);
}
@ -6007,8 +6005,7 @@ sit_for (Lisp_Object timeout, int reading, int do_display)
else
{
EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (seconds);
sec = EMACS_SECS (t);
sec = min (sec, INTMAX_MAX);
sec = min (EMACS_SECS (t), WAIT_READING_MAX);
nsec = EMACS_NSECS (t);
}
}

View file

@ -3857,11 +3857,9 @@ kbd_buffer_get_event (KBOARD **kbp,
return Qnil; /* finished waiting */
else
{
intmax_t secs;
EMACS_SUB_TIME (duration, *end_time, duration);
secs = EMACS_SECS (duration);
wait_reading_process_output (min (secs, INTMAX_MAX),
wait_reading_process_output (min (EMACS_SECS (duration),
WAIT_READING_MAX),
EMACS_NSECS (duration),
-1, 1, Qnil, NULL, 0);
}

View file

@ -3249,6 +3249,14 @@ extern int wait_reading_process_output (intmax_t, int, int, int,
Lisp_Object,
struct Lisp_Process *,
int);
/* Max value for the first argument of wait_reading_process_output. */
#if __GNUC__ == 3 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 5)
/* Work around a bug in GCC 3.4.2, known to be fixed in GCC 4.6.3.
The bug merely causes a bogus warning, but the warning is annoying. */
# define WAIT_READING_MAX min (TYPE_MAXIMUM (time_t), INTMAX_MAX)
#else
# define WAIT_READING_MAX INTMAX_MAX
#endif
extern void add_keyboard_wait_descriptor (int);
extern void delete_keyboard_wait_descriptor (int);
#ifdef HAVE_GPM

View file

@ -3996,9 +3996,7 @@ Return non-nil if we received any output before the timeout expired. */)
if (0 < XFLOAT_DATA (seconds))
{
EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (seconds));
secs = EMACS_SECS (t);
secs = min (secs, INTMAX_MAX);
secs = min (EMACS_SECS (t), WAIT_READING_MAX);
nsecs = EMACS_NSECS (t);
}
}