all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Kruchinin <dan.kruchinin@gmail.com>
To: Andreas Schwab <schwab@suse.de>
Cc: emacs-devel@gnu.org
Subject: Re: [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems
Date: Fri, 04 Apr 2008 13:46:18 +0400	[thread overview]
Message-ID: <47F5F8EA.40101@gmail.com> (raw)
In-Reply-To: <je63uym2by.fsf@sykes.suse.de>

Andreas Schwab wrote:
> Dan Kruchinin <dan.kruchinin@gmail.com> 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.





      reply	other threads:[~2008-04-04  9:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-04  7:27 [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems Dan Kruchinin
2008-04-04  8:49 ` Andreas Schwab
2008-04-04  9:46   ` Dan Kruchinin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47F5F8EA.40101@gmail.com \
    --to=dan.kruchinin@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.