about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-12-04 18:37:56 +0000
committerRoland McGrath <roland@gnu.org>1995-12-04 18:37:56 +0000
commitba848785bb048e7700555ef97c9d1fd3911a3da3 (patch)
tree646ee57c65b8d2231e235caa069d7fea634e8b64 /stdlib
parentc13a4f3dbd44ff03d85ad1ac35cca38c3f35d33c (diff)
downloadglibc-ba848785bb048e7700555ef97c9d1fd3911a3da3.tar.gz
glibc-ba848785bb048e7700555ef97c9d1fd3911a3da3.tar.xz
glibc-ba848785bb048e7700555ef97c9d1fd3911a3da3.zip
Updated from ../=mpn/gmp-1.910
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/gmp-impl.h20
-rw-r--r--stdlib/gmp.h11
-rw-r--r--stdlib/longlong.h88
3 files changed, 81 insertions, 38 deletions
diff --git a/stdlib/gmp-impl.h b/stdlib/gmp-impl.h
index 0d2a8fcede..2f0956d960 100644
--- a/stdlib/gmp-impl.h
+++ b/stdlib/gmp-impl.h
@@ -179,24 +179,22 @@ void _mp_default_free ();
    strings in base 2..36.  */
 struct bases
 {
-  /* Number of digits in the conversion base that always fits in
-     an mp_limb.  For example, for base 10 this is 10, since
-     2**32 = 4294967296 has ten digits.  */
+  /* Number of digits in the conversion base that always fits in an mp_limb.
+     For example, for base 10 on a machine where a mp_limb has 32 bits this
+     is 9, since 10**9 is the largest number that fits into a mp_limb.  */
   int chars_per_limb;
 
   /* log(2)/log(conversion_base) */
   float chars_per_bit_exactly;
 
-  /* big_base is conversion_base**chars_per_limb, i.e. the biggest
-     number that fits a word, built by factors of conversion_base.
-     Exception: For 2, 4, 8, etc, big_base is log2(base), i.e. the
-     number of bits used to represent each digit in the base.  */
+  /* base**chars_per_limb, i.e. the biggest number that fits a word, built by
+     factors of base.  Exception: For 2, 4, 8, etc, big_base is log2(base),
+     i.e. the number of bits used to represent each digit in the base.  */
   mp_limb big_base;
 
-  /* big_base_inverted is a BITS_PER_MP_LIMB bit approximation to
-     1/big_base, represented as a fixed-point number.  Instead of
-     dividing by big_base an application can choose to multiply
-     by big_base_inverted.  */
+  /* A BITS_PER_MP_LIMB bit approximation to 1/big_base, represented as a
+     fixed-point number.  Instead of dividing by big_base an application can
+     choose to multiply by big_base_inverted.  */
   mp_limb big_base_inverted;
 };
 
diff --git a/stdlib/gmp.h b/stdlib/gmp.h
index 0b2cb29014..243779996d 100644
--- a/stdlib/gmp.h
+++ b/stdlib/gmp.h
@@ -23,6 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 #ifndef __GNU_MP__
 #define __need_size_t
 #include <stddef.h>
+#undef __need_size_t
 
 #if defined (__STDC__)
 #define __gmp_const const
@@ -40,7 +41,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 typedef unsigned int		mp_limb;
 typedef int			mp_limb_signed;
 #else
-#if _LONG_LONG_LIMB
+#ifdef _LONG_LONG_LIMB
 typedef unsigned long long int	mp_limb;
 typedef long long int		mp_limb_signed;
 #else
@@ -110,11 +111,11 @@ typedef __mpq_struct mpq_t[1];
 
 typedef struct
 {
-  mp_size_t alloc;		/* Number of *limbs* allocated and pointed
-				   to by the D field.  */
   mp_size_t prec;		/* Max precision, in number of `mp_limb's.
 				   Set by mpf_init and modified by
-				   mpf_set_prec.  */
+				   mpf_set_prec.  The area pointed to
+				   by the `d' field contains `prec' + 1
+				   limbs.  */
   mp_size_t size;		/* abs(SIZE) is the number of limbs
 				   the last field points to.  If SIZE
 				   is negative this is a negative
@@ -127,7 +128,7 @@ typedef struct
 typedef __mpf_struct mpf_t[1];
 
 /* Types for function declarations in gmp files.  */
-/* ??? Should not pollute user name space ??? */
+/* ??? Should not pollute user name space with these ??? */
 typedef __gmp_const __mpz_struct *mpz_srcptr;
 typedef __mpz_struct *mpz_ptr;
 typedef __gmp_const __mpf_struct *mpf_srcptr;
diff --git a/stdlib/longlong.h b/stdlib/longlong.h
index bbb92e3af8..e52bf32dba 100644
--- a/stdlib/longlong.h
+++ b/stdlib/longlong.h
@@ -139,6 +139,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
     __asm__ ("clz %0,%1"						\
 	     : "=r" ((USItype)(count))					\
 	     : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
 #endif /* __a29k__ */
 
 #if defined (__alpha__) && W_TYPE_SIZE == 64
@@ -298,9 +299,9 @@ extern UDItype __udiv_qrnnd ();
 	   struct {USItype __h, __l;} __i;				\
 	  } __xx;							\
     __asm__ ("xmpyu %1,%2,%0"						\
-	     : "=fx" (__xx.__ll)					\
-	     : "fx" ((USItype)(u)),					\
-	       "fx" ((USItype)(v)));					\
+	     : "=*f" (__xx.__ll)					\
+	     : "*f" ((USItype)(u)),					\
+	       "*f" ((USItype)(v)));					\
     (wh) = __xx.__i.__h;						\
     (wl) = __xx.__i.__l;						\
   } while (0)
@@ -339,7 +340,7 @@ extern USItype __udiv_qrnnd ();
 	sub		%0,%1,%0		; Subtract it.
 	" : "=r" (count), "=r" (__tmp) : "1" (x));			\
   } while (0)
-#endif
+#endif /* hppa */
 
 #if (defined (__i370__) || defined (__mvs__)) && W_TYPE_SIZE == 32
 #define umul_ppmm(xh, xl, m0, m1) \
@@ -431,7 +432,29 @@ extern USItype __udiv_qrnnd ();
 #endif
 #endif /* 80x86 */
 
