changeset 2039:fd0cbe945410

[xemacs-hg @ 2004-04-22 03:24:00 by james] Change VALBITS to INT_VALBITS in a number of places.
author james
date Thu, 22 Apr 2004 03:24:02 +0000
parents c6190a5b1ece
children 8d61839d121a
files src/ChangeLog src/data.c src/event-stream.c src/events.c src/floatfns.c src/fns.c src/sysdep.c
diffstat 7 files changed, 41 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Apr 21 21:50:35 2004 +0000
+++ b/src/ChangeLog	Thu Apr 22 03:24:02 2004 +0000
@@ -1,3 +1,21 @@
+2004-04-19  Jerry James  <james@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): Use INT_VALBITS instead of VALBITS to compute
+	the denominator.
+	* sysdep.c (get_random): Use INT_VALBITS instead of VALBITS to
+	build random numbers.
+	
 2004-04-18  Jerry James  <james@xemacs.org>
 
 	* dump-data.c (dumped_data_get): Change return type to char *.
--- a/src/data.c	Wed Apr 21 21:50:35 2004 +0000
+++ b/src/data.c	Thu Apr 22 03:24:02 2004 +0000
@@ -171,10 +171,10 @@
 EMACS_INT
 sign_extend_lisp_int (EMACS_INT num)
 {
-  if (num & (1L << (VALBITS - 1)))
-    return num | ((-1L) << VALBITS);
+  if (num & (1L << (INT_VALBITS - 1)))
+    return num | ((-1L) << INT_VALBITS);
   else
-    return num & ((1L << VALBITS) - 1);
+    return num & (EMACS_INT) ((1UL << INT_VALBITS) - 1);
 }
 
 
--- a/src/event-stream.c	Wed Apr 21 21:50:35 2004 +0000
+++ b/src/event-stream.c	Thu Apr 22 03:24:02 2004 +0000
@@ -4782,7 +4782,7 @@
   /* This junk is so that timestamps don't get to be negative, but contain
      as many bits as this particular emacs will allow.
    */
-  return make_int (((1L << (VALBITS - 1)) - 1) & tiempo);
+  return make_int (EMACS_INT_MAX & tiempo);
 }
 
 
--- a/src/events.c	Wed Apr 21 21:50:35 2004 +0000
+++ b/src/events.c	Thu Apr 22 03:24:02 2004 +0000
@@ -1744,11 +1744,10 @@
   /* This junk is so that timestamps don't get to be negative, but contain
      as many bits as this particular emacs will allow.
    */
-  return make_int (((1L << (VALBITS - 1)) - 1) &
-		      XEVENT_TIMESTAMP (event));
+  return make_int (EMACS_INT_MAX & XEVENT_TIMESTAMP (event));
 }
 
-#define TIMESTAMP_HALFSPACE (1L << (VALBITS - 2))
+#define TIMESTAMP_HALFSPACE (1L << (INT_VALBITS - 2))
 
 DEFUN ("event-timestamp<", Fevent_timestamp_lessp, 2, 2, 0, /*
 Return true if timestamp TIME1 is earlier than timestamp TIME2.
--- a/src/floatfns.c	Wed Apr 21 21:50:35 2004 +0000
+++ b/src/floatfns.c	Thu Apr 22 03:24:02 2004 +0000
@@ -128,15 +128,16 @@
   bignum_set_double (scratch_bignum, x);
   return Fcanonicalize_number (make_bignum_bg (scratch_bignum));
 #else
-  if (x >= ((EMACS_INT) 1 << (VALBITS-1))
-      || x <= - ((EMACS_INT) 1 << (VALBITS-1)) - (EMACS_INT) 1)
-  {
-    if (!UNBOUNDP (num2))
-      range_error2 (name, num, num2);
-    else
-      range_error (name, num);
-  }
-  return (make_int ((EMACS_INT) x));
+  REGISTER EMACS_INT result = (EMACS_INT) x;
+
+  if (result > EMACS_INT_MAX || result < EMACS_INT_MIN)
+    {
+      if (!UNBOUNDP (num2))
+	range_error2 (name, num, num2);
+      else
+	range_error (name, num);
+    }
+  return make_int (result);
 #endif /* HAVE_BIGNUM */
 }
 
@@ -798,7 +799,7 @@
   double f = extract_float (number);
 
   if (f == 0.0)
-    return make_int (- (EMACS_INT)(((EMACS_UINT) 1) << (VALBITS - 1))); /* most-negative-fixnum */
+    return make_int (EMACS_INT_MIN);
 #ifdef HAVE_LOGB
   {
     Lisp_Object val;
--- a/src/fns.c	Wed Apr 21 21:50:35 2004 +0000
+++ b/src/fns.c	Thu Apr 22 03:24:02 2004 +0000
@@ -170,7 +170,7 @@
 	 it's possible to get a quotient larger than limit; discarding
 	 these values eliminates the bias that would otherwise appear
 	 when using a large limit.  */
-      denominator = ((unsigned long)1 << VALBITS) / XINT (limit);
+      denominator = ((unsigned long)1 << INT_VALBITS) / XINT (limit);
       do
 	val = get_random () / denominator;
       while (val >= XINT (limit));
--- a/src/sysdep.c	Wed Apr 21 21:50:35 2004 +0000
+++ b/src/sysdep.c	Thu Apr 22 03:24:02 2004 +0000
@@ -3648,19 +3648,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 << VALBITS) - 1);
+  return val & (EMACS_INT) ((1UL << INT_VALBITS) - 1);
 }