Source-Changes-HG archive

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

[src/trunk]: src/sys/lib/libkern Sync with libc/quad:



details:   https://anonhg.NetBSD.org/src/rev/5b02d781d3b5
branches:  trunk
changeset: 538433:5b02d781d3b5
user:      scw <scw%NetBSD.org@localhost>
date:      Sun Oct 20 10:17:14 2002 +0000

description:
Sync with libc/quad:

As discussed (briefly) on tech-userlevel, fix our quad support to work
correctly on LP64 platforms. This is mostly just s/long/int/ in the
appropriate places.

diffstat:

 sys/lib/libkern/adddi3.c  |   6 +++---
 sys/lib/libkern/ashldi3.c |  10 +++++-----
 sys/lib/libkern/ashrdi3.c |  16 ++++++++--------
 sys/lib/libkern/lshldi3.c |  10 +++++-----
 sys/lib/libkern/lshrdi3.c |  10 +++++-----
 sys/lib/libkern/muldi3.c  |  38 +++++++++++++++++++-------------------
 sys/lib/libkern/qdivrem.c |  30 +++++++++++++++---------------
 sys/lib/libkern/quad.h    |  28 ++++++++++++++--------------
 sys/lib/libkern/subdi3.c  |   6 +++---
 9 files changed, 77 insertions(+), 77 deletions(-)

diffs (truncated from 485 to 300 lines):

diff -r 87004a3d25c8 -r 5b02d781d3b5 sys/lib/libkern/adddi3.c
--- a/sys/lib/libkern/adddi3.c  Sun Oct 20 10:15:47 2002 +0000
+++ b/sys/lib/libkern/adddi3.c  Sun Oct 20 10:17:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adddi3.c,v 1.6 1998/03/27 01:29:58 cgd Exp $   */
+/*     $NetBSD: adddi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $   */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)adddi3.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: adddi3.c,v 1.6 1998/03/27 01:29:58 cgd Exp $");
+__RCSID("$NetBSD: adddi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -50,7 +50,7 @@
 
 /*
  * Add two quads.  This is trivial since a one-bit carry from a single
- * u_long addition x+y occurs if and only if the sum x+y is less than
+ * u_int addition x+y occurs if and only if the sum x+y is less than
  * either x or y (the choice to compare with x or y is arbitrary).
  */
 quad_t
diff -r 87004a3d25c8 -r 5b02d781d3b5 sys/lib/libkern/ashldi3.c
--- a/sys/lib/libkern/ashldi3.c Sun Oct 20 10:15:47 2002 +0000
+++ b/sys/lib/libkern/ashldi3.c Sun Oct 20 10:17:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ashldi3.c,v 1.6 1998/03/27 01:29:58 cgd Exp $  */
+/*     $NetBSD: ashldi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ashldi3.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: ashldi3.c,v 1.6 1998/03/27 01:29:58 cgd Exp $");
+__RCSID("$NetBSD: ashldi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -62,12 +62,12 @@
        if (shift == 0)
                return(a);
        aa.q = a;
-       if (shift >= LONG_BITS) {
-               aa.ul[H] = aa.ul[L] << (shift - LONG_BITS);
+       if (shift >= INT_BITS) {
+               aa.ul[H] = aa.ul[L] << (shift - INT_BITS);
                aa.ul[L] = 0;
        } else {
                aa.ul[H] = (aa.ul[H] << shift) |
-                   (aa.ul[L] >> (LONG_BITS - shift));
+                   (aa.ul[L] >> (INT_BITS - shift));
                aa.ul[L] <<= shift;
        }
        return (aa.q);
diff -r 87004a3d25c8 -r 5b02d781d3b5 sys/lib/libkern/ashrdi3.c
--- a/sys/lib/libkern/ashrdi3.c Sun Oct 20 10:15:47 2002 +0000
+++ b/sys/lib/libkern/ashrdi3.c Sun Oct 20 10:17:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ashrdi3.c,v 1.7 1999/09/10 13:21:15 drochner Exp $     */
+/*     $NetBSD: ashrdi3.c,v 1.8 2002/10/20 10:17:14 scw Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ashrdi3.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: ashrdi3.c,v 1.7 1999/09/10 13:21:15 drochner Exp $");
+__RCSID("$NetBSD: ashrdi3.c,v 1.8 2002/10/20 10:17:14 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -61,24 +61,24 @@
        if (shift == 0)
                return(a);
        aa.q = a;
-       if (shift >= LONG_BITS) {
-               long s;
+       if (shift >= INT_BITS) {
+               int s;
 
                /*
                 * Smear bits rightward using the machine's right-shift
                 * method, whether that is sign extension or zero fill,
                 * to get the `sign word' s.  Note that shifting by
-                * LONG_BITS is undefined, so we shift (LONG_BITS-1),
+                * INT_BITS is undefined, so we shift (INT_BITS-1),
                 * then 1 more, to get our answer.
                 */
                /* LINTED inherits machine dependency */
-               s = (aa.sl[H] >> (LONG_BITS - 1)) >> 1;
+               s = (aa.sl[H] >> (INT_BITS - 1)) >> 1;
                /* LINTED inherits machine dependency*/
-               aa.ul[L] = aa.sl[H] >> (shift - LONG_BITS);
+               aa.ul[L] = aa.sl[H] >> (shift - INT_BITS);
                aa.ul[H] = s;
        } else {
                aa.ul[L] = (aa.ul[L] >> shift) |
-                   (aa.ul[H] << (LONG_BITS - shift));
+                   (aa.ul[H] << (INT_BITS - shift));
                /* LINTED inherits machine dependency */
                aa.sl[H] >>= shift;
        }
diff -r 87004a3d25c8 -r 5b02d781d3b5 sys/lib/libkern/lshldi3.c
--- a/sys/lib/libkern/lshldi3.c Sun Oct 20 10:15:47 2002 +0000
+++ b/sys/lib/libkern/lshldi3.c Sun Oct 20 10:17:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lshldi3.c,v 1.6 1998/03/27 01:30:03 cgd Exp $  */
+/*     $NetBSD: lshldi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)lshldi3.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: lshldi3.c,v 1.6 1998/03/27 01:30:03 cgd Exp $");
+__RCSID("$NetBSD: lshldi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -62,12 +62,12 @@
        if (shift == 0)
                return(a);
        aa.q = a;
-       if (shift >= LONG_BITS) {
-               aa.ul[H] = aa.ul[L] << (shift - LONG_BITS);
+       if (shift >= INT_BITS) {
+               aa.ul[H] = aa.ul[L] << (shift - INT_BITS);
                aa.ul[L] = 0;
        } else {
                aa.ul[H] = (aa.ul[H] << shift) |
-                   (aa.ul[L] >> (LONG_BITS - shift));
+                   (aa.ul[L] >> (INT_BITS - shift));
                aa.ul[L] <<= shift;
        }
        return (aa.q);
diff -r 87004a3d25c8 -r 5b02d781d3b5 sys/lib/libkern/lshrdi3.c
--- a/sys/lib/libkern/lshrdi3.c Sun Oct 20 10:15:47 2002 +0000
+++ b/sys/lib/libkern/lshrdi3.c Sun Oct 20 10:17:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lshrdi3.c,v 1.6 1998/03/27 01:30:03 cgd Exp $  */
+/*     $NetBSD: lshrdi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)lshrdi3.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: lshrdi3.c,v 1.6 1998/03/27 01:30:03 cgd Exp $");
+__RCSID("$NetBSD: lshrdi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -61,12 +61,12 @@
        if (shift == 0)
                return(a);
        aa.q = a;
-       if (shift >= LONG_BITS) {
-               aa.ul[L] = aa.ul[H] >> (shift - LONG_BITS);
+       if (shift >= INT_BITS) {
+               aa.ul[L] = aa.ul[H] >> (shift - INT_BITS);
                aa.ul[H] = 0;
        } else {
                aa.ul[L] = (aa.ul[L] >> shift) |
-                   (aa.ul[H] << (LONG_BITS - shift));
+                   (aa.ul[H] << (INT_BITS - shift));
                aa.ul[H] >>= shift;
        }
        return (aa.q);
diff -r 87004a3d25c8 -r 5b02d781d3b5 sys/lib/libkern/muldi3.c
--- a/sys/lib/libkern/muldi3.c  Sun Oct 20 10:15:47 2002 +0000
+++ b/sys/lib/libkern/muldi3.c  Sun Oct 20 10:17:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: muldi3.c,v 1.6 1998/03/27 01:30:05 cgd Exp $   */
+/*     $NetBSD: muldi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $   */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)muldi3.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: muldi3.c,v 1.6 1998/03/27 01:30:05 cgd Exp $");
+__RCSID("$NetBSD: muldi3.c,v 1.7 2002/10/20 10:17:14 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -54,7 +54,7 @@
  * Our algorithm is based on the following.  Split incoming quad values
  * u and v (where u,v >= 0) into
  *
- *     u = 2^n u1  *  u0       (n = number of bits in `u_long', usu. 32)
+ *     u = 2^n u1  *  u0       (n = number of bits in `u_int', usu. 32)
  *
  * and 
  *
@@ -85,9 +85,9 @@
  *
  * This algorithm is from Knuth vol. 2 (2nd ed), section 4.3.3, p. 278.
  *
- * Since C does not give us a `long * long = quad' operator, we split
- * our input quads into two longs, then split the two longs into two
- * shorts.  We can then calculate `short * short = long' in native
+ * Since C does not give us a `int * int = quad' operator, we split
+ * our input quads into two ints, then split the two ints into two
+ * shorts.  We can then calculate `short * short = int' in native
  * arithmetic.
  *
  * Our product should, strictly speaking, be a `long quad', with 128
@@ -105,14 +105,14 @@
  * of 2^n in either one will also vanish.  Only `low' need be computed
  * mod 2^2n, and only because of the final term above.
  */
-static quad_t __lmulq(u_long, u_long);
+static quad_t __lmulq(u_int, u_int);
 
 quad_t
 __muldi3(a, b)
        quad_t a, b;
 {
        union uu u, v, low, prod;
-       u_long high, mid, udiff, vdiff;
+       u_int high, mid, udiff, vdiff;
        int negall, negmid;
 #define        u1      u.ul[H]
 #define        u0      u.ul[L]
@@ -122,7 +122,7 @@
        /*
         * Get u and v such that u, v >= 0.  When this is finished,
         * u1, u0, v1, and v0 will be directly accessible through the
-        * longword fields.
+        * int fields.
         */
        if (a >= 0)
                u.q = a, negall = 0;
@@ -145,7 +145,7 @@
                 * Compute the three intermediate products, remembering
                 * whether the middle term is negative.  We can discard
                 * any upper bits in high and mid, so we can use native
-                * u_long * u_long => u_long arithmetic.
+                * u_int * u_int => u_int arithmetic.
                 */
                low.q = __lmulq(u0, v0);
 
@@ -176,27 +176,27 @@
 }
 
 /*
- * Multiply two 2N-bit longs to produce a 4N-bit quad, where N is half
- * the number of bits in a long (whatever that is---the code below
+ * Multiply two 2N-bit ints to produce a 4N-bit quad, where N is half
+ * the number of bits in an int (whatever that is---the code below
  * does not care as long as quad.h does its part of the bargain---but
  * typically N==16).
  *
  * We use the same algorithm from Knuth, but this time the modulo refinement
- * does not apply.  On the other hand, since N is half the size of a long,
+ * does not apply.  On the other hand, since N is half the size of an int,
  * we can get away with native multiplication---none of our input terms
- * exceeds (ULONG_MAX >> 1).
+ * exceeds (UINT_MAX >> 1).
  *
- * Note that, for u_long l, the quad-precision result
+ * Note that, for u_int l, the quad-precision result
  *
  *     l << N
  *
- * splits into high and low longs as HHALF(l) and LHUP(l) respectively.
+ * splits into high and low ints as HHALF(l) and LHUP(l) respectively.
  */
 static quad_t
-__lmulq(u_long u, u_long v)
+__lmulq(u_int u, u_int v)
 {
-       u_long u1, u0, v1, v0, udiff, vdiff, high, mid, low;
-       u_long prodh, prodl, was;
+       u_int u1, u0, v1, v0, udiff, vdiff, high, mid, low;
+       u_int prodh, prodl, was;
        union uu prod;
        int neg;
 
diff -r 87004a3d25c8 -r 5b02d781d3b5 sys/lib/libkern/qdivrem.c
--- a/sys/lib/libkern/qdivrem.c Sun Oct 20 10:15:47 2002 +0000
+++ b/sys/lib/libkern/qdivrem.c Sun Oct 20 10:17:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: qdivrem.c,v 1.8 2000/12/12 17:44:04 mycroft Exp $      */
+/*     $NetBSD: qdivrem.c,v 1.9 2002/10/20 10:17:14 scw Exp $  */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@



Home | Main Index | Thread Index | Old Index