emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compiling Elisp to a native code with a GCC plugin


From: Eli Zaretskii
Subject: Re: Compiling Elisp to a native code with a GCC plugin
Date: Fri, 17 Sep 2010 18:39:50 +0200

> From: Lars Magne Ingebrigtsen <address@hidden>
> Date: Fri, 17 Sep 2010 18:24:34 +0200
> 
> The thing I'm must unclear on now is whether it's valid to say
> 
> int thing = PT;
> 
> and whether it's valid to say
> 
> PT + 1;

PT is just a number, an integral data type.  So adding one to it is
okay.  But storing into an `int' is not, because PT is an EMACS_INT,
see `struct buffer':

    struct buffer
    {
      ...
      /* Char position of point in buffer.  */
      EMACS_INT pt;
      /* Byte position of point in buffer.  */
      EMACS_INT pt_byte;

EMACS_INT is a 64-bit data type on 64-bit machines, so assigning it to
an int is a bug waiting to happen.  You should do this instead:

  EMACS_INT thing = PT;

> I've grepped through the code, and this seems to be used all over the
> place

Each place where you see PT assigned to an int is a bug, please either
report it or fix it right away.

> so I'm guessing that perhaps the size of a buffer is constrained
> to be less than INT_MAX?

No, it's constrained by most-positive-fixnum (MOST_POSITIVE_FIXNUM in
C), but we still have many places where we use a int, which is why
buffers larger than MAX_INT not always work well.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]