X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Frounding.h;h=dfc691eaf1369f21c0375059a5da0ba8e299afc2;hb=49fa0747268af6aa22c89c5eacffe36bf93084d0;hp=ec31b47264e9344e1e07c0324cee56716f6caf51;hpb=21ccdbdb5dd87b2ee66c4e78b011ec4df29efb98;p=mesa.git diff --git a/src/util/rounding.h b/src/util/rounding.h index ec31b47264e..dfc691eaf13 100644 --- a/src/util/rounding.h +++ b/src/util/rounding.h @@ -24,10 +24,13 @@ #ifndef _ROUNDING_H #define _ROUNDING_H -#include +#include "c99_math.h" + #include +#include -#ifdef __x86_64__ +#if defined(__SSE__) || defined(_MSC_VER) +/* MSVC always has SSE nowadays */ #include #include #endif @@ -93,13 +96,13 @@ _mesa_roundeven(double x) static inline long _mesa_lroundevenf(float x) { -#ifdef __x86_64__ -#if LONG_BIT == 64 +#if defined(__SSE__) || defined(_MSC_VER) +#if LONG_MAX == INT64_MAX return _mm_cvtss_si64(_mm_load_ss(&x)); -#elif LONG_BIT == 32 || defined(_WIN32) +#elif LONG_MAX == INT32_MAX return _mm_cvtss_si32(_mm_load_ss(&x)); #else -#error "Unsupported or undefined LONG_BIT" +#error "Unsupported long size" #endif #else return lrintf(x); @@ -113,13 +116,13 @@ _mesa_lroundevenf(float x) static inline long _mesa_lroundeven(double x) { -#ifdef __x86_64__ -#if LONG_BIT == 64 +#if defined(__SSE__) || defined(_MSC_VER) +#if LONG_MAX == INT64_MAX return _mm_cvtsd_si64(_mm_load_sd(&x)); -#elif LONG_BIT == 32 || defined(_WIN32) +#elif LONG_MAX == INT32_MAX return _mm_cvtsd_si32(_mm_load_sd(&x)); #else -#error "Unsupported or undefined LONG_BIT" +#error "Unsupported long size" #endif #else return lrint(x);