mirror of
https://github.com/RawAccelOfficial/rawaccel.git
synced 2025-05-11 10:26:58 +02:00
improve carry guard
This commit is contained in:
parent
9d6d76a571
commit
127002a5c9
1 changed files with 13 additions and 1 deletions
|
@ -31,6 +31,18 @@ struct {
|
|||
|
||||
extern "C" PULONG InitSafeBootMode;
|
||||
|
||||
// precise behavior required to handle NaN (UB with /fp:fast)
|
||||
#pragma float_control(precise, on, push)
|
||||
|
||||
static __forceinline
|
||||
bool
|
||||
ValidCarry(double x, double y)
|
||||
{
|
||||
return fabs(x) < 1 && fabs(y) < 1;
|
||||
}
|
||||
|
||||
#pragma float_control(pop)
|
||||
|
||||
__declspec(guard(ignore))
|
||||
VOID
|
||||
RawaccelCallback(
|
||||
|
@ -109,7 +121,7 @@ Arguments:
|
|||
double carry_x = carried_result_x - out_x;
|
||||
double carry_y = carried_result_y - out_y;
|
||||
|
||||
if (!ra::infnan(carry_x + carry_y)) {
|
||||
if (ValidCarry(carry_x, carry_y)) {
|
||||
devExt->carry.x = carry_x;
|
||||
devExt->carry.y = carry_y;
|
||||
it->LastX = out_x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue