summaryrefslogtreecommitdiffstats
path: root/src/util/rounding.h
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2015-06-25 16:47:52 -0700
committerMatt Turner <mattst88@gmail.com>2015-08-03 09:24:51 -0700
commit594fc0f85953d11c455e7ab549308a773b312d70 (patch)
treef23cb5f74f95e7f97fcc8e5c01b166c9a90edde9 /src/util/rounding.h
parentf55c408067a3ea3529fcf7cbbaa1a041a4a8849d (diff)
downloadexternal_mesa3d-594fc0f85953d11c455e7ab549308a773b312d70.zip
external_mesa3d-594fc0f85953d11c455e7ab549308a773b312d70.tar.gz
external_mesa3d-594fc0f85953d11c455e7ab549308a773b312d70.tar.bz2
mesa: Replace F_TO_I() with _mesa_lroundevenf().
I'm not sure what the true meaning of "The rounding mode may vary." is, but it is the case that the IROUND() path rounds differently than the other paths (and does it wrong, at that). Like _mesa_roundeven{f,}(), just add an use _mesa_lroundeven{f,}() that has known semantics. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Diffstat (limited to 'src/util/rounding.h')
-rw-r--r--src/util/rounding.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util/rounding.h b/src/util/rounding.h
index 0cbe926..088cf86 100644
--- a/src/util/rounding.h
+++ b/src/util/rounding.h
@@ -21,6 +21,9 @@
* IN THE SOFTWARE.
*/
+#ifndef _ROUNDING_H
+#define _ROUNDING_H
+
#include <math.h>
#ifdef __SSE4_1__
@@ -76,3 +79,25 @@ _mesa_roundeven(double x)
return rint(x);
#endif
}
+
+/**
+ * \brief Rounds \c x to the nearest integer, with ties to the even integer,
+ * and returns the value as a long int.
+ */
+static inline long
+_mesa_lroundevenf(float x)
+{
+ return lrintf(x);
+}
+
+/**
+ * \brief Rounds \c x to the nearest integer, with ties to the even integer,
+ * and returns the value as a long int.
+ */
+static inline long
+_mesa_lroundeven(double x)
+{
+ return lrint(x);
+}
+
+#endif