X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Fmacros.h;h=73d4e68b99a8df792edd85f2056816b2fdfcea59;hb=aa5bc35f31863fd15219849bc09826fe5be3a2ba;hp=e3c785af508079f2b866bdbd280b3dd80c2947e2;hpb=d919ff0f279b6007809220dc43af26fc25435356;p=mesa.git diff --git a/src/util/macros.h b/src/util/macros.h index e3c785af508..73d4e68b99a 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -198,9 +198,7 @@ do { \ # 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 +# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) # endif # ifndef HAS_TRIVIAL_DESTRUCTOR /* It's always safe (if inefficient) to assume that a @@ -285,4 +283,35 @@ do { \ #define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C)) #define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C)) +/** Align a value to a power of two */ +#define ALIGN_POT(x, pot_align) (((x) + (pot_align) - 1) & ~((pot_align) - 1)) + +/** + * Macro for declaring an explicit conversion operator. Defaults to an + * implicit conversion if C++11 is not supported. + */ +#if __cplusplus >= 201103L +#define EXPLICIT_CONVERSION explicit +#elif defined(__cplusplus) +#define EXPLICIT_CONVERSION +#endif + +/** Set a single bit */ +#define BITFIELD_BIT(b) (1u << (b)) +/** Set all bits up to excluding bit b */ +#define BITFIELD_MASK(b) \ + ((b) == 32 ? (~0u) : BITFIELD_BIT((b) % 32) - 1) +/** Set count bits starting from bit b */ +#define BITFIELD_RANGE(b, count) \ + (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b)) + +/** Set a single bit */ +#define BITFIELD64_BIT(b) (1ull << (b)) +/** Set all bits up to excluding bit b */ +#define BITFIELD64_MASK(b) \ + ((b) == 64 ? (~0ull) : BITFIELD64_BIT(b) - 1) +/** Set count bits starting from bit b */ +#define BITFIELD64_RANGE(b, count) \ + (BITFIELD64_MASK((b) + (count)) & ~BITFIELD64_MASK(b)) + #endif /* UTIL_MACROS_H */