aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util/u_math.h
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util/u_math.h')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index b5e06630a..ec03e4e58 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -112,10 +112,13 @@ static INLINE float logf( float f )
#define logf(x) ((float)log((double)(x)))
#endif /* logf */
+#if _MSC_VER < 1800
#define isfinite(x) _finite((double)(x))
#define isnan(x) _isnan((double)(x))
+#endif /* _MSC_VER < 1800 */
#endif /* _MSC_VER < 1400 && !defined(__cplusplus) */
+#if _MSC_VER < 1800
static INLINE double log2( double x )
{
const double invln2 = 1.442695041;
@@ -133,6 +136,7 @@ roundf(float x)
{
return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
}
+#endif
#define INFINITY (DBL_MAX + DBL_MAX)
#define NAN (INFINITY - INFINITY)
@@ -717,13 +721,18 @@ util_bitcount(unsigned n)
*/
#ifdef PIPE_ARCH_BIG_ENDIAN
+#define util_le64_to_cpu(x) util_bswap64(x)
#define util_le32_to_cpu(x) util_bswap32(x)
#define util_le16_to_cpu(x) util_bswap16(x)
#else
+#define util_le64_to_cpu(x) (x)
#define util_le32_to_cpu(x) (x)
#define util_le16_to_cpu(x) (x)
#endif
+#define util_cpu_to_le64(x) util_le64_to_cpu(x)
+#define util_cpu_to_le32(x) util_le32_to_cpu(x)
+#define util_cpu_to_le16(x) util_le16_to_cpu(x)
/**
* Reverse byte order of a 32 bit word.
@@ -731,7 +740,8 @@ util_bitcount(unsigned n)
static INLINE uint32_t
util_bswap32(uint32_t n)
{
-#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)
+/* We need the gcc version checks for non-autoconf build system */
+#if defined(HAVE___BUILTIN_BSWAP32) || (defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403))
return __builtin_bswap32(n);
#else
return (n >> 24) |
@@ -741,6 +751,20 @@ util_bswap32(uint32_t n)
#endif
}
+/**
+ * Reverse byte order of a 64bit word.
+ */
+static INLINE uint64_t
+util_bswap64(uint64_t n)
+{
+#if defined(HAVE___BUILTIN_BSWAP64)
+ return __builtin_bswap64(n);
+#else
+ return ((uint64_t)util_bswap32(n) << 32) |
+ util_bswap32((n >> 32));
+#endif
+}
+
/**
* Reverse byte order of a 16 bit word.