aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-06-23 21:11:19 -0700
committerPaul Eggert2012-06-23 21:11:19 -0700
commitf1dd807386718d2c7c29d13b9f7615759086a954 (patch)
treefd8eefef3df95b6db09d8a03380f53f88be5832a /src
parentb82c175521ddd7d7ae8183c62fc87587b8b615e5 (diff)
downloademacs-f1dd807386718d2c7c29d13b9f7615759086a954.tar.gz
emacs-f1dd807386718d2c7c29d13b9f7615759086a954.zip
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>.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/dispnew.c7
-rw-r--r--src/keyboard.c6
-rw-r--r--src/lisp.h8
-rw-r--r--src/process.c4
5 files changed, 25 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 40073d32834..a302db4fae6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12012-06-24 Paul Eggert <eggert@cs.ucla.edu>
2
3 Fix bug when time_t is unsigned and as wide as intmax_t (Bug#9000).
4 * lisp.h (WAIT_READING_MAX): New macro.
5 * dispnew.c (Fsleep_for, sit_for):
6 * keyboard.c (kbd_buffer_get_event):
7 * process.c (Faccept_process_output):
8 Use it to avoid bogus compiler warnings with obsolescent GCC versions.
9 This improves on the previous patch, which introduced a bug
10 when time_t is unsigned and as wide as intmax_t.
11 See <http://bugs.gnu.org/9000#51>.
12
12012-06-23 Eli Zaretskii <eliz@gnu.org> 132012-06-23 Eli Zaretskii <eliz@gnu.org>
2 14
3 * dispnew.c (sit_for, Fsleep_for): 15 * dispnew.c (sit_for, Fsleep_for):
diff --git a/src/dispnew.c b/src/dispnew.c
index e18fca6f122..05c22be79ae 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5957,9 +5957,7 @@ additional wait period, in milliseconds; this is for backwards compatibility.
5957 if (0 < duration) 5957 if (0 < duration)
5958 { 5958 {
5959 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration); 5959 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration);
5960 intmax_t secs = EMACS_SECS (t); 5960 wait_reading_process_output (min (EMACS_SECS (t), WAIT_READING_MAX),
5961
5962 wait_reading_process_output (min (secs, INTMAX_MAX),
5963 EMACS_NSECS (t), 0, 0, Qnil, NULL, 0); 5961 EMACS_NSECS (t), 0, 0, Qnil, NULL, 0);
5964 } 5962 }
5965 5963
@@ -6007,8 +6005,7 @@ sit_for (Lisp_Object timeout, int reading, int do_display)
6007 else 6005 else
6008 { 6006 {
6009 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (seconds); 6007 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (seconds);
6010 sec = EMACS_SECS (t); 6008 sec = min (EMACS_SECS (t), WAIT_READING_MAX);
6011 sec = min (sec, INTMAX_MAX);
6012 nsec = EMACS_NSECS (t); 6009 nsec = EMACS_NSECS (t);
6013 } 6010 }
6014 } 6011 }
diff --git a/src/keyboard.c b/src/keyboard.c
index 38b05c22063..a39be2b859c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3857,11 +3857,9 @@ kbd_buffer_get_event (KBOARD **kbp,
3857 return Qnil; /* finished waiting */ 3857 return Qnil; /* finished waiting */
3858 else 3858 else
3859 { 3859 {
3860 intmax_t secs;
3861
3862 EMACS_SUB_TIME (duration, *end_time, duration); 3860 EMACS_SUB_TIME (duration, *end_time, duration);
3863 secs = EMACS_SECS (duration); 3861 wait_reading_process_output (min (EMACS_SECS (duration),
3864 wait_reading_process_output (min (secs, INTMAX_MAX), 3862 WAIT_READING_MAX),
3865 EMACS_NSECS (duration), 3863 EMACS_NSECS (duration),
3866 -1, 1, Qnil, NULL, 0); 3864 -1, 1, Qnil, NULL, 0);
3867 } 3865 }
diff --git a/src/lisp.h b/src/lisp.h
index dd8cdd348b2..275761b0e94 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3249,6 +3249,14 @@ extern int wait_reading_process_output (intmax_t, int, int, int,
3249 Lisp_Object, 3249 Lisp_Object,
3250 struct Lisp_Process *, 3250 struct Lisp_Process *,
3251 int); 3251 int);
3252/* Max value for the first argument of wait_reading_process_output. */
3253#if __GNUC__ == 3 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 5)
3254/* Work around a bug in GCC 3.4.2, known to be fixed in GCC 4.6.3.
3255 The bug merely causes a bogus warning, but the warning is annoying. */
3256# define WAIT_READING_MAX min (TYPE_MAXIMUM (time_t), INTMAX_MAX)
3257#else
3258# define WAIT_READING_MAX INTMAX_MAX
3259#endif
3252extern void add_keyboard_wait_descriptor (int); 3260extern void add_keyboard_wait_descriptor (int);
3253extern void delete_keyboard_wait_descriptor (int); 3261extern void delete_keyboard_wait_descriptor (int);
3254#ifdef HAVE_GPM 3262#ifdef HAVE_GPM
diff --git a/src/process.c b/src/process.c
index b41a77f58fd..457a1a9c7ea 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3996,9 +3996,7 @@ Return non-nil if we received any output before the timeout expired. */)
3996 if (0 < XFLOAT_DATA (seconds)) 3996 if (0 < XFLOAT_DATA (seconds))
3997 { 3997 {
3998 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (seconds)); 3998 EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (seconds));
3999 3999 secs = min (EMACS_SECS (t), WAIT_READING_MAX);
4000 secs = EMACS_SECS (t);
4001 secs = min (secs, INTMAX_MAX);
4002 nsecs = EMACS_NSECS (t); 4000 nsecs = EMACS_NSECS (t);
4003 } 4001 }
4004 } 4002 }