From 2ae895c76f75559565af5dcc285cf10f9bd4555f Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Mon, 28 Mar 2011 10:11:20 +0200 Subject: [PATCH] COMMON: Add specialized templates for float ABS/MIN/MAX --- src/common/util.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/common/util.h b/src/common/util.h index 62f274f20f..c037ef7a01 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -19,6 +19,8 @@ #include "common/endianness.h" +#include + #ifdef MIN #undef MIN #endif @@ -64,6 +66,27 @@ inline uint64 NEXTPOWER2(uint64 x) { return x + 1; } +#ifdef HAVE_FABS +template<> inline double ABS(double x) { return fabs(x); } +#endif +#ifdef HAVE_FABSF +template<> inline float ABS(float x) { return fabsf(x); } +#endif + +#ifdef HAVE_FMIN +template<> inline double MIN(double a, double b) { return fmin(a, b); } +#endif +#ifdef HAVE_FMINF +template<> inline float MIN(float a, float b) { return fminf(a, b); } +#endif + +#ifdef HAVE_FMAX +template<> inline double MAX(double a, double b) { return fmax(a, b); } +#endif +#ifdef HAVE_FMAXF +template<> inline float MAX(float a, float b) { return fmaxf(a, b); } +#endif + /** * Macro which determines the number of entries in a fixed size array. */