unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long
@ 2012-06-14 19:17 Ulrich Mueller
  2012-06-21 19:56 ` Glenn Morris
  2012-06-25 20:19 ` Ulrich Mueller
  0 siblings, 2 replies; 4+ messages in thread
From: Ulrich Mueller @ 2012-06-14 19:17 UTC (permalink / raw)
  To: 11712

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 275 bytes --]

The EMACS_TIME_CMP macro defined in systime.h casts the seconds values
(which are of type time_t) to long. This is problematic on platforms
where time_t has 64 bits but long has only 32 bits, for example
GNU/Linux x64_64 systems with x32 ABI.

Attached patch should fix it.


[-- Attachment #2: systime-time_t.diff --]
[-- Type: text/plain, Size: 1155 bytes --]

--- emacs-orig/src/ChangeLog
+++ emacs/src/ChangeLog
@@ -1,3 +1,7 @@
+2012-06-14  Ulrich Müller  <ulm@gentoo.org>
+
+	* systime.h (EMACS_TIME_CMP): Don't cast time_t values to long.
+
 2012-06-14  Paul Eggert  <eggert@cs.ucla.edu>
 
 	* .gdbinit (xgetint): Fix recently-introduced paren typo.
--- emacs-orig/src/systime.h
+++ emacs/src/systime.h
@@ -147,15 +147,12 @@
 #endif
 
 /* Compare times T1 and T2.  Value is 0 if T1 and T2 are the same.
-   Value is < 0 if T1 is less than T2.  Value is > 0 otherwise.  (Cast
-   to long is for those platforms where time_t is an unsigned
-   type, and where otherwise T1 will always be grater than T2.)  */
+   Value is < 0 if T1 is less than T2.  Value is > 0 otherwise.  */
 
 #define EMACS_TIME_CMP(T1, T2)				\
-  ((long)EMACS_SECS (T1) - (long)EMACS_SECS (T2)	\
-   + (EMACS_SECS (T1) == EMACS_SECS (T2)		\
-      ? EMACS_USECS (T1) - EMACS_USECS (T2)		\
-      : 0))
+  (EMACS_SECS (T1) == EMACS_SECS (T2)			\
+   ? EMACS_USECS (T1) - EMACS_USECS (T2)		\
+   : (EMACS_SECS (T1) < EMACS_SECS (T2) ? -1 : 1))
 
 /* Compare times T1 and T2 for equality, inequality etc.  */
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long
  2012-06-14 19:17 bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long Ulrich Mueller
@ 2012-06-21 19:56 ` Glenn Morris
  2012-06-25 20:19 ` Ulrich Mueller
  1 sibling, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-06-21 19:56 UTC (permalink / raw)
  To: Ulrich Mueller; +Cc: 11712


This seems important, but I'm not qualified to judge it, so I hope
someone who is looks at this patch.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long
  2012-06-14 19:17 bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long Ulrich Mueller
  2012-06-21 19:56 ` Glenn Morris
@ 2012-06-25 20:19 ` Ulrich Mueller
  2012-06-25 23:19   ` Glenn Morris
  1 sibling, 1 reply; 4+ messages in thread
From: Ulrich Mueller @ 2012-06-25 20:19 UTC (permalink / raw)
  To: 11712

Seems that it has been taken care of independently:
<http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/108687#src/systime.h>





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long
  2012-06-25 20:19 ` Ulrich Mueller
@ 2012-06-25 23:19   ` Glenn Morris
  0 siblings, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-06-25 23:19 UTC (permalink / raw)
  To: Ulrich Mueller; +Cc: 11712

Ulrich Mueller wrote:

> Seems that it has been taken care of independently:
> <http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/108687#src/systime.h>

OK, good, if you say so! :)

I think it should somehow be fixed in the emacs-24 branch as well,
just in case.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-25 23:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-14 19:17 bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long Ulrich Mueller
2012-06-21 19:56 ` Glenn Morris
2012-06-25 20:19 ` Ulrich Mueller
2012-06-25 23:19   ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).