+#if defined (__i860__) && W_TYPE_SIZE == 32
+#define rshift_rhlc(r,h,l,c) \
+  __asm__ ("shr %3,r0,r0\;shrd %1,%2,%0"				\
+	   "=r" (r) : "r" (h), "r" (l), "rn" (c))
+#endif /* i860 */
+
 #if defined (__i960__) && W_TYPE_SIZE == 32
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+  __asm__ ("cmpo 1,0\;addc %5,%4,%1\;addc %3,%2,%0"			\
+	   : "=r" ((USItype)(sh)),					\
+	     "=&r" ((USItype)(sl))					\
+	   : "%dI" ((USItype)(ah)),					\
+	     "dI" ((USItype)(bh)),					\
+	     "%dI" ((USItype)(al)),					\
+	     "dI" ((USItype)(bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  __asm__ ("cmpo 0,0\;subc %5,%4,%1\;subc %3,%2,%0"			\
+	   : "=r" ((USItype)(sh)),					\
+	     "=&r" ((USItype)(sl))					\
+	   : "dI" ((USItype)(ah)),					\
+	     "dI" ((USItype)(bh)),					\
+	     "dI" ((USItype)(al)),					\
+	     "dI" ((USItype)(bl)))
 #define umul_ppmm(w1, w0, u, v) \
   ({union {UDItype __ll;						\
 	   struct {USItype __l, __h;} __i;				\
@@ -448,7 +471,39 @@ extern USItype __udiv_qrnnd ();
 	     : "%dI" ((USItype)(u)),					\
 	       "dI" ((USItype)(v)));					\
     __w; })  
-#endif /* __i960__ */
+#define udiv_qrnnd(q, r, nh, nl, d) \
+  do {									\
+    union {UDItype __ll;						\
+	   struct {USItype __l, __h;} __i;				\
+	  } __nn;							\
+    __nn.__i.__h = (nh); __nn.__i.__l = (nl);				\
+    __asm__ ("ediv %d,%n,%0"						\
+	   : "=d" (__rq.__ll)						\
+	   : "dI" (__nn.__ll),						\
+	     "dI" ((USItype)(d)));					\
+    (r) = __rq.__i.__l; (q) = __rq.__i.__h;				\
+  } while (0)
+#define count_leading_zeros(count, x) \
+  do {									\
+    USItype __cbtmp;							\
+    __asm__ ("scanbit %1,%0"						\
+	     : "=r" (__cbtmp)						\
+	     : "r" ((USItype)(x)));					\
+    (count) = __cbtmp ^ 31;						\
+  } while (0)
+#define COUNT_LEADING_ZEROS_0 (-32) /* sic */
+#if defined (__i960mx)		/* what is the proper symbol to test??? */
+#define rshift_rhlc(r,h,l,c) \
+  do {									\
+    union {UDItype __ll;						\
+	   struct {USItype __l, __h;} __i;				\
+	  } __nn;							\
+    __nn.__i.__h = (h); __nn.__i.__l = (l);				\
+    __asm__ ("shre %2,%1,%0"						\
+	     : "=d" (r) : "dI" (__nn.__ll), "dI" (c));			\
+  }
+#endif /* i960mx */
+#endif /* i960 */
 
 #if (defined (__mc68000__) || defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
@@ -469,7 +524,7 @@ extern USItype __udiv_qrnnd ();
 	     "d" ((USItype)(bh)),					\
 	     "1" ((USItype)(al)),					\
 	     "g" ((USItype)(bl)))
-#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020)) && W_TYPE_SIZE == 32
+#if (defined (__mc68020__) || defined (__NeXT__) || defined(mc68020))
 #define umul_ppmm(w1, w0, u, v) \
   __asm__ ("mulu%.l %3,%1:%0"						\
 	   : "=d" ((USItype)(w0)),					\
@@ -496,8 +551,9 @@ extern USItype __udiv_qrnnd ();
   __asm__ ("bfffo %1{%b2:%b2},%0"					\
 	   : "=d" ((USItype)(count))					\
 	   : "od" ((USItype)(x)), "n" (0))
+#define COUNT_LEADING_ZEROS_0 32
 #else /* not mc68020 */
-#define umul_ppmmxx(xh, xl, a, b) \
+#define umul_ppmm(xh, xl, a, b) \
   do { USItype __umul_tmp1, __umul_tmp2;				\
 	__asm__ ("| Inlined umul_ppmm
 	move%.l	%5,%3
@@ -557,6 +613,7 @@ extern USItype __udiv_qrnnd ();
 	     : "r" ((USItype)(x)));					\
     (count) = __cbtmp ^ 31;						\
   } while (0)
+#define COUNT_LEADING_ZEROS_0 63 /* sic */
 #if defined (__m88110__)
 #define umul_ppmm(wh, wl, u, v) \
   do {									\
@@ -738,6 +795,7 @@ extern USItype __udiv_qrnnd ();
   __asm__ ("{cntlz|cntlzw} %0,%1"					\
 	   : "=r" ((USItype)(count))					\
 	   : "r" ((USItype)(x)))
+#define COUNT_LEADING_ZEROS_0 32
 #if defined (_ARCH_PPC)
 #define umul_ppmm(ph, pl, m0, m1) \
   do {									\
@@ -887,7 +945,7 @@ extern USItype __udiv_qrnnd ();
 	(count) += 16;							\
       }									\
   } while (0)
-#endif
+#endif /* RT/ROMP */
 
 #if defined (__sh2__) && W_TYPE_SIZE == 32
 #define umul_ppmm(w1, w0, u, v) \
@@ -1154,20 +1212,6 @@ extern USItype __udiv_qrnnd ();
     (xh) += ((((signed int) __m0 >> 15) & __m1)				\
 	     + (((signed int) __m1 >> 15) & __m0));			\
   } while (0)
-#define umul_ppmm_off(xh, xl, m0, m1) \
-  do {									\
-    union {long int __ll;						\
-	   struct {unsigned int __h, __l;} __i;				\
-	  } __xx;							\
-    __asm__ ("mult	%S0,%H3"					\
-	     : "=r" (__xx.__i.__h),					\
-	       "=r" (__xx.__i.__l)					\
-	     : "%1" (m0),						\
-	       "rQR" (m1));						\
-    (xh) = __xx.__i.__h + ((((signed int) m0 >> 15) & m1)		\
-			   + (((signed int) m1 >> 15) & m0));		\
-    (xl) = __xx.__i.__l;						\
-  } while (0)
 #endif /* __z8000__ */
 
 #endif /* __GNUC__ */