diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2019-08-23 11:08:48 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-09-04 11:55:50 -0700 |
commit | 07ac4269a512464777f6f90abca7067506716526 (patch) | |
tree | 3f00280042eb53233133c9c6bd1377a55d6d9acd /src | |
parent | c2aad5dc4d203da5aabe8537009429e2f6c0e51b (diff) | |
download | mesa-07ac4269a512464777f6f90abca7067506716526.tar.gz |
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: 594fc0f8595 ("mesa: Replace F_TO_I() with _mesa_lroundevenf().")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
(cherry picked from commit b59914e179a9e5930af37e7f7c0d8eafd682caff)
Diffstat (limited to 'src')
-rw-r--r-- | src/util/rounding.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/rounding.h b/src/util/rounding.h index dfc691eaf13..fd343ab929b 100644 --- a/src/util/rounding.h +++ b/src/util/rounding.h @@ -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 |