Module: wine Branch: master Commit: c449da64e18b70914ff0da6b3fb55530ee369faa URL: https://gitlab.winehq.org/wine/wine/-/commit/c449da64e18b70914ff0da6b3fb5553...
Author: Jeff Smith whydoubt@gmail.com Date: Wed Aug 2 22:39:03 2023 -0500
d3dx9_36/tests: Use compare_uint() in compare_float() instead of abs().
The result of abs(INT_MIN) is INT_MIN, which breaks the ulps comparison.
---
dlls/d3dx9_36/tests/effect.c | 12 ++++++++---- dlls/d3dx9_36/tests/math.c | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index aed30118a44..edc35235c3e 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -23,6 +23,13 @@ #include "d3dx9.h"
/* helper functions */ +static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff) +{ + unsigned int diff = x > y ? x - y : y - x; + + return diff <= max_diff; +} + static BOOL compare_float(FLOAT f, FLOAT g, UINT ulps) { INT x = *(INT *)&f; @@ -33,10 +40,7 @@ static BOOL compare_float(FLOAT f, FLOAT g, UINT ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
static inline INT get_int(D3DXPARAMETER_TYPE type, const void *data) diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c index 5d112bd4b92..79f02e6536e 100644 --- a/dlls/d3dx9_36/tests/math.c +++ b/dlls/d3dx9_36/tests/math.c @@ -24,6 +24,13 @@ #include <math.h> #include <stdint.h>
+static BOOL compare_uint(unsigned int x, unsigned int y, unsigned int max_diff) +{ + unsigned int diff = x > y ? x - y : y - x; + + return diff <= max_diff; +} + static BOOL compare_float(float f, float g, unsigned int ulps) { int x = *(int *)&f; @@ -34,10 +41,7 @@ static BOOL compare_float(float f, float g, unsigned int ulps) if (y < 0) y = INT_MIN - y;
- if (abs(x - y) > ulps) - return FALSE; - - return TRUE; + return compare_uint(x, y, ulps); }
static BOOL compare_vec2(const D3DXVECTOR2 *v1, const D3DXVECTOR2 *v2, unsigned int ulps)