[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems
From: |
Dan Kruchinin |
Subject: |
Re: [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems |
Date: |
Fri, 04 Apr 2008 13:46:18 +0400 |
User-agent: |
Mozilla-Thunderbird 2.0.0.9 (X11/20080109) |
Andreas Schwab wrote:
Dan Kruchinin <address@hidden> writes:
But it'll never return false on _LP64 systems(on which EMACS_INT is long
and sizeof(long) == 8),
because it uses low bitwise operations expecting that sizeof(EMACS_INT) ==
4:
--- src/editfns.c: lisp_time_argument ---
*result = (XINT (high) << 16) + (XINT (low) & 0xffff);
return *result >> 16 == XINT (high);
Where does this assume a 32bit EMACS_INT?
Andreas.
I looked more closely at src/editfns.c and how it works with date and
time, so
1st: yep, my patch was invalid
2nd:
All functions use int data type for holding seconds. Here for example
code from current-time
function:
--
EMACS_TIME t;
EMACS_GET_TIME (t);
return list3 (make_number ((EMACS_SECS (t) >> 16) & 0xffff),
make_number ((EMACS_SECS (t) >> 0) & 0xffff),
make_number (EMACS_USECS (t)));
--
or from get-internal-run-time:
--
int secs, usecs;
...
return list3 (make_number ((secs >> 16) & 0xffff),
make_number ((secs >> 0) & 0xffff),
make_number (usecs));
--
It implies that both HIGH and LOW have size = 2 bytes.
It also implies that they are not depend on how big is int: 32 or 64 bits.
But in the function lisp_time_argument 'high' can be greater than 2 bytes
because XINT(high) returns long(8 bytes on _LP64) and
"*result = (XINT (high) << 16) + (XINT (low) & 0xffff)"
will not truncate it because 'result' has type time_t which can be >
than 4 bytes. (8 bytes on _LP64).
Something like this seems to be valid:
"*result = ((XINT (high) & 0xffff) << 16) + (XINT (low) & 0xffff);"
or like this:
"*result &= 0xffffffff;"
Anyway if "seconds" have some size restriction, lisp_time_argument
should check it correctly.
W.B.R.
Dan Kruchinin.