git: b4335268ba1b - 2026Q4 - games/xray-16: Fix build against math.h declaring rsqrt() in recent 16
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 17 Oct 2026 13:11:44 UTC
The branch 2026Q4 has been updated by vvd:
URL: https://cgit.FreeBSD.org/ports/commit/?id=b4335268ba1bf844a6728c93800aa15bc05c1285
commit b4335268ba1bf844a6728c93800aa15bc05c1285
Author: Martin Filla <freebsd@sysctl.cz>
AuthorDate: 2026-10-11 14:41:11 +0000
Commit: Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-10-17 13:11:31 +0000
games/xray-16: Fix build against math.h declaring rsqrt() in recent 16
FreeBSD's <math.h> now declares double rsqrt(double), which clashes with
the engine's own rsqrt() helper:
src/xrCore/_vector3d.h:359:8: error: exception specification in
declaration does not match previous declaration
359 | double rsqrt(double v) noexcept;
/usr/include/math.h:556:9: note: previous declaration is here
556 | double rsqrt(double);
Rename the engine helper to xr_rsqrt() in its declaration, its definition
and its four call sites so it no longer collides with the libm symbol.
PR: 299297
Sponsored by: UNIS Labs (vvd, commit patch)
(cherry picked from commit f8f8aa77d7a9d324b62f440940d7e4af374124b4)
---
.../files/patch-src_utils_xrMiscMath_vector.cpp | 11 +++++++
.../patch-src_utils_xrMiscMath_xrMiscMath.cpp | 38 ++++++++++++++++++++++
games/xray-16/files/patch-src_xrCore___vector3d.h | 11 +++++++
3 files changed, 60 insertions(+)
diff --git a/games/xray-16/files/patch-src_utils_xrMiscMath_vector.cpp b/games/xray-16/files/patch-src_utils_xrMiscMath_vector.cpp
new file mode 100644
index 000000000000..76d82add9cff
--- /dev/null
+++ b/games/xray-16/files/patch-src_utils_xrMiscMath_vector.cpp
@@ -0,0 +1,11 @@
+--- src/utils/xrMiscMath/vector.cpp.orig 2026-09-30 22:31:46 UTC
++++ src/utils/xrMiscMath/vector.cpp
+@@ -140,7 +140,7 @@ float angle_inertion_var(float src, float tgt, float m
+ return src;
+ }
+
+-double rsqrt(double v) noexcept { return 1.0 / _sqrt(v); }
++double xr_rsqrt(double v) noexcept { return 1.0 / _sqrt(v); }
+
+ //////////////////////////////////////////////////////////////////
+
diff --git a/games/xray-16/files/patch-src_utils_xrMiscMath_xrMiscMath.cpp b/games/xray-16/files/patch-src_utils_xrMiscMath_xrMiscMath.cpp
new file mode 100644
index 000000000000..ec4c0c90a80c
--- /dev/null
+++ b/games/xray-16/files/patch-src_utils_xrMiscMath_xrMiscMath.cpp
@@ -0,0 +1,38 @@
+--- src/utils/xrMiscMath/xrMiscMath.cpp.orig 2026-09-30 22:31:46 UTC
++++ src/utils/xrMiscMath/xrMiscMath.cpp
+@@ -8,7 +8,7 @@ bool exact_normalize(float* a)
+ double epsilon = 1.192092896e-05F;
+ if (sqr_magnitude > epsilon)
+ {
+- double l = rsqrt(sqr_magnitude);
++ double l = xr_rsqrt(sqr_magnitude);
+ a[0] *= l;
+ a[1] *= l;
+ a[2] *= l;
+@@ -31,7 +31,7 @@ bool exact_normalize(float* a)
+ {
+ a0 /= aa1;
+ a2 /= aa1;
+- l = rsqrt(a0*a0 + a2*a2 + 1);
++ l = xr_rsqrt(a0*a0 + a2*a2 + 1);
+ a[0] = a0*l;
+ a[1] = (double)_copysign(l, a1);
+ a[2] = a2*l;
+@@ -44,7 +44,7 @@ bool exact_normalize(float* a)
+ aa2_largest: // aa2 is largest
+ a0 /= aa2;
+ a1 /= aa2;
+- l = rsqrt(a0*a0 + a1*a1 + 1);
++ l = xr_rsqrt(a0*a0 + a1*a1 + 1);
+ a[0] = a0*l;
+ a[1] = a1*l;
+ a[2] = (double)_copysign(l, a2);
+@@ -61,7 +61,7 @@ bool exact_normalize(float* a)
+ }
+ a1 /= aa0;
+ a2 /= aa0;
+- l = rsqrt(a1*a1 + a2*a2 + 1);
++ l = xr_rsqrt(a1*a1 + a2*a2 + 1);
+ a[0] = (double)_copysign(l, a0);
+ a[1] = a1*l;
+ a[2] = a2*l;
diff --git a/games/xray-16/files/patch-src_xrCore___vector3d.h b/games/xray-16/files/patch-src_xrCore___vector3d.h
new file mode 100644
index 000000000000..9ba4c7e17080
--- /dev/null
+++ b/games/xray-16/files/patch-src_xrCore___vector3d.h
@@ -0,0 +1,11 @@
+--- src/xrCore/_vector3d.h.orig 2026-09-30 22:31:46 UTC
++++ src/xrCore/_vector3d.h
+@@ -356,7 +356,7 @@ bool _valid(const _vector3<T>& v)
+ //////////////////////////////////////////////////////////////////////////
+ #pragma warning(push)
+ #pragma warning(disable : 4244)
+-double rsqrt(double v) noexcept;
++double xr_rsqrt(double v) noexcept;
+ bool exact_normalize(float* a);
+ bool exact_normalize(Fvector3& a);
+ #pragma warning(pop)