mirror of
https://github.com/shadps4-emu/ext-SDL.git
synced 2026-01-31 00:55:22 +01:00
isfinite is not available on all platforms, so add a bitmasking alternative
Compiler Explorer shows both result in the same assembly.
This commit is contained in:
committed by
Anonymous Maarten
parent
f896e26f59
commit
a296c40867
@@ -15,6 +15,16 @@
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testautomation_suites.h"
|
||||
|
||||
static bool test_double_isfinite(double d)
|
||||
{
|
||||
union {
|
||||
Uint64 u64;
|
||||
double d;
|
||||
} d_u;
|
||||
d_u.d = d;
|
||||
return (d_u.u64 & 0x7ff0000000000000ULL) != 0x7ff0000000000000ULL;
|
||||
}
|
||||
|
||||
/* ================= Test Case Implementation ================== */
|
||||
|
||||
/* Fixture */
|
||||
@@ -1147,11 +1157,11 @@ static int SDLCALL audio_resampleLoss(void *arg)
|
||||
SDL_DestroyAudioStream(stream);
|
||||
SDL_free(buf_out);
|
||||
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite.");
|
||||
SDLTest_AssertCheck(test_double_isfinite(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(test_double_isfinite(sum_squared_error), "Sum of squared error should be finite.");
|
||||
/* Infinity is theoretically possible when there is very little to no noise */
|
||||
SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
|
||||
SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(test_double_isfinite(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(signal_to_noise >= spec->signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.",
|
||||
signal_to_noise, spec->signal_to_noise);
|
||||
SDLTest_AssertCheck(max_error <= spec->max_error, "Maximum conversion error %f should be no more than %f.",
|
||||
@@ -1440,11 +1450,11 @@ static int SDLCALL audio_formatChange(void *arg)
|
||||
}
|
||||
|
||||
signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite.");
|
||||
SDLTest_AssertCheck(test_double_isfinite(sum_squared_value), "Sum of squared target should be finite.");
|
||||
SDLTest_AssertCheck(test_double_isfinite(sum_squared_error), "Sum of squared error should be finite.");
|
||||
/* Infinity is theoretically possible when there is very little to no noise */
|
||||
SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN.");
|
||||
SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(test_double_isfinite(max_error), "Maximum conversion error should be finite.");
|
||||
SDLTest_AssertCheck(signal_to_noise >= target_signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.",
|
||||
signal_to_noise, target_signal_to_noise);
|
||||
SDLTest_AssertCheck(max_error <= target_max_error, "Maximum conversion error %f should be no more than %f.",
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#define ISFINITE(X) isfinite((float)(X))
|
||||
#define ISINF(X) isinf((float)(X))
|
||||
#define ISNAN(X) isnan((float)(X))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user