From 507c5f75bd961e3d65ca02ce4a4e7991574312db Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 13 Feb 2024 10:39:27 +0100 Subject: [PATCH] revert a few things --- src/m_fixed.c | 4 ++-- src/m_fixed.h | 21 ++------------------- src/r_main.c | 14 +++++++------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/m_fixed.c b/src/m_fixed.c index 44baefae1..2da72fe05 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -23,7 +23,7 @@ #include "m_fixed.h" #include "tables.h" // ANGLETOFINESHIFT -FUNCINLINE ATTRINLINE fixed_t FixedSqrt(fixed_t x) +fixed_t FixedSqrt(fixed_t x) { #ifdef HAVE_SQRT const float fx = FIXED_TO_FLOAT(x); @@ -61,7 +61,7 @@ FUNCINLINE ATTRINLINE fixed_t FixedSqrt(fixed_t x) #endif } -FUNCINLINE ATTRINLINE fixed_t FixedHypot(fixed_t x, fixed_t y) +fixed_t FixedHypot(fixed_t x, fixed_t y) { // Moved the code from R_PointToDist2 to here, // since R_PointToDist2 did the same thing, diff --git a/src/m_fixed.h b/src/m_fixed.h index dc240013e..80fe660dd 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -41,13 +41,7 @@ typedef UINT32 ufixed_t; FUNCMATH FUNCINLINE static ATTRINLINE float FixedToFloat(fixed_t x) { -#if defined(_WIN32) && defined(__MINGW64__) - __m128 divisor = _mm_set1_ps((float)FRACUNIT); - __m128 result = _mm_div_ps(_mm_cvtepi32_ps(_mm_set1_epi32(x)), divisor); - return _mm_cvtss_f32(result); -#else return x / (float)FRACUNIT; -#endif } FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f) @@ -69,20 +63,9 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FloatToFixed(float f) */ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedMul(fixed_t a, fixed_t b) { -#if defined(_WIN32) && defined(__MINGW64__) - int32_t a_int = (int32_t)a; - int32_t b_int = (int32_t)b; - - int64_t result_int = _mul128(a_int, b_int, NULL); - - result_int >>= FRACBITS; - - fixed_t result = (fixed_t)result_int; - - return result; -#else + // Need to cast to unsigned before shifting to avoid undefined behaviour + // for negative integers return (fixed_t)(((UINT64)((INT64)a * b)) >> FRACBITS); -#endif } /** \brief The FixedDiv2 function diff --git a/src/r_main.c b/src/r_main.c index 2d9e687f9..06c7fdfe7 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -333,8 +333,7 @@ static void FlipCam4_OnChange(void) // // killough 5/2/98: reformatted // - -FUNCINLINE ATTRINLINE INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) +INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) { if (!node->dx) return x <= node->x ? node->dy > 0 : node->dy < 0; @@ -353,7 +352,7 @@ FUNCINLINE ATTRINLINE INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict } // killough 5/2/98: reformatted -FUNCINLINE ATTRINLINE INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) +INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) { fixed_t lx = line->v1->x; fixed_t ly = line->v1->y; @@ -388,7 +387,7 @@ FUNCINLINE ATTRINLINE INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) // // killough 5/2/98: reformatted, cleaned up -FUNCINLINE ATTRINLINE angle_t R_PointToAngle(fixed_t x, fixed_t y) +angle_t R_PointToAngle(fixed_t x, fixed_t y) { return (y -= viewy, (x -= viewx) || y) ? x >= 0 ? @@ -492,7 +491,7 @@ fixed_t R_PointToDist(fixed_t x, fixed_t y) return R_PointToDist2(viewx, viewy, x, y); } -FUNCINLINE ATTRINLINE angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1) +angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1) { INT64 dx = x1-x2; INT64 dy = y1-y2; @@ -1107,7 +1106,7 @@ boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y) // // R_PointInSubsector // -FUNCINLINE ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t y) +subsector_t *R_PointInSubsector(fixed_t x, fixed_t y) { size_t nodenum = numnodes-1; @@ -1120,12 +1119,13 @@ FUNCINLINE ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t y) // // R_IsPointInSubsector, same as above but returns 0 if not in subsector // -FUNCINLINE ATTRINLINE subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) +subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) { node_t *node; INT32 side, i; size_t nodenum; subsector_t *ret; + seg_t *seg; // single subsector is a special case if (numnodes == 0)