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
This commit is contained in:
John S 2024-11-26 18:15:54 -05:00 committed by GitHub
parent 831fdcefc9
commit 74e344bef6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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__)