i965/fs: Make half() divide the register width by 2 and use it more
[mesa.git] / src / util / macros.h
index ee05e05a4a889f9b1ab12bf6c526412882eaa184..40ebf02da84cc86c22cbd930d29c8f07185604e4 100644 (file)
 /**
  * __builtin_expect macros
  */
-#if !defined(__GNUC__)
+#if !defined(HAVE___BUILTIN_EXPECT)
 #  define __builtin_expect(x, y) (x)
 #endif
 
 #ifndef likely
-#  ifdef __GNUC__
+#  ifdef HAVE___BUILTIN_EXPECT
 #    define likely(x)   __builtin_expect(!!(x), 1)
 #    define unlikely(x) __builtin_expect(!!(x), 0)
 #  else
  * Unreachable macro. Useful for suppressing "control reaches end of non-void
  * function" warnings.
  */
-#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
+#ifdef HAVE___BUILTIN_UNREACHABLE
 #define unreachable(str)    \
 do {                        \
    assert(!str);            \
    __builtin_unreachable(); \
 } while (0)
-#elif (defined(__clang__) && defined(__has_builtin))
-# if __has_builtin(__builtin_unreachable)
-#  define unreachable(str)  \
-do {                        \
-   assert(!str);            \
-   __builtin_unreachable(); \
-} while (0)
-# endif
 #endif
 
 #ifndef unreachable
 #define unreachable(str)
 #endif
 
+#ifdef HAVE_FUNC_ATTRIBUTE_FLATTEN
+#define FLATTEN __attribute__((__flatten__))
+#else
+#define FLATTEN
+#endif
 
-#if (__GNUC__ >= 3)
+#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT
 #define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
 #else
 #define PRINTFLIKE(f, a)
 #endif
 
+#ifdef HAVE_FUNC_ATTRIBUTE_MALLOC
+#define MALLOCLIKE __attribute__((__malloc__))
+#else
+#define MALLOCLIKE
+#endif
 
 /* Used to optionally mark structures with misaligned elements or size as
  * packed, to trade off performance for space.
  */
-#if (__GNUC__ >= 3)
+#ifdef HAVE_FUNC_ATTRIBUTE_PACKED
 #define PACKED __attribute__((__packed__))
 #else
 #define PACKED
 #endif
 
-
 #ifdef __cplusplus
 /**
  * Macro function that evaluates to true if T is a trivially