From 74e344bef60d04952b5974f702a8d411797448b0 Mon Sep 17 00:00:00 2001 From: John S <138552829+Multi-Volt@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:15:54 -0500 Subject: [PATCH] Fix issues in PR #359 relating to incorrect handling of miscellaneous data types (#527) * Update math_util.h to fix issues in last PR * Update math_util.h again --- src/engine/math_util.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 6df41f3af..b6d1d51a3 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -42,20 +42,24 @@ s16 sqr(s16 x); f32 sins(s16 sm64Angle); f32 coss(s16 sm64Angle); +// Generic macros help the inline functions be noted in autodoc while retaining original functionality #define min(a, b) _Generic((a), \ - f32: minf, \ - default: min \ -)(a, b) + f32: minf(a, b), \ + s16: (min)(a, b), \ + default: ((a) < (b) ? (a) : (b)) \ +) #define max(a, b) _Generic((a), \ - f32: maxf, \ - default: max \ -)(a, b) + f32: maxf(a, b), \ + s16: (max)(a, b), \ + default: ((a) > (b) ? (a) : (b)) \ +) #define sqr(x) _Generic((x), \ - f32: sqrf, \ - default: sqr \ -)(x) + f32: sqrf(x), \ + s16: (sqr)(x), \ + default: ((x) * (x)) \ +) #if defined(__clang__) || defined(__GNUC__)