Mesa (master): util: Define round and roundf on MSVC.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Fri Feb 11 12:33:00 UTC 2011


Module: Mesa
Branch: master
Commit: 151faa2258be40abbce017b65d95c52003053d2b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=151faa2258be40abbce017b65d95c52003053d2b

Author: José Fonseca <jfonseca at vmware.com>
Date:   Fri Feb 11 11:11:33 2011 +0000

util: Define round and roundf on MSVC.

---

 src/gallium/auxiliary/util/u_math.h |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index 37294b7..30555f9 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -176,7 +176,7 @@ static INLINE float logf( float f )
 
 #define isfinite(x) _finite((double)(x))
 #define isnan(x) _isnan((double)(x))
-#endif
+#endif /* _MSC_VER < 1400 && !defined(__cplusplus) */
 
 static INLINE double log2( double x )
 {
@@ -184,6 +184,18 @@ static INLINE double log2( double x )
    return log( x ) * invln2;
 }
 
+static INLINE double
+round(double x)
+{
+   return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+
+static INLINE float
+roundf(float x)
+{
+   return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
+}
+
 #endif /* _MSC_VER */
 
 




More information about the mesa-commit mailing list