Commit 07ac4269 authored by Kenneth Graunke's avatar Kenneth Graunke Committed by Dylan Baker

util: Add a _mesa_i64roundevenf() helper.

This always returns a int64_t, translating to _mesa_lroundevenf on
systems where long is 64-bit, and llrintf where "long long" is needed.

Fixes: 594fc0f8 ("mesa: Replace F_TO_I() with _mesa_lroundevenf().")
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: Matt Turner's avatarMatt Turner <mattst88@gmail.com>
(cherry picked from commit b59914e1)
parent c2aad5dc
......@@ -129,4 +129,20 @@ _mesa_lroundeven(double x)
#endif
}
/**
* \brief Rounds \c x to the nearest integer, with ties to the even integer,
* and returns the value as an int64_t.
*/
static inline int64_t
_mesa_i64roundevenf(float x)
{
#if LONG_MAX == INT64_MAX
return _mesa_lroundevenf(x);
#elif LONG_MAX == INT32_MAX
return llrintf(x);
#else
#error "Unsupported long size"
#endif
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment