Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/quad As discussed (briefly) on tech-userlevel, fix ...



details:   https://anonhg.NetBSD.org/src/rev/87004a3d25c8
branches:  trunk
changeset: 538432:87004a3d25c8
user:      scw <scw%NetBSD.org@localhost>
date:      Sun Oct 20 10:15:47 2002 +0000

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

diffstat:

 lib/libc/quad/TESTS/divrem.c |  16 ++++++++--------
 lib/libc/quad/TESTS/mul.c    |  14 +++++++-------
 lib/libc/quad/adddi3.c       |   6 +++---
 lib/libc/quad/ashldi3.c      |  10 +++++-----
 lib/libc/quad/ashrdi3.c      |  16 ++++++++--------
 lib/libc/quad/fixunsdfdi.c   |  10 +++++-----
 lib/libc/quad/fixunssfdi.c   |  20 ++++++++++----------
 lib/libc/quad/floatdidf.c    |   8 ++++----
 lib/libc/quad/floatdisf.c    |   8 ++++----
 lib/libc/quad/floatunsdidf.c |   6 +++---
 lib/libc/quad/lshldi3.c      |  10 +++++-----
 lib/libc/quad/lshrdi3.c      |  10 +++++-----
 lib/libc/quad/muldi3.c       |  38 +++++++++++++++++++-------------------
 lib/libc/quad/qdivrem.c      |  30 +++++++++++++++---------------
 lib/libc/quad/quad.h         |  28 ++++++++++++++--------------
 lib/libc/quad/subdi3.c       |   6 +++---
 16 files changed, 118 insertions(+), 118 deletions(-)

diffs (truncated from 777 to 300 lines):

diff -r 9670b4e67fc5 -r 87004a3d25c8 lib/libc/quad/TESTS/divrem.c
--- a/lib/libc/quad/TESTS/divrem.c      Sun Oct 20 06:26:39 2002 +0000
+++ b/lib/libc/quad/TESTS/divrem.c      Sun Oct 20 10:15:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: divrem.c,v 1.2 1995/02/27 17:31:30 cgd Exp $   */
+/*     $NetBSD: divrem.c,v 1.3 2002/10/20 10:15:48 scw Exp $   */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)divrem.c   8.1 (Berkeley) 6/4/93";
 #else
-static char rcsid[] = "$NetBSD: divrem.c,v 1.2 1995/02/27 17:31:30 cgd Exp $";
+static char rcsid[] = "$NetBSD: divrem.c,v 1.3 2002/10/20 10:15:48 scw Exp $";
 #endif
 #endif /* not lint */
 
@@ -55,7 +55,7 @@
 
 main()
 {
-       union { long long q; unsigned long v[2]; } a, b, q, r;
+       union { long long q; unsigned int v[2]; } a, b, q, r;
        char buf[300];
        extern long long __qdivrem(unsigned long long, unsigned long long,
            unsigned long long *);
@@ -64,19 +64,19 @@
                printf("> ");
                if (fgets(buf, sizeof buf, stdin) == NULL)
                        break;
-               if (sscanf(buf, "%lu:%lu %lu:%lu",
+               if (sscanf(buf, "%u:%u %u:%u",
                            &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 &&
-                   sscanf(buf, "0x%lx:%lx 0x%lx:%lx",
+                   sscanf(buf, "0x%x:%x 0x%x:%x",
                            &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) {
                        printf("eh?\n");
                        continue;
                }
                q.q = __qdivrem(a.q, b.q, &r.q);
-               printf("%lx:%lx /%% %lx:%lx => q=%lx:%lx r=%lx:%lx\n",
+               printf("%x:%x /%% %x:%x => q=%x:%x r=%x:%x\n",
                    a.v[0], a.v[1], b.v[0], b.v[1],
                    q.v[0], q.v[1], r.v[0], r.v[1]);
-               printf("  = %lX%08lX / %lX%08lX => %lX%08lX\n\
-  = %lX%08lX %% %lX%08lX => %lX%08lX\n",
+               printf("  = %X%08X / %X%08X => %X%08X\n\
+  = %X%08X %% %X%08X => %X%08X\n",
                    a.v[0], a.v[1], b.v[0], b.v[1], q.v[0], q.v[1],
                    a.v[0], a.v[1], b.v[0], b.v[1], r.v[0], r.v[1]);
        }
diff -r 9670b4e67fc5 -r 87004a3d25c8 lib/libc/quad/TESTS/mul.c
--- a/lib/libc/quad/TESTS/mul.c Sun Oct 20 06:26:39 2002 +0000
+++ b/lib/libc/quad/TESTS/mul.c Sun Oct 20 10:15:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mul.c,v 1.2 1995/02/27 17:31:34 cgd Exp $      */
+/*     $NetBSD: mul.c,v 1.3 2002/10/20 10:15:48 scw Exp $      */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)mul.c      8.1 (Berkeley) 6/4/93";
 #else
-static char rcsid[] = "$NetBSD: mul.c,v 1.2 1995/02/27 17:31:34 cgd Exp $";
+static char rcsid[] = "$NetBSD: mul.c,v 1.3 2002/10/20 10:15:48 scw Exp $";
 #endif
 #endif /* not lint */
 
@@ -55,7 +55,7 @@
 
 main()
 {
-       union { long long q; unsigned long v[2]; } a, b, m;
+       union { long long q; unsigned int v[2]; } a, b, m;
        char buf[300];
        extern long long __muldi3(long long, long long);
 
@@ -63,17 +63,17 @@
                printf("> ");
                if (fgets(buf, sizeof buf, stdin) == NULL)
                        break;
-               if (sscanf(buf, "%lu:%lu %lu:%lu",
+               if (sscanf(buf, "%u:%u %u:%u",
                            &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 &&
-                   sscanf(buf, "0x%lx:%lx 0x%lx:%lx",
+                   sscanf(buf, "0x%x:%x 0x%x:%x",
                            &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) {
                        printf("eh?\n");
                        continue;
                }
                m.q = __muldi3(a.q, b.q);
-               printf("%lx:%lx * %lx:%lx => %lx:%lx\n",
+               printf("%x:%x * %x:%x => %x:%x\n",
                    a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]);
-               printf("  = %lX%08lX * %lX%08lX => %lX%08lX\n",
+               printf("  = %X%08X * %X%08X => %X%08X\n",
                    a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]);
        }
        exit(0);
diff -r 9670b4e67fc5 -r 87004a3d25c8 lib/libc/quad/adddi3.c
--- a/lib/libc/quad/adddi3.c    Sun Oct 20 06:26:39 2002 +0000
+++ b/lib/libc/quad/adddi3.c    Sun Oct 20 10:15:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: adddi3.c,v 1.3 1997/07/13 20:01:39 christos Exp $      */
+/*     $NetBSD: adddi3.c,v 1.4 2002/10/20 10:15:47 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.3 1997/07/13 20:01:39 christos Exp $");
+__RCSID("$NetBSD: adddi3.c,v 1.4 2002/10/20 10:15:47 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 9670b4e67fc5 -r 87004a3d25c8 lib/libc/quad/ashldi3.c
--- a/lib/libc/quad/ashldi3.c   Sun Oct 20 06:26:39 2002 +0000
+++ b/lib/libc/quad/ashldi3.c   Sun Oct 20 10:15:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ashldi3.c,v 1.5 1998/01/29 03:23:40 mouse Exp $        */
+/*     $NetBSD: ashldi3.c,v 1.6 2002/10/20 10:15:47 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.5 1998/01/29 03:23:40 mouse Exp $");
+__RCSID("$NetBSD: ashldi3.c,v 1.6 2002/10/20 10:15:47 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 9670b4e67fc5 -r 87004a3d25c8 lib/libc/quad/ashrdi3.c
--- a/lib/libc/quad/ashrdi3.c   Sun Oct 20 06:26:39 2002 +0000
+++ b/lib/libc/quad/ashrdi3.c   Sun Oct 20 10:15:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ashrdi3.c,v 1.7 1999/09/10 12:53:10 drochner Exp $     */
+/*     $NetBSD: ashrdi3.c,v 1.8 2002/10/20 10:15:47 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 12:53:10 drochner Exp $");
+__RCSID("$NetBSD: ashrdi3.c,v 1.8 2002/10/20 10:15:47 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 9670b4e67fc5 -r 87004a3d25c8 lib/libc/quad/fixunsdfdi.c
--- a/lib/libc/quad/fixunsdfdi.c        Sun Oct 20 06:26:39 2002 +0000
+++ b/lib/libc/quad/fixunsdfdi.c        Sun Oct 20 10:15:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fixunsdfdi.c,v 1.5 1999/03/26 21:04:24 kristerw Exp $  */
+/*     $NetBSD: fixunsdfdi.c,v 1.6 2002/10/20 10:15:47 scw Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,13 +42,13 @@
 #if 0
 static char sccsid[] = "@(#)fixunsdfdi.c       8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fixunsdfdi.c,v 1.5 1999/03/26 21:04:24 kristerw Exp $");
+__RCSID("$NetBSD: fixunsdfdi.c,v 1.6 2002/10/20 10:15:47 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
 #include "quad.h"
 
-#define        ONE_FOURTH      ((long)1 << (LONG_BITS - 2))
+#define        ONE_FOURTH      ((int)1 << (INT_BITS - 2))
 #define        ONE_HALF        (ONE_FOURTH * 2.0)
 #define        ONE             (ONE_FOURTH * 4.0)
 
@@ -62,7 +62,7 @@
        double x;
 {
        union uu t;
-       unsigned long tmp;
+       unsigned int tmp;
 
        if (x < 0)
                return (UQUAD_MAX);     /* ??? should be 0?  ERANGE??? */
@@ -81,7 +81,7 @@
         * Furthermore, the quotient will fit into a 32-bit integer.
         */
        tmp = x / ONE;
-       t.ul[L] = (unsigned long) (x - tmp * ONE);
+       t.ul[L] = (unsigned int) (x - tmp * ONE);
        t.ul[H] = tmp;
        return (t.uq);
 }
diff -r 9670b4e67fc5 -r 87004a3d25c8 lib/libc/quad/fixunssfdi.c
--- a/lib/libc/quad/fixunssfdi.c        Sun Oct 20 06:26:39 2002 +0000
+++ b/lib/libc/quad/fixunssfdi.c        Sun Oct 20 10:15:47 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fixunssfdi.c,v 1.4 1997/07/13 20:01:45 christos Exp $  */
+/*     $NetBSD: fixunssfdi.c,v 1.5 2002/10/20 10:15:47 scw Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,13 +42,13 @@
 #if 0
 static char sccsid[] = "@(#)fixunssfdi.c       8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fixunssfdi.c,v 1.4 1997/07/13 20:01:45 christos Exp $");
+__RCSID("$NetBSD: fixunssfdi.c,v 1.5 2002/10/20 10:15:47 scw Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
 #include "quad.h"
 
-#define        ONE_FOURTH      ((long)1 << (LONG_BITS - 2))
+#define        ONE_FOURTH      ((int)1 << (INT_BITS - 2))
 #define        ONE_HALF        (ONE_FOURTH * 2.0)
 #define        ONE             (ONE_FOURTH * 4.0)
 
@@ -88,20 +88,20 @@
         * between x and this is the bottom part (this may introduce
         * a few fuzzy bits, but what the heck).  With any luck this
         * difference will be nonnegative: x should wind up in the
-        * range [0..ULONG_MAX].  For paranoia, we assume [LONG_MIN..
-        * 2*ULONG_MAX] instead.
+        * range [0..UINT_MAX].  For paranoia, we assume [INT_MIN..
+        * 2*UINT_MAX] instead.
         */
-       t.ul[H] = (unsigned long)toppart;
+       t.ul[H] = (unsigned int)toppart;
        t.ul[L] = 0;
        x -= (double)t.uq;
        if (x < 0) {
                t.ul[H]--;
-               x += ULONG_MAX;
+               x += UINT_MAX;
        }
-       if (x > ULONG_MAX) {
+       if (x > UINT_MAX) {
                t.ul[H]++;



Home | Main Index | Thread Index | Old Index