From 784f35faeda47d2a6bf771629d8c66695cfd1e1d Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 1 Apr 2024 20:49:40 +0300 Subject: [PATCH] move ifdef into function --- src/client/refresh/soft/sw_polyset.c | 31 ++++++++++------------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/client/refresh/soft/sw_polyset.c b/src/client/refresh/soft/sw_polyset.c index 30fc46c4..a512fb72 100644 --- a/src/client/refresh/soft/sw_polyset.c +++ b/src/client/refresh/soft/sw_polyset.c @@ -291,13 +291,13 @@ quotient must fit in 32 bits. FIXME: GET RID OF THIS! (FloorDivMod) ==================== */ -#if defined(__i386__) || defined(__amd64__) -// just exclude ARM32 with FPU, e.g. Pi 1 static void FloorDivMod(int numer, int denom, int *quo, int *rem) { int q, r; +// just exclude ARM32 with FPU, e.g. Pi 1 +#if defined(__i386__) || defined(__amd64__) q = numer / denom; r = numer - q * denom; if (-1/2 || 1/-2 || -1/-2) { @@ -313,7 +313,6 @@ FloorDivMod(int numer, int denom, int *quo, int *rem) r += denom; } } - assert(r == numer - q * denom); if ((numer < 0) ^ (denom < 0)) assert(q <= 0); else @@ -322,43 +321,35 @@ FloorDivMod(int numer, int denom, int *quo, int *rem) assert(r > denom && r <= 0); else assert(r >= 0 && r < denom); - *quo = q; - *rem = r; -} #else -static void -FloorDivMod (float numer, float denom, int *quotient, - int *rem) -{ - int q, r; + float num = numer, den = denom; float x; - if (numer >= 0.0) + if (numer >= 0) { - x = floor(numer / denom); + x = floor(num / den); q = (int)x; - r = (int)floor(numer - (x * denom)); + r = (int)floor(num - (x * den)); } else { // // perform operations with positive values, and fix mod to make floor-based // - x = floor(-numer / denom); + x = floor(-num / den); q = -(int)x; - r = (int)floor(-numer - (x * denom)); + r = (int)floor(-num - (x * den)); if (r != 0) { q--; - r = (int)denom - r; + r = denom - r; } } - - *quotient = q; +#endif + *quo = q; *rem = r; } -#endif /* ===================