@@ -46,6 +46,12 @@ union double_long {
UDItype_x ll;
};
+static __inline__ void
+fexceptdiv (float d, float e)
+{
+ __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
+}
+
DItype_x __fixdfdi (double a1);
/* convert double to int */
@@ -73,7 +79,11 @@ __fixdfdi (double a1)
/* NaN */
if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
- return 0x8000000000000000ULL;
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0x8000000000000000ULL;
+ }
/* Number big number & +/- inf */
@@ -81,6 +91,8 @@ __fixdfdi (double a1)
l = (long long)1<<63;
if (!SIGND(dl1))
l--;
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
return l;
}
@@ -43,6 +43,12 @@ union float_long
USItype_x l;
};
+static __inline__ void
+fexceptdiv (float d, float e)
+{
+ __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
+}
+
DItype_x __fixsfdi (float a1);
/* convert double to int */
@@ -70,7 +76,11 @@ __fixsfdi (float a1)
/* NaN */
if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
- return 0x8000000000000000ULL;
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0x8000000000000000ULL;
+ }
/* Number big number & +/- inf */
@@ -78,6 +88,8 @@ __fixsfdi (float a1)
l = (long long)1<<63;
if (!SIGN(fl1))
l--;
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
return l;
}
@@ -50,6 +50,12 @@ union double_long {
UDItype_x ll[2]; /* 64 bit parts: 0 upper, 1 lower */
};
+static __inline__ void
+fexceptdiv (float d, float e)
+{
+ __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
+}
+
DItype_x __fixtfdi (long double a1);
/* convert double to unsigned int */
@@ -77,7 +83,11 @@ __fixtfdi (long double a1)
/* NaN: All exponent bits set and a nonzero fraction. */
if ((EXPD(dl1) == 0x7fff) && !FRACD_ZERO_P (dl1))
- return 0x8000000000000000ULL;
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0x8000000000000000ULL;
+ }
/* One extra bit is needed for the unit bit which is appended by
MANTD_HIGH_LL on the left of the matissa. */
@@ -90,6 +100,8 @@ __fixtfdi (long double a1)
or more. */
if (exp >= 0)
{
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
l = 1ULL << 63; /* long long min */
return SIGND (dl1) ? l : l - 1;
}
@@ -46,6 +46,12 @@ union double_long {
UDItype_x ll;
};
+static __inline__ void
+fexceptdiv (float d, float e)
+{
+ __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
+}
+
UDItype_x __fixunsdfdi (double a1);
/* convert double to unsigned int */
@@ -73,13 +79,20 @@ __fixunsdfdi (double a1)
/* NaN */
if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
- return 0x0ULL;
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0x0ULL;
+ }
/* Number big number & + inf */
- if (exp >= 12) {
- return 0xFFFFFFFFFFFFFFFFULL;
- }
+ if (exp >= 12)
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0xFFFFFFFFFFFFFFFFULL;
+ }
l = MANTD_LL(dl1);
@@ -43,6 +43,12 @@ union float_long
USItype_x l;
};
+static __inline__ void
+fexceptdiv (float d, float e)
+{
+ __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
+}
+
UDItype_x __fixunssfdi (float a1);
/* convert float to unsigned int */
@@ -70,13 +76,20 @@ __fixunssfdi (float a1)
/* NaN */
if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
- return 0x0ULL;
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0x0ULL;
+ }
/* Number big number & + inf */
- if (exp >= 41) {
- return 0xFFFFFFFFFFFFFFFFULL;
- }
+ if (exp >= 41)
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0xFFFFFFFFFFFFFFFFULL;
+ }
l = MANT(fl1);
@@ -50,6 +50,12 @@ union double_long {
UDItype_x ll[2]; /* 64 bit parts: 0 upper, 1 lower */
};
+static __inline__ void
+fexceptdiv (float d, float e)
+{
+ __asm__ __volatile__ ("debr %0,%1" : : "f" (d), "f" (e) );
+}
+
UDItype_x __fixunstfdi (long double a1);
/* convert double to unsigned int */
@@ -78,16 +84,25 @@ __fixunstfdi (long double a1)
/* NaN: All exponent bits set and a nonzero fraction. */
if ((EXPD(dl1) == 0x7fff) && !FRACD_ZERO_P (dl1))
- return 0x0ULL;
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0x0ULL;
+ }
/* One extra bit is needed for the unit bit which is appended by
MANTD_HIGH_LL on the left of the matissa. */
exp += HIGH_LL_FRAC_BITS + 1;
- /* If the result would still need a left shift it will be too large
- to be represented. */
+ /* If the result would still need a left shift it will be too
+ large to be represented. Infinities have all exponent bits set
+ and will end up here as well. */
if (exp > 0)
- return 0xFFFFFFFFFFFFFFFFULL;
+ {
+ /* C99 Annex F.4 requires an "invalid" exception to be thrown. */
+ fexceptdiv (0.0, 0.0);
+ return 0xFFFFFFFFFFFFFFFFULL;
+ }
l = MANTD_LOW_LL (dl1) >> (HIGH_LL_FRAC_BITS + 1)
| MANTD_HIGH_LL (dl1) << (64 - (HIGH_LL_FRAC_BITS + 1));