mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Semiwrap / meson / robotpy define `NDEBUG` when building their software in all modes, while `allwplib` only does it when building debug. This causes the size of `DenseMap` to differ between the shared libraries built here, and the extension modules built in `mostrobotpy`, causing segfaults when you try to execute code that uses `DenseMap`. This is not a problem with the robotpy code in `allwpilib`, because bazel uses the exact same compiler flags when building the shared libraries and pybind11 extensions.
42 lines
1.2 KiB
Diff
42 lines
1.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: PJ Reiniger <pj.reiniger@gmail.com>
|
|
Date: Tue, 3 May 2022 22:50:24 -0400
|
|
Subject: [PATCH 13/35] Add lerp and sgn
|
|
|
|
---
|
|
llvm/include/llvm/Support/MathExtras.h | 21 +++++++++++++++++++++
|
|
1 file changed, 21 insertions(+)
|
|
|
|
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
|
|
index 60f8c48031b1809e9de66220103b3a504f32c225..acd16bb0e6cf73f565d44d654c34057d9b97dd95 100644
|
|
--- a/llvm/include/llvm/Support/MathExtras.h
|
|
+++ b/llvm/include/llvm/Support/MathExtras.h
|
|
@@ -759,6 +759,27 @@ using stack_float_t = volatile float;
|
|
using stack_float_t = float;
|
|
#endif
|
|
|
|
+// Typesafe implementation of the signum function.
|
|
+// Returns -1 if negative, 1 if positive, 0 if 0.
|
|
+template <typename T>
|
|
+constexpr int sgn(T val) {
|
|
+ return (T(0) < val) - (val < T(0));
|
|
+}
|
|
+
|
|
+/**
|
|
+ * Linearly interpolates between two values.
|
|
+ *
|
|
+ * @param startValue The start value.
|
|
+ * @param endValue The end value.
|
|
+ * @param t The fraction for interpolation.
|
|
+ *
|
|
+ * @return The interpolated value.
|
|
+ */
|
|
+template <typename T>
|
|
+constexpr T Lerp(const T& startValue, const T& endValue, double t) {
|
|
+ return startValue + (endValue - startValue) * t;
|
|
+}
|
|
+
|
|
} // namespace llvm
|
|
|
|
#endif
|