summaryrefslogtreecommitdiffstats
path: root/lib/libc/sparc64/fpu/fpu_explode.c
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2005-05-27 10:00:22 +0000
committerstefanf <stefanf@FreeBSD.org>2005-05-27 10:00:22 +0000
commit194c67c3c8bad703f62d8f1294c11eb847764428 (patch)
treef6003ef89e1f08e9ae380f4c2ad6c2037e010ffc /lib/libc/sparc64/fpu/fpu_explode.c
parentb83d3b8bcc5ec80538880f65b3c34fd80e30bdea (diff)
downloadFreeBSD-src-194c67c3c8bad703f62d8f1294c11eb847764428.zip
FreeBSD-src-194c67c3c8bad703f62d8f1294c11eb847764428.tar.gz
Fix long (and long long) to long double, unsigned to long double and unsigned
long (and unsigned long long) to long double conversions. - Add a parameter that specifies the position of the sign bit to the _QP_TTOQ macro, previously it always looked at bit 31. Pass a negative number to disable sign inspection for unsigned types. This fixes _Qp_xtoq(), _Qp_uitoq() and _Qp_uxtoq(). - In the functions __fpu_itof() and __fpu_xtof(), look at the sign bit to decide whether we're doing a conversion from an unsigned type. If so, don't negate the mantissa if the integer exceeds the biggest signed number. PR: 55773 Patch by: Stephen Paskaluk (based upon) MFC after: 2 weeks
Diffstat (limited to 'lib/libc/sparc64/fpu/fpu_explode.c')
-rw-r--r--lib/libc/sparc64/fpu/fpu_explode.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/libc/sparc64/fpu/fpu_explode.c b/lib/libc/sparc64/fpu/fpu_explode.c
index 7c1f3eb..09f8908 100644
--- a/lib/libc/sparc64/fpu/fpu_explode.c
+++ b/lib/libc/sparc64/fpu/fpu_explode.c
@@ -101,7 +101,14 @@ __fpu_itof(fp, i)
* fpu_norm()'s handling of `supernormals'; see fpu_subr.c.
*/
fp->fp_exp = FP_LG;
- fp->fp_mant[0] = (int)i < 0 ? -i : i;
+ /*
+ * The sign bit decides whether i should be interpreted as
+ * a signed or unsigned entity.
+ */
+ if (fp->fp_sign && (int)i < 0)
+ fp->fp_mant[0] = -i;
+ else
+ fp->fp_mant[0] = i;
fp->fp_mant[1] = 0;
fp->fp_mant[2] = 0;
fp->fp_mant[3] = 0;
@@ -127,7 +134,14 @@ __fpu_xtof(fp, i)
* fpu_norm()'s handling of `supernormals'; see fpu_subr.c.
*/
fp->fp_exp = FP_LG2;
- *((int64_t*)fp->fp_mant) = (int64_t)i < 0 ? -i : i;
+ /*
+ * The sign bit decides whether i should be interpreted as
+ * a signed or unsigned entity.
+ */
+ if (fp->fp_sign && (int64_t)i < 0)
+ *((int64_t*)fp->fp_mant) = -i;
+ else
+ *((int64_t*)fp->fp_mant) = i;
fp->fp_mant[2] = 0;
fp->fp_mant[3] = 0;
__fpu_norm(fp);
OpenPOWER on IntegriCloud