summaryrefslogtreecommitdiff
path: root/mpz/set_d.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2003-10-31 22:53:43 +0100
committerKevin Ryde <user42@zip.com.au>2003-10-31 22:53:43 +0100
commit0202a23cf907f6c2177f89d584f1e96be8311501 (patch)
treee3599459ce1a81d2e5b5d5ebb5d4275d7ad95339 /mpz/set_d.c
parent94684c8b922b1850fb441c4c5fc5ac20128da6b5 (diff)
downloadgmp-0202a23cf907f6c2177f89d584f1e96be8311501.tar.gz
* mpz/set_d.c: Don't use a special case for d < MP_BASE_AS_DOUBLE, gcc
3.3 -mpowerpc64 on darwin gets ulonglong->double casts wrong.
Diffstat (limited to 'mpz/set_d.c')
-rw-r--r--mpz/set_d.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/mpz/set_d.c b/mpz/set_d.c
index 07b6ef83d..119bdcca9 100644
--- a/mpz/set_d.c
+++ b/mpz/set_d.c
@@ -28,6 +28,14 @@ MA 02111-1307, USA. */
#include "gmp.h"
#include "gmp-impl.h"
+
+/* We used to have a special case for d < MP_BASE_AS_DOUBLE, just casting
+ double -> limb. Unfortunately gcc 3.3 on powerpc970-apple-darwin6.8.5
+ got this wrong. (It assumed __fixunsdfdi returned its result in a single
+ 64-bit register, where instead that function followed the calling
+ conventions and gave the result in two parts r3 and r4.) Hence the use
+ of __gmp_extract_double in all cases. */
+
void
mpz_set_d (mpz_ptr r, double d)
{
@@ -43,16 +51,6 @@ mpz_set_d (mpz_ptr r, double d)
negative = d < 0;
d = ABS (d);
- /* Handle small arguments quickly. */
- if (d < MP_BASE_AS_DOUBLE)
- {
- mp_limb_t tmp;
- tmp = d;
- PTR(r)[0] = tmp;
- SIZ(r) = negative ? -(tmp != 0) : (tmp != 0);
- return;
- }
-
rn = __gmp_extract_double (tp, d);
if (ALLOC(r) < rn)
@@ -77,8 +75,10 @@ mpz_set_d (mpz_ptr r, double d)
rp[0] = tp[1];
break;
case 1:
- /* handled in "small aguments" case above */
- ASSERT_ALWAYS (0);
+ rp[0] = tp[2];
+ break;
+ case 0:
+ break;
}
#else
switch (rn)
@@ -91,8 +91,10 @@ mpz_set_d (mpz_ptr r, double d)
rp[1] = tp[1], rp[0] = tp[0];
break;
case 1:
- /* handled in "small aguments" case above */
- ASSERT_ALWAYS (0);
+ rp[0] = tp[1];
+ break;
+ case 0:
+ break;
}
#endif