i965: switch gen6 to use its own cc state bo
[mesa.git] / src / mesa / main / compiler.h
index 87c3b2e5621457a13d364d7c22214a856e499b16..5557a3b5cb5ac4ffd804bb27d84ee22d389dc6c6 100644 (file)
@@ -65,9 +65,7 @@ extern "C" {
    typedef unsigned __int8    uint8_t;
    typedef __int16            int16_t;
    typedef unsigned __int16   uint16_t;
-#  ifndef __eglplatform_h_
-     typedef __int32            int32_t;
-#  endif
+   typedef __int32            int32_t;
    typedef unsigned __int32   uint32_t;
    typedef __int64            int64_t;
    typedef unsigned __int64   uint64_t;
@@ -173,7 +171,7 @@ extern "C" {
  * We also need to define a USED attribute, so the optimizer doesn't 
  * inline a static function that we later use in an alias. - ajax
  */
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
 #  define PUBLIC __attribute__((visibility("default")))
 #  define USED __attribute__((used))
 #else
@@ -196,10 +194,17 @@ extern "C" {
 /**
  * __builtin_expect macros
  */
-#if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900)
+#if !defined(__GNUC__)
 #  define __builtin_expect(x, y) x
 #endif
 
+#ifdef __GNUC__
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else
+#define likely(x) !!(x)
+#define unlikely(x) !!(x)
+#endif
 
 /**
  * The __FUNCTION__ gcc variable is generally only used for debugging.
@@ -209,7 +214,7 @@ extern "C" {
 #ifndef __FUNCTION__
 # if defined(__VMS)
 #  define __FUNCTION__ "VMS$NL:"
-# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
+# elif !defined(__GNUC__) && !defined(__xlC__) &&      \
       (!defined(_MSC_VER) || _MSC_VER < 1300)
 #  if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
     (defined(__SUNPRO_C) && defined(__C99FEATURES__))
@@ -219,11 +224,23 @@ extern "C" {
 #  endif
 # endif
 #endif
+#ifndef __func__
+#  if (__STDC_VERSION__ >= 199901L) || \
+      (defined(__SUNPRO_C) && defined(__C99FEATURES__))
+       /* __func__ is part of C99 */
+#  elif defined(_MSC_VER)
+#    if _MSC_VER >= 1300
+#      define __func__ __FUNCTION__
+#    else
+#      define __func__ "<unknown>"
+#    endif
+#  endif
+#endif
 
 
 /**
- * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
- * Do not use them unless absolutely necessary!
+ * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32.
+ * Do not use these unless absolutely necessary!
  * Try to use a runtime test instead.
  * For now, only used by some DRI hardware drivers for color/texel packing.
  */
@@ -234,11 +251,14 @@ extern "C" {
 #elif defined(__APPLE__)
 #include <CoreFoundation/CFByteOrder.h>
 #define CPU_TO_LE32( x )       CFSwapInt32HostToLittle( x )
-#elif defined(_AIX)
-#define CPU_TO_LE32( x )        x = ((x & 0x000000ff) << 24) | \
-                                    ((x & 0x0000ff00) <<  8) | \
-                                    ((x & 0x00ff0000) >>  8) | \
-                                    ((x & 0xff000000) >> 24);
+#elif (defined(_AIX) || defined(__blrts))
+static INLINE GLuint CPU_TO_LE32(GLuint x)
+{
+   return (((x & 0x000000ff) << 24) |
+           ((x & 0x0000ff00) <<  8) |
+           ((x & 0x00ff0000) >>  8) |
+           ((x & 0xff000000) >> 24));
+}
 #else /*__linux__ */
 #include <sys/endian.h>
 #define CPU_TO_LE32( x )       bswap32( x )
@@ -308,6 +328,11 @@ extern "C" {
 #endif
 #endif
 
+#if (__GNUC__ >= 3)
+#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
+#else
+#define PRINTFLIKE(f, a)
+#endif
 
 #ifndef NULL
 #define NULL 0
@@ -318,8 +343,7 @@ extern "C" {
  * LONGSTRING macro
  * gcc -pedantic warns about long string literals, LONGSTRING silences that.
  */
-#if !defined(__GNUC__) || (__GNUC__ < 2) || \
-    ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 7))
+#if !defined(__GNUC__)
 # define LONGSTRING
 #else
 # define LONGSTRING __extension__
@@ -334,6 +358,10 @@ extern "C" {
 #define M_E (2.7182818284590452354)
 #endif
 
+#ifndef M_LOG2E
+#define M_LOG2E     (1.4426950408889634074)
+#endif
+
 #ifndef ONE_DIV_LN2
 #define ONE_DIV_LN2 (1.442695040888963456)
 #endif