Message ID | 1521663109-32262-6-git-send-email-cota@braap.org |
---|---|
State | New |
Headers | show |
Series | fp-test + hostfloat | expand |
Emilio G. Cota <cota@braap.org> writes: > This paves the way for upcoming work. > > Signed-off-by: Emilio G. Cota <cota@braap.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> > --- > include/fpu/softfloat.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h > index 36626a5..7b9d31c 100644 > --- a/include/fpu/softfloat.h > +++ b/include/fpu/softfloat.h > @@ -402,6 +402,11 @@ static inline int float32_is_zero(float32 a) > return (float32_val(a) & 0x7fffffff) == 0; > } > > +static inline bool float32_is_normal(float32 a) > +{ > + return ((float32_val(a) + 0x00800000) & 0x7fffffff) >= 0x01000000; > +} > + > static inline int float32_is_any_nan(float32 a) > { > return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL); > @@ -531,6 +536,11 @@ static inline int float64_is_zero(float64 a) > return (float64_val(a) & 0x7fffffffffffffffLL) == 0; > } > > +static inline bool float64_is_normal(float64 a) > +{ > + return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53; > +} > + > static inline int float64_is_any_nan(float64 a) > { > return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL); -- Alex Bennée
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 36626a5..7b9d31c 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -402,6 +402,11 @@ static inline int float32_is_zero(float32 a) return (float32_val(a) & 0x7fffffff) == 0; } +static inline bool float32_is_normal(float32 a) +{ + return ((float32_val(a) + 0x00800000) & 0x7fffffff) >= 0x01000000; +} + static inline int float32_is_any_nan(float32 a) { return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL); @@ -531,6 +536,11 @@ static inline int float64_is_zero(float64 a) return (float64_val(a) & 0x7fffffffffffffffLL) == 0; } +static inline bool float64_is_normal(float64 a) +{ + return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53; +} + static inline int float64_is_any_nan(float64 a) { return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL);
This paves the way for upcoming work. Signed-off-by: Emilio G. Cota <cota@braap.org> --- include/fpu/softfloat.h | 10 ++++++++++ 1 file changed, 10 insertions(+)