summaryrefslogtreecommitdiff
path: root/lib/mesa/src/util/macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/util/macros.h')
-rw-r--r--lib/mesa/src/util/macros.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/mesa/src/util/macros.h b/lib/mesa/src/util/macros.h
index efb896f4c..a66f1bfed 100644
--- a/lib/mesa/src/util/macros.h
+++ b/lib/mesa/src/util/macros.h
@@ -136,6 +136,17 @@ do { \
#define MALLOCLIKE
#endif
+/* Forced function inlining */
+#ifndef ALWAYS_INLINE
+# if defined(__GNUC__) || defined(__clang__)
+# define ALWAYS_INLINE inline __attribute__((always_inline))
+# elif defined(_MSC_VER)
+# define ALWAYS_INLINE __forceinline
+# else
+# define ALWAYS_INLINE inline
+# endif
+#endif
+
/* Used to optionally mark structures with misaligned elements or size as
* packed, to trade off performance for space.
*/
@@ -175,6 +186,10 @@ do { \
# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
# endif
+# elif defined(_MSC_VER) && !defined(__INTEL_COMPILER)
+# if _MSC_VER >= 1800
+# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T)
+# endif
# endif
# ifndef HAS_TRIVIAL_DESTRUCTOR
/* It's always safe (if inefficient) to assume that a
@@ -229,8 +244,8 @@ do { \
/** Compute ceiling of integer quotient of A divided by B. */
#define DIV_ROUND_UP( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
-/** Clamp X to [MIN,MAX] */
-#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+/** Clamp X to [MIN,MAX]. Turn NaN into MIN, arbitrarily. */
+#define CLAMP( X, MIN, MAX ) ( (X)>(MIN) ? ((X)>(MAX) ? (MAX) : (X)) : (MIN) )
/** Minimum of two values: */
#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )