[Q21.4] truncate range error

Vin Shelton acs at xemacs.org
Mon Apr 19 15:49:53 EDT 2004


QUERY

(Not really a query, though)

Jerry, thanks for the patch, but see my note below:

Jerry James <james at xemacs.org> writes:
> Thank you for the report, Lars.  It looks like this bug predates me, so
> I will cowardly refuse to take responsibility for it. :-) I haven't done
> the required digging through the CVS history yet, but it looks like this
> was probably introduced when Lisp integers were changed from 28 bits to
> 31 bits.  The problem is that VALBITS is used several places in the
> sources where INT_VALBITS should be used.  I've taken the opportunity to
> also replace some complex expressions with EMACS_INT_MAX or
> EMACS_INT_MIN, as appropriate.
>
> A patch for 21.5 will also be necessary.  I will submit that separately,
> because the bignum patch has messed up some of the context.
>
> The data.c and sysdep.c changes look a little funny because (1L << 31)
> causes gcc to complain about integer overflow on 32 bit machines.
>
>
> src/ChangeLog addition:
>
> 2004-04-19  Jerry James  <james at xemacs.org>
>
> 	* data.c (sign_extend_lisp_int): Use INT_VALBITS instead of
> 	VALBITS to compute the location of the sign bit.
> 	* event-stream.c (Fcurrent_event_timestamp): Replace incorrect use
> 	of VALBITS with EMACS_INT_MAX.
> 	* events.c (Fevent_timestamp): Ditto.
> 	* events.c (TIMESTAMP_HALFSPACE): Change VALBITS to INT_VALBITS to
> 	compute the halfway point to timestamp wraparound.
> 	* floatfns.c (float_to_int): Compare against EMACS_INT_MAX and
> 	EMACS_INT_MIN instead of using VALBITS.
> 	* floatfns.c (Flogb): Use EMACS_INT_MIN instead of building an
> 	incorrect number with VALBITS.
> 	* fns.c (Frandom): Correct number of integer bits in docstring.
> 	Use INT_VALBITS instead of VALBITS to compute the denominator.
> 	* sysdep.c (get_random): Use INT_VALBITS instead of VALBITS to
> 	build random numbers.
...
> Index: src/sysdep.c
> ===================================================================
> RCS file: /pack/xemacscvs/XEmacs/xemacs/src/sysdep.c,v
> retrieving revision 1.38.2.3
> diff -d -u -r1.38.2.3 sysdep.c
> --- src/sysdep.c	2002/08/20 11:38:14	1.38.2.3
> +++ src/sysdep.c	2004/04/19 16:14:44
> @@ -3510,19 +3510,19 @@
>  get_random (void)
>  {
>    long val = random ();
> -#if VALBITS > RAND_BITS
> +#if INT_VALBITS > RAND_BITS
>    val = (val << RAND_BITS) ^ random ();
> -#if VALBITS > 2*RAND_BITS
> +#if INT_VALBITS > 2*RAND_BITS
>    val = (val << RAND_BITS) ^ random ();
> -#if VALBITS > 3*RAND_BITS
> +#if INT_VALBITS > 3*RAND_BITS
>    val = (val << RAND_BITS) ^ random ();
> -#if VALBITS > 4*RAND_BITS
> +#if INT_VALBITS > 4*RAND_BITS
>    val = (val << RAND_BITS) ^ random ();
>  #endif /* need at least 5 */
>  #endif /* need at least 4 */
>  #endif /* need at least 3 */
>  #endif /* need at least 2 */
> -  return val & ((1L << VALB

Unfortunately, the patch got truncated here, Jerry.  Can you please
resubmit?

Thanks,
  Vin




More information about the XEmacs-Beta mailing list