diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-12-31 07:12:27 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-12-31 07:12:27 +0000 |
commit | 051645c92924bf915d82bf219f2ed67309b5577a (patch) | |
tree | 4aae126dd8e5a18c6a9926a5468d1561e6038a07 /lib/mesa/src/util/macros.h | |
parent | 2dae6fe6f74cf7fb9fd65285302c0331d9786b00 (diff) |
Merge Mesa 17.2.8
Diffstat (limited to 'lib/mesa/src/util/macros.h')
-rw-r--r-- | lib/mesa/src/util/macros.h | 19 |
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) ) |