aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Fonseca <[email protected]>2015-08-09 11:25:41 +0100
committerJose Fonseca <[email protected]>2015-08-09 11:32:43 +0100
commit21ccdbdb5dd87b2ee66c4e78b011ec4df29efb98 (patch)
treef153b5b0a59ea96007f240849bf54dd5e7d20b4c
parenteb643db30e1bdf5171d0a012674016c317925b6e (diff)
util: Cope with LONG_BIT not being defined on Windows.
Neither MSVC nor MinGW defines LONG_BIT. For MSVC this was not a problem as it doesn't define __x86_64__ macro (it's GCC specific.) However on Windows long type is guaranteed to be 32bits. Also add an #error, as GCC will just warn, not throw any error, when no value is returned. Trivial.
-rw-r--r--src/util/rounding.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/util/rounding.h b/src/util/rounding.h
index b0c9918fd6e..ec31b47264e 100644
--- a/src/util/rounding.h
+++ b/src/util/rounding.h
@@ -96,8 +96,10 @@ _mesa_lroundevenf(float x)
#ifdef __x86_64__
#if LONG_BIT == 64
return _mm_cvtss_si64(_mm_load_ss(&x));
-#elif LONG_BIT == 32
+#elif LONG_BIT == 32 || defined(_WIN32)
return _mm_cvtss_si32(_mm_load_ss(&x));
+#else
+#error "Unsupported or undefined LONG_BIT"
#endif
#else
return lrintf(x);
@@ -114,8 +116,10 @@ _mesa_lroundeven(double x)
#ifdef __x86_64__
#if LONG_BIT == 64
return _mm_cvtsd_si64(_mm_load_sd(&x));
-#elif LONG_BIT == 32
+#elif LONG_BIT == 32 || defined(_WIN32)
return _mm_cvtsd_si32(_mm_load_sd(&x));
+#else
+#error "Unsupported or undefined LONG_BIT"
#endif
#else
return lrint(x);