mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibC: Remove FE_TOMAXMAGNITUDE
It's non-standard (and a serenity-only extension, not something in common use), unused, and riscv-only.
This commit is contained in:
1 parent
3249f49b1e
commit
f9699604d8
6 files changed
+4
-48
No files matched your search
@@ -11,10 +11,6 @@
|
||||
|
||||
static constexpr auto reset_rounding_mode = [] { fesetround(FE_TONEAREST); };
|
||||
|
||||
#if !ARCH(RISCV64)
|
||||
# define TOMAXMAGNITUDE_DECAYS_TO_TONEAREST
|
||||
#endif
|
||||
|
||||
TEST_CASE(float_round_up)
|
||||
{
|
||||
// Non-default rounding mode should not escape files with -frounding-math.
|
||||
@@ -65,23 +61,6 @@ TEST_CASE(float_round_to_nearest)
|
||||
EXPECT_EQ(1.f + 5.9604645e-08f, 1.f);
|
||||
}
|
||||
|
||||
TEST_CASE(float_round_to_max_magnitude)
|
||||
{
|
||||
ScopeGuard rounding_mode_guard = reset_rounding_mode;
|
||||
|
||||
fesetround(FE_TOMAXMAGNITUDE);
|
||||
EXPECT_EQ(0.1f + 0.2f, 0.3f);
|
||||
EXPECT_EQ(0.1f + 0.3f, 0.4f);
|
||||
EXPECT_EQ(0.1f + 0.4f, 0.5f);
|
||||
EXPECT_EQ(-1.f + -0.1f, -1.1f);
|
||||
EXPECT_EQ(1.f + 0.1f, 1.1f);
|
||||
#ifdef TOMAXMAGNITUDE_DECAYS_TO_TONEAREST
|
||||
EXPECT_EQ(1.f + 5.9604645e-08f, 1.f);
|
||||
#else
|
||||
EXPECT_EQ(1.f + 5.9604645e-08f, 1.0000001f);
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE(store_round_in_env)
|
||||
{
|
||||
ScopeGuard rounding_mode_guard = reset_rounding_mode;
|
||||
@@ -110,12 +89,4 @@ TEST_CASE(save_restore_round)
|
||||
EXPECT_EQ(-1.f + -0.1f, -1.0999999f);
|
||||
fesetround(rounding_mode);
|
||||
EXPECT_EQ(-1.f + -0.1f, -1.1f);
|
||||
|
||||
fesetround(FE_TOMAXMAGNITUDE);
|
||||
#ifdef TOMAXMAGNITUDE_DECAYS_TO_TONEAREST
|
||||
// Max-magnitude rounding is not supported by x86, so we expect fesetround to decay it to some other rounding mode.
|
||||
EXPECT_EQ(fegetround(), FE_TONEAREST);
|
||||
#else
|
||||
EXPECT_EQ(fegetround(), FE_TOMAXMAGNITUDE);
|
||||
#endif
|
||||
}
|
||||
@@ -133,12 +133,9 @@ int fegetround()
|
||||
|
||||
int fesetround(int rounding_mode)
|
||||
{
|
||||
if (rounding_mode < FE_TONEAREST || rounding_mode > FE_TOMAXMAGNITUDE)
|
||||
if (rounding_mode < FE_TONEAREST || rounding_mode > FE_TOWARDZERO)
|
||||
return 1;
|
||||
|
||||
if (rounding_mode == FE_TOMAXMAGNITUDE)
|
||||
rounding_mode = FE_TONEAREST;
|
||||
|
||||
set_rounding_mode(rmode_from_feround(rounding_mode));
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -43,8 +43,6 @@ static RoundingMode frm_from_feround(int c_rounding_mode)
|
||||
return RoundingMode::RDN;
|
||||
case FE_UPWARD:
|
||||
return RoundingMode::RUP;
|
||||
case FE_TOMAXMAGNITUDE:
|
||||
return RoundingMode::RMM;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
@@ -62,7 +60,7 @@ static int feround_from_frm(RoundingMode frm)
|
||||
case RoundingMode::RUP:
|
||||
return FE_UPWARD;
|
||||
case RoundingMode::RMM:
|
||||
return FE_TOMAXMAGNITUDE;
|
||||
VERIFY_NOT_REACHED();
|
||||
default:
|
||||
// DYN is invalid in the frm register and therefore should never appear here.
|
||||
case RoundingMode::DYN:
|
||||
@@ -220,7 +218,7 @@ int fegetround()
|
||||
|
||||
int fesetround(int rounding_mode)
|
||||
{
|
||||
if (rounding_mode < FE_TONEAREST || rounding_mode > FE_TOMAXMAGNITUDE)
|
||||
if (rounding_mode < FE_TONEAREST || rounding_mode > FE_TOWARDZERO)
|
||||
return 1;
|
||||
|
||||
auto frm = frm_from_feround(rounding_mode);
|
||||
|
||||
@@ -117,12 +117,9 @@ int fegetround()
|
||||
|
||||
int fesetround(int rounding_mode)
|
||||
{
|
||||
if (rounding_mode < FE_TONEAREST || rounding_mode > FE_TOMAXMAGNITUDE)
|
||||
if (rounding_mode < FE_TONEAREST || rounding_mode > FE_TOWARDZERO)
|
||||
return 1;
|
||||
|
||||
if (rounding_mode == FE_TOMAXMAGNITUDE)
|
||||
rounding_mode = FE_TONEAREST;
|
||||
|
||||
auto control_word = read_control_word();
|
||||
|
||||
control_word &= ~(3 << 10);
|
||||
|
||||
@@ -38,8 +38,6 @@ int feraiseexcept(int exceptions);
|
||||
#define FE_DOWNWARD 1
|
||||
#define FE_UPWARD 2
|
||||
#define FE_TOWARDZERO 3
|
||||
// Only exists in RISC-V at the moment; on other architectures this is replaced with FE_TONEAREST.
|
||||
#define FE_TOMAXMAGNITUDE 4
|
||||
|
||||
int fesetround(int round);
|
||||
int fegetround(void);
|
||||
|
||||
@@ -58,8 +58,6 @@ enum class RoundingMode {
|
||||
Up = FE_UPWARD,
|
||||
Down = FE_DOWNWARD,
|
||||
ToEven = FE_TONEAREST,
|
||||
// Round to nearest, ties away from zero.
|
||||
ToMaxMagnitude = FE_TOMAXMAGNITUDE,
|
||||
};
|
||||
|
||||
// This is much branchier than it really needs to be
|
||||
@@ -126,9 +124,6 @@ static FloatType internal_to_integer(FloatType x, RoundingMode rounding_mode)
|
||||
break;
|
||||
case RoundingMode::ToZero:
|
||||
break;
|
||||
case RoundingMode::ToMaxMagnitude:
|
||||
should_round = true;
|
||||
break;
|
||||
}
|
||||
|
||||
auto result = extractor.to_float();
|
||||
|
||||
Reference in new issue
Block a